Firebird SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesFirebird SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 13th, 2011, 07:09 AM
Unspoken Unspoken is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2011
Posts: 6 Unspoken User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 17 m 14 sec
Reputation Power: 0
Unhappy Help me with basic select statements please.

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 collumn 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 collumn 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???


Thanks for your help.

Reply With Quote
  #2  
Old April 13th, 2011, 11:58 PM
costin_mentor costin_mentor is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 31 costin_mentor User rank is Lance Corporal (50 - 100 Reputation Level)costin_mentor User rank is Lance Corporal (50 - 100 Reputation Level)costin_mentor User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 13 h 12 m 34 sec
Reputation Power: 7
For first and third example:
select statement should always have the clause "from"

SELECT 1 from RDB$DATABASE into :var_SecondsOfTime ;

For second example try this:

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

and will work.

Reply With Quote
  #3  
Old April 14th, 2011, 03:45 AM
Unspoken Unspoken is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2011
Posts: 6 Unspoken User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 17 m 14 sec
Reputation Power: 0
Quote:
Originally Posted by costin_mentor
For first and third example:
select statement should always have the clause "from"

SELECT 1 from RDB$DATABASE into :var_SecondsOfTime ;

For second example try this:

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

and will work.


Thank you, all is working fine now.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > Help me with basic select statements please.

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap