Subject | Executing DSQL inside a stored procedure |
---|---|
Author | Jaume Andreu Sabater Malondra |
Post date | 2002-09-07T18:26:42Z |
Hi, people.
I have got a problem with DSQL. I have dynamically built an UPDATE statement,
which is located inside a varchar variable. But I can't find the way to make
Firebird execute. I am inside a stored procedure. Here is the code:
[..]
DECLARE VARIABLE SQL_UPDATE VARCHAR(255);
DECLARE EXEC_UPDATE STATEMENT;
[..]
/* Now SQL_UPDATE contains something like
UPDATE GROUPS SET
GRP_GRPNAM = :P_GRPNAM,
GRP_PARCOD = :P_PARCOD,
GRP_PASSWD = :P_PASSWD
WHERE GRP_GRPCOD = :P_GRPCOD;
where :P_GRPNAM, :P_PARCOD, :P_PASSWD and :P_GRPCOD are the input stored
procedure parameters. */
PREPARE EXEC_UPDATE FROM :SQL_UPDATE;
EXECUTE :EXEC_UPDATE;
And here is the error:
ISC ERROR CODE: 335544569
ISC ERROR MESSAGE
Dynamic SQL Error
SQL error code = -104
Token Unknown - line 16, char 9
EXEC_UPDATE
Line 16 is the second declaration at top, the on with "DECLARE EXEC_UPDATE
STATEMENT" is.
If I take that line out, then the error is
ISC ERROR CODE: 335544569
ISC ERROR MESSAGE:
Dynamic SQL Error
SQL error code = -104
Token unknown - line 103, char 15
EXEC_UPDATE
Line 103 is the one with the PREPARE statement.
This is the first time I try this (using DSQL inside a stored procedure), so I
really don't know what to do.
I hope any of you may help me. Meanwhile I'll read the language reference
manual again and see if I forgot something. Thanks in advance anyway.
P.S.: I also tried to use EXECUTE IMMEDIATE instead of PREPARE and EXECUTE,
since the language reference says it, but I got a "TOKEN UNKNOWN 'IMMEDIATE'"
error, which stopped me.
--
Jaume Andreu Sabater Malondra
jsabater@...
Registered linux user #209072
"Ubi sapientas ibi libertas"
I have got a problem with DSQL. I have dynamically built an UPDATE statement,
which is located inside a varchar variable. But I can't find the way to make
Firebird execute. I am inside a stored procedure. Here is the code:
[..]
DECLARE VARIABLE SQL_UPDATE VARCHAR(255);
DECLARE EXEC_UPDATE STATEMENT;
[..]
/* Now SQL_UPDATE contains something like
UPDATE GROUPS SET
GRP_GRPNAM = :P_GRPNAM,
GRP_PARCOD = :P_PARCOD,
GRP_PASSWD = :P_PASSWD
WHERE GRP_GRPCOD = :P_GRPCOD;
where :P_GRPNAM, :P_PARCOD, :P_PASSWD and :P_GRPCOD are the input stored
procedure parameters. */
PREPARE EXEC_UPDATE FROM :SQL_UPDATE;
EXECUTE :EXEC_UPDATE;
And here is the error:
ISC ERROR CODE: 335544569
ISC ERROR MESSAGE
Dynamic SQL Error
SQL error code = -104
Token Unknown - line 16, char 9
EXEC_UPDATE
Line 16 is the second declaration at top, the on with "DECLARE EXEC_UPDATE
STATEMENT" is.
If I take that line out, then the error is
ISC ERROR CODE: 335544569
ISC ERROR MESSAGE:
Dynamic SQL Error
SQL error code = -104
Token unknown - line 103, char 15
EXEC_UPDATE
Line 103 is the one with the PREPARE statement.
This is the first time I try this (using DSQL inside a stored procedure), so I
really don't know what to do.
I hope any of you may help me. Meanwhile I'll read the language reference
manual again and see if I forgot something. Thanks in advance anyway.
P.S.: I also tried to use EXECUTE IMMEDIATE instead of PREPARE and EXECUTE,
since the language reference says it, but I got a "TOKEN UNKNOWN 'IMMEDIATE'"
error, which stopped me.
--
Jaume Andreu Sabater Malondra
jsabater@...
Registered linux user #209072
"Ubi sapientas ibi libertas"