Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8461221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:49:14+00:00 2026-06-10T13:49:14+00:00

I am trying to write a procedure which will accept victims and their count.The

  • 0

I am trying to write a procedure which will accept victims and their count.The victims
parameter will contain the values like this '123,321,222' and I am using a function
call SPLIT_STR_FUNCTION to split the text into comma seperated values. Then I
will insert each value in the database.

here is my procedure :

CREATE DEFINER=`root`@`localhost` PROCEDURE `InsertPost`( in pmsg text, in pthumbPath text, in ppath text, in puserid bigint, in count int, in victims text) 
BEGIN 
INSERT INTO posts(path,thumbpath,msg,userid) VALUES(ppath,pthumbpath,pmsg,puserid);


SET @lastpostid = (SELECT postid FROM posts ORDER BY postid DESC LIMIT 1);

SET @startindex=1;

WHILE @startindex <= count DO 
SET @IndividualIDs=convert((select SPLIT_STR_Function(victims, ',', @startindex)),signed); 
SET @startindex=startindex+1;     
INSERT INTO victims(victimid,postid) VALUES(@IndividualIDs,@lastpostid); 

end WHILE; 
END

Error:
Unknown column startindex in the field list

SPLIT_STR_FUNCTION: (from here)

CREATE DEFINER=`root`@`localhost` FUNCTION `SPLIT_STR_Function`(
x VARCHAR(255),
delim VARCHAR(12),
pos INT
 ) 

 RETURNS varchar(255) CHARSET latin1
 RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(x, delim, pos),
    LENGTH(SUBSTRING_INDEX(x, delim, pos -1)) + 1),
    delim, '')
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T13:49:15+00:00Added an answer on June 10, 2026 at 1:49 pm

    Your user variable @startindex is missing its @ when you increment it:

    SET @startindex=startindex+1;
    -- Should be:
    SET @startindex = @startindex+1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write a stored procedure in MySQL which will perform a
I am trying to write a stored procedure in sql server 2005 which will
In MySQL I'm trying to write a Stored Procedure which does the following: Run
I'm trying to write a procedure for a baseball program that will use multiple
I'm trying to write a stored procedure in SQL that will : Make a
I'm trying to create a simple stored procedure which I can use to write
I am trying to write a routine which will execute a DOS batch program
I am trying to write a stored procedure which selects columns from a table
I'm trying to write a stored procedure in which I insert a few things
I'm trying to build a python procedure that: Open a .txt file (which contain

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.