This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
insert into NEW_TABLE (COLUMN_A, COLUMN_B) select COLUMN_1, COLUMN_2 from OLD_TABLE where COLUMN_3 like 'variable%';
COLUMN_3 is VARCHAR2 type.
I want to loop through the above SQL with a different variable each time. How do I create a list of the variables and set a for or while loop to go through it? The list of the variable could be something like: aa, bb, cc, dd, ...
Elizabeth, You can add the values to a collection like an ArrayList. Then you can iterate through the list and call the insert each time. Note that it is likely to be more efficient to set a batch insert statement within the loop and then make only one call to the database.
Elizabeth, I didn't catch that from the original post.
Have you looked into PL SQL arrays? Are you stuck on a specific part?
Purushoth Thambu
Ranch Hand
Joined: May 24, 2003
Posts: 425
posted
0
Since you are in 10g you can make use of regular expression function and get away with loops. Something like below
This will work as long as comma separated input_variable doesn't have spaces between commas. [ February 27, 2007: Message edited by: Purushothaman Thambu ]
Elizabeth King
Ranch Hand
Joined: Jul 11, 2002
Posts: 189
posted
0
Where do I set my string values: aa,bb,cc,dd? Do you mean this: