Subject Re: [firebird-support] Could you help me with basic SELECT queries, please?
Author Alan J Davies
Example 1
try
select somedata
from sometable
you need to specify the source

Example 2
comma is unknown token after "*" - the "*" specifies everything in the
source, be it a table, view or joined tables or stored procedure, so how
can you have more? When "," is then encountered, an error is generated
(correctly)

Example 3
Combination of above errors - and more.
A good starting point is the wealth of documentation on the
Ibphoenix.com site - explains the syntax very well. And also how it
differs from the relaxed version employed in sql server. I use both and
also get frustrated, but do prefer a hard and fast way of doing things
like in the later (st) version of Firebird. Leaving nothin to chance
when selecting data means you get the right result every time and also
improves my way of doing stuff.
Good luck
Alan

Alan J Davies
Aldis

On 13/04/2011 16:50, truewodzu wrote:
> 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.
>
>
> ------------------------------------------------------------------------
>
> No virus found in this message.
> Checked by AVG - www.avg.com <http://www.avg.com>
> Version: 10.0.1209 / Virus Database: 1500/3568 - Release Date: 04/12/11
>