Re: select from <variable>
Posted in 1991
>
> I have a problem.
>
> In conventional way. table name is fixed:
>
> select xx,yy,zz
> from table
> where .......>
> What we want to do is to use string variable as table name.
> We want to change table name dynamically.
> Informix 4GL or ESQL/C does not have such a facility?
No problem. Take this 4gl code for instance:
DEFINE tabname CHAR(30), dum_str CHAR(200)
.
.
.
IF something THEN
LET tabname = "thistable"
ELSE
LET tabname = "thattable"
END IF
LET dum_str = "SELECT xx, yy, zz FROM ", tabname CLIPPED, " WHERE ..."
PREPARE ppp FROM dum_str
DECLARE c_ppp CURSOR FOR ppp
OPEN c_ppp
>
> Thank you.
>
> Teruki Niki
> Tokyo Research Lab.
> Matsushita Electric Industrial Co,. Ltd.
>
----------
Snorri Bergmann | Internet: snorri@strengur.is
Strengur Consulting Engineers | Bang: ...!uunet!strengur.is!snorri
Storhofdi 15 | Phone: +354 1 685130
112 Reykjavik Iceland | Telefax: +354 1 680628