Subject Re: [IBO] Re: Building a statement at runtime
Author Helen Borrie
At 10:52 AM 18-06-02 +0000, you wrote:
>Ciao, lele
>I try to explain better.
>I've created, in the sql explorer, a new procedure:
>CREATE PROCEDURE PROCEDURE1 AS
>declare variable C0 varchar(100);
>declare variable C1 varchar(100);
>declare variable C2 varchar(100);
>declare variable C3 varchar(100);
>declare variable C4 varchar(100);
>BEGIN
>C1 = 'INSERT INTO PIANIF(MINUTI, ';
>C2 = 'CLV2) ';
>C3 = 'VALUES(1, ';
>C4 = '"00003")';
>C0 = C1+C2+C3+C4;
>C0;
>END
>After clicking "Apply" the error message is:
>General SQL error
>Token unknown - line 13, char 1
>;
>=============================
>In IB_WISQL the error is:
>------------------
>Page Error message
>ISC ERROR CODE:335544569
>
>ISC ERROR MESSAGE:
>Dynamic SQL Error
>SQL error code = -104
>Token unknown - line 13, char 1
>;
>
>STATEMENT:
>TIB_DSQL: "frmDSQL.dsqlEdit"
>------------------
>Page SQL message
>SQL ERROR CODE:-104
>
>SQL ERROR MESSAGE:
>Invalid token
>=============================

Paolo,
You simply CANNOT do this. In IB/FB, stored procedures are validated and
compiled at create time, never at run-time. Thus, you cannot use variables
to represent either elements of an SQL statement nor metadata objects,
because the compiler needs to know and validate the metadata before it will
compile your procedure. Variables can be *only* constants representing data.

Bad luck. You will have to find another way to construct these run-time
statements and you must do them in your client application.

regards,
Helen

All for Open and Open for All
Firebird Open SQL Database · http://firebirdsql.org ·
http://users.tpg.com.au/helebor/
_______________________________________________________