Declare Cursor with Variable
How do I declare a cursor using a variable for the SELECT clause? Example: the variable "tabl" contains the value of the table I wish to declare a cursor upon. The following code will not work (invalid cursor error):
declare cursor cursor_table is SELECT * from tabl;
The reason I am using the variable "tabl" is because this section of code operates inside a loop. The loop is repeated once for every record in a "driver" table. The driver table contains the names of other tables which I wish to declare (and open) the cursor upon. The variable "tabl" holds the names of these tables.
Any help is appreciated.
Thanks.