Re: ESQL Guru? Need Help!
Posted in 1996
Topics: SQL Development & Query Writing, Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL
Chao Y. Din wrote:
>
> 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!!!
>
> Chao
Hi Chao!
I'm not sure, but I think something like the following will do the trick:
int x;
sprintf(szStmt,"INSERT INTO table1 SELECT %d,y FROM table2",x);
EXEC SQL prepare ins_stmt from :szStmt;
EXEC SQL execute ins_stmt;
I have not tried it myself, but I see no reason why this should not work.
Cheers,
Dirk
--
---------------------------------------------------
Dirk Schmidtpott S I E M E N S
EMail: schmd@dbm212.pdb.sni.de =============
Phone: 0049-5251-8-14922 N I X D O R F
Fax : 0049-5251-8-27905
The above statements and opinions are my own and do
not necessarily represent those of my employer.
---------------------------------------------------