I have a small problem that I need help with.
I have a loop that adds the values into a table from a store procedure that I use in a select. The SP can return one or more rows. t_rownr tells which row it is. It always starts at 1.This is working properly. The problem is that I have a loop that is outside it. If ct_max value is greater than 1, it shall repeat the select and insert. This is where the problem comes. My select returns the same value, but I want it to increase t_rownr each time the loop is executed.
Example If ct_max = 4:
This may not be the right or best way to clone lines and increase t_rownr every time the clone?
I've tried to add this to enumerate the line number (t_rownr + ct_counter) -1. It works if the select returns only one row, but not when it retunerar several rows.
Someone who can help me solve this?
This is not the optimal way because of database performance concerns, but I used select count + 1 to determine the next row number for each insert statement.
SET ct_max = 10;
answered 05 Jul '14, 10:17