>----------
>From: Chao Y. Din
>To: informix-list@rmy.emory.edu
>Subject: ESQL Guru? Need Help!
>Date: Wednesday, July 31, 1996 11:08AM
>In a stored procedure, I can use a single insert/select statement to copy
>one table to another and ....
>
> LET x = ...;
> INSERT INTO table1
> SELECT x, y FROM table2 ...;>
>Where x is a local variable, and y is a column name of table2. Since it
>is a stored procedure, "x" does not need ":", and the above program
>works.
>How do I accomplish the same thing in ESQL/C? Sorry, I don't have 4GL
>and any other tools. If x is a variable (or host variable), it must have
>":" in front, yet only where clause accept host variables. Help!!!
Create a dynamic query then execute it.
For example, if x is a number
sprintf (strStmt,"INSERT INTO table1 SELECT %d, y FROM table2 WHERE ...", x);
EXEC SQL prepare i_id from :strSTmt;
EXEC SQL execute i_id;
EXEC SQL free i_id;
Chao