how to de-reference a variable for an INSERT command?
Posted in 1997
Hi, All!
I'm having trouble writing the correct SQL in a *stored procedure*.
my_table contains a column that has table names which I select into a
variable called 'tbl'. As I step through the result set, I want to insert
into the table named by the variable 'tbl'.
When I execute this stored procedure, I get an error saying that table
'tbl' doesn't exist. How do I de-reference the variable for the INSERT
statement? I'm not allowed to do a PREPARE within a stored procedure, and
I can't seem to find any other way to do this in the Informix manuals.
FOREACH SELECT col1 INTO tbl FROM my_table
WHERE <some condition>
INSERT INTO tbl VALUES( blah, blah, blah );
DELETE FROM my_table
WHERE <some condition>;END FOREACH;
Any help is appreciated. Thanks!
--
Wanda Beck