Subject | Re: [IBO] How to declare variable in query? |
---|---|
Author | Paul Vinkenoog |
Post date | 2004-05-19T13:45:02Z |
Hi Rafael,
statement. It can be complex and multiline, but it's still a single
statement.
For multiple statements in a row, and for procedure and trigger
definitions, you need a TIB_Script.
BTW, are you sure that "DECLARE varCount integer;" works? As far as I
know it must be "DECLARE VARIABLE".
Do you have the Firebird Quickstart Guide and the InterBase 6.0
documentation set, especially the Data Definition Guide? I think you
should study those. You can get them at
http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_download_documentation
Greetings,
Paul Vinkenoog
> No .. is not this. I need to do in query ... like this:You can't put that in a Query. A Query always contains a single SQL
>
> DECLARE varCount integer;
> begin
> SELECT Count(*) FROM Conta WHERE NomeConta = 'gugu' into varcount;
> if (varCount <= 0) then
> INSERT INTO Conta (NomeConta,IsAtiva) VALUES ('gugu', 1);
>
> This query works if I put in stored procedure, but not work if i put
> like:
>
> Ib_Query.sql.text :=
> DECLARE varCount integer;
> begin
> SELECT Count(*) FROM Conta WHERE NomeConta = 'gugu' into varcount;
> if (varCount <= 0) then
> INSERT INTO Conta (NomeConta,IsAtiva) VALUES ('gugu', 1);
statement. It can be complex and multiline, but it's still a single
statement.
For multiple statements in a row, and for procedure and trigger
definitions, you need a TIB_Script.
BTW, are you sure that "DECLARE varCount integer;" works? As far as I
know it must be "DECLARE VARIABLE".
Do you have the Firebird Quickstart Guide and the InterBase 6.0
documentation set, especially the Data Definition Guide? I think you
should study those. You can get them at
http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_download_documentation
Greetings,
Paul Vinkenoog