Subject Could you help me with basic SELECT queries, please?
Author truewodzu
Hi guys.

I just don't get why this SELECT statements doesn't work as they work on the MS SQL Server. I know, two different engines. But what am I doing wrong?

FIRST EXAMPLE:

SELECT 5

I would expect to get a result with one row and one column and the value 5, instead of I am getting this error in FlameRobin:

Preparing query: SELECT 5
Error: *** IBPP::SQLException ***
Context: Statement::Prepare( SELECT 5 )
Message: isc_dsql_prepare failed

SQL Message : -104
Invalid token

Engine Code : 335544569
Engine Message :
Dynamic SQL Error
SQL error code = -104
Unexpected end of command - line 1, column 8


SECOND EXAMPLE:

SELECT *, (1+1) AS test FROM CITIES

Again, I would expect to have in each row a column called "test" with the value of 2 in it. Instead:

Error: *** IBPP::SQLException ***
Context: Statement::Prepare( SELECT *, (1+1) AS test FROM CITIES )
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 1, column 9
,


I don't get it. The comma is an unknown token, why?


THIRD EXAMPLE:

set term ^ ;

EXECUTE BLOCK
AS
DECLARE VARIABLE var_SecondsOfTime INTEGER;

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

set term ^ ;

I would expect to get one row, one column with the value hold by the variable var_SecondsOfTime. But again, there is an error:

Preparing query:

EXECUTE BLOCK
AS
DECLARE VARIABLE var_SecondsOfTime INTEGER;

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

Error: *** IBPP::SQLException ***
Context: Statement::Prepare(

EXECUTE BLOCK
AS
DECLARE VARIABLE var_SecondsOfTime INTEGER;

BEGIN
SELECT 1 from RDB$DATABASE into :var_SecondsOfTime ;
SELECT var_SecondsOfTime ;
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 28
;

Semicolon an unknown token???


I am struggling with such basic things.. it is very frustrating...
Thanks for your help.