Unable to declare a variable in Firebird 2.5, why?

I have a single line query:

DECLARE VARIABLE var_SecondsOfTime INTEGER; 

But after running the request, I get this message:

Engine error (code = 335544569): Dynamic SQL error. SQL error code = -104. Current unknown - row 1, column 9. VARIABLE.

SQL error (code = -104): invalid token.

I looked everywhere on the Internet and all the examples demonstrating the same ad style that I use.

What's wrong?

+5
source share
2 answers

Firebird 2.5 supports the execution of code blocks surrounded by the execute block statement , try this:

 set term ^ ; EXECUTE BLOCK AS DECLARE VARIABLE var_SecondsOfTime INTEGER; BEGIN SELECT 1 from RDB$DATABASE into var_SecondsOfTime ; END ^ set term ; ^ 

I returned select, because I am sure that it is impossible to execute an empty block, try to do it yourself by deleting select.

isql running the block

Edit My original choice was invalid for the block, I added a sentence in to collect the result. I have never used Firebird Maestro, but now it works fine on isql, as shown.

+3
source

Try the following:

 set term ^ ; EXECUTE BLOCK AS DECLARE VARIABLE var_SecondsOfTime INTEGER; BEGIN SELECT 1 from RDB$DATABASE into :var_SecondsOfTime ; END^ set term ;^ 

The second setpoint requires up to a colon to carats.

+4
source

Source: https://habr.com/ru/post/1338169/


All Articles