Re: how to de-reference a variable for an INSERT command?
Posted in 1997
Thanks, Chuck! Looks like I'll have to do this in ESQL.
--
Wanda Beck
cludwigsen@worldnet.att.net ("Chuck Ludwigsen") on 08/14/97 10:29:09 PM
To: informix-list@rmy.emory.edu @ smtp
cc: (bcc: Wanda Beck/SYBASE)
Subject: Re: how to de-reference a variable for an INSERT command?
No can do, Wanda. SPL doesn't allow dynamic sql statements. The table
must be specified. Although it is ugly, with a limited list of tables, you
could do this with an if/elif construct. Its about the only option if you
must use SPL for the task.
** I hate it when I have to give bad news **
++-------------------------------------------------------------------------
-
-------------------------------------++
Chuck Ludwigsen <cludwigs@hotmail.com>
Database Engineer <cludwigsen@harrahs.com>
Harrah's Entertainment, Inc. <www.harrahs.com>
President, Memphis Informix User's Group <miug@hotmail.com>
++-------------------------------------------------------------------------
-
-------------------------------------++
"Wanda Beck" <wbeck@sybase.com> wrote in article
<5svot3$ech@cssun.mathcs.emory.edu>...
>
> 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
>
>
>