Re: embedded SQL question?
Date: 1996/12/10
Message-ID: <58jkua$62k_at_newton.pacific.net.sg>#1/1
ruihua_at_cat.cs.mu.OZ.AU (Rui Hua Sarah YANG) wrote:
>Hello,
>
> Can anyone tell me whether I can use a variable to replace a table name in a
> embedded SQL program(The purpose is to make the program generic)? If you
> know the answer, would you please tell me how to do it? Thanks!
> my email address is : ruihua_at_cs.mu.oz.au
>ruihua_at_cat.cs.mu.OZ.AU (Rui Hua Sarah YANG) wrote:
>Hello,
>
> Can anyone tell me whether I can use a variable to replace a table name in a
> embedded SQL program(The purpose is to make the program generic)? If you
> know the answer, would you please tell me how to do it? Thanks!
> my email address is : ruihua_at_cs.mu.oz.au
>
Hi there,
You need to PREPARE and execute the SQL statement to acheive your objectives. Please refere to PRO*C manual appendix, an example is described in detail.
An example
strcpy(sql_stmt.arr, "select c1, c2 from "); strcat(sql_stmt.arr, table_name.arr);
EXEC SQL PREPARE sql_stmt;
EXEC SQL OPEN sql_stmt;
This is just an idea, please refer to PRO*C manual for additional info.
Regards
N.Prabhakar Received on Tue Dec 10 1996 - 00:00:00 CET