My task is to write a stored procedure that will first validate the data from a temporary table and then insert the data into the main table.
For this I am planning to iterate over each row of the temp table, validate it using some other stored procedure or user defined function and then insert the data into the main table.
My problem is how to iterate over the rows of temp table without using CURSORS because they are very slow and memory consuming. I want to use some looping structure instead of CURSOR.
Of course if any one has any other algorithm for the above problem there suggestions are welcome.
PS: I am using MYSQL DB
Without the use of Cursor, you could iterate using a temporary table and a While..Do statement.
Let’s say you have two tables
And
Create the following routine, and adjust the validation process: