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 8933623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:35:11+00:00 2026-06-15T09:35:11+00:00

I have a delimited string of values like such: 00,45,50,66,84,99. This string is passed

  • 0

I have a delimited string of values like such: 00,45,50,66,84,99. This string is passed as an IN parameter to a DB2 stored procedure. In the procedure, I would like to loop through this string and insert each value into a temp table. My knowledge of DB2 looping syntax is very poor and I have been struggling with this for awhile. Any help would be much appreciated, thank you!

  • 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-15T09:35:12+00:00Added an answer on June 15, 2026 at 9:35 am

    You can define a recursive SP that takes the IN varchar, processes the first element, and do a recursive call for the rest.

    CREATE OR REPLACE PROCEDURE REC (
     IN STRING VARCHAR(256)
    )
    P_REC: BEGIN
     DECLARE INDEX SMALLINT;
     DECLARE PRE VARCHAR(256);
     DECLARE POS VARCHAR(256);
     DECLARE STMT STATEMENT;
     PREPARE STMT FROM 'CALL REC(?)';
    
     SET INDEX = POSSTR (STRING, ',');
     IF (INDEX <> 0) THEN
      SET PRE = SUBSTR(STRING, 1, INDEX - 1);
      INSERT INTO table
        VALUES (PRE);
      -- Recursive call
      SET POS = SUBSTR(STRING, INDEX + 1);
      EXECUTE STMT USING POS;
     ELSE
      INSERT INTO table
        VALUES (STRING);
     END IF;
    END P_REC @
    

    To make it work from db2clp:

    db2 create table table (string varchar(256))
    db2 -td@
     <Copy, paste> in the interactive mode + quit
    db2 call rec ('00,45,50,66,84,99')
    db2 select * from table
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a pipe delimited string like this: blah|blah|blah|blah|blah|blah|blah|blah|blah|oldDate|blah|blah| I would like replace the
I have a List of String objects that are pipe delimited. something like this:
I have a string: [{id:1,gameName:arizona,cost:0.5E1,email:hi@gmail.com,requests:0},{id:2,gameName:arizona,cost:0.5E1,email:hi@gmail.com,requests:0},{id:3,gameName:arizona,cost:0.5E1,email:hi@gmail.com,requests:0}] However, I would like to parse this string into
I have a string that contains multiple parameters delimited by #, like this :
I have hashmap that has keys like this:'2+4+5' , '653+65+1324+75'.(integer values delimited by a
After spliting a tab delimited file I have my required values in a string
I have a server reading inbound newline-delimited strings. The pipeline looks like this: ...
I have a Javascript string array with values like A12, B50, C105 etc. and
I have a SQL Server 2008 database. This database has a stored procedure that
I have a list of integer values (List) and would like to generate a

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.