Subject | Re: [firebird-support] Why is END invalid |
---|---|
Author | Helen Borrie |
Post date | 2011-07-21T12:08:23Z |
At 11:49 PM 21/07/2011, you wrote:
e.g.
.. THEN
SELECT 'Whats Up' FROM RDB$DATABASE;
END
./hb
>Could somebody tell me why the following error is received when I try to compile this SQL statement. Using firebird 64 bit v 2.5 ?In both cases, SELECT 'Whats Up' is invalid SQL so, at the point where the error occurs, the parser is looking for FROM and the rest of the SELECT statement. However, as Marcin points out, you will need to close the THEN action with a semicolon, before using END to close the block.
>
>SET TERM ^ ;
>
>CREATE PROCEDURE TestProc
>AS
>BEGIN
> IF ( EXISTS(SELECT * FROM OBJECTTYPE)) THEN
> SELECT 'Test message.'
>
>END^
>
>SET TERM ; ^
>
>Error: *** IBPP::SQLException ***
>Context: Statement::Prepare(
>
>CREATE PROCEDURE TestProc
>AS
>BEGIN
> IF ( EXISTS(SELECT * FROM OBJECTTYPE)) THEN
> SELECT 'Whats Up'
>
>END
> )
>Message: isc_dsql_prepare failed
>
>SQL Message : -104
>Invalid token
>
>Engine Code : 335544569
>Engine Message :
>Dynamic SQL Error
>SQL error code = -104
>Token unknown - line 9, column 1
>END
e.g.
.. THEN
SELECT 'Whats Up' FROM RDB$DATABASE;
END
./hb