Pergunta

I have a one line query:

DECLARE VARIABLE var_SecondsOfTime INTEGER;

But after running the query I am getting this message:

Engine Error (code = 335544569): Dynamic SQL Error. SQL error code = -104. Token unknown - line 1, column 9. VARIABLE.

SQL Error (code = -104): Invalid token.

I've looked everywhere on the Internet and all examples showing the same declaration style which I am using.

What is wrong?

Foi útil?

Solução

Firebird 2.5 supports execution of code blocks surrounded by a 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 issued the select because I'm pretty sure it is not possible to execute an empty block, try this by yourself removing the select.

isql running the block

Edit My original select was invalid for a block, I added the into clause to collect the result. I never used firebird maestro, but it now works perfectly on isql, as shown.

Outras dicas

Try this:

set term ^ ;

EXECUTE BLOCK 
AS
   DECLARE VARIABLE var_SecondsOfTime INTEGER;

BEGIN
  SELECT  1 from RDB$DATABASE  into :var_SecondsOfTime ;
END^

set term  ;^

The second set term needs the semi colon before the carat.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top