Hi James,

your query has to look like

select <something> from <relation>

Your example queries look like

select <something>

Taking your first example, you may write

SELECT
  case RDB$RELATION_NAME
    when 'SCHEMA_VERSION' then 1
    else 0
  end
FROM RDB$RELATIONS

to achieve the second.

I'd write

SELECT
  ii(RDB$RELATION_NAME = 'SCHEMA_VERSION', 1, 0)
FROM RDB$RELATIONS

but this is identical in respect of performance.



Am 04.04.2014 15:30, schrieb James Schumacher:
>  
> 
> Hello,
> 
> I am new to Firebird, I have experience using MS SQL. I am trying to
> convert some code that performs various checks but having problems with
> the syntax. One thing I need to convert is SQL to detect whether a
> table exists.
> 
> I have tried these in Squirrel and isql connected to an embedded db
> version Firebird 2.5
> 
> I tried the following
> 
> SELECT RDB$RELATION_NAME FROM RDB$RELATIONS
> WHERE RDB$RELATION_NAME = 'SCHEMA_VERSION'
> 
> works fine. I went on to:
> 
> select case when exists(SELECT RDB$RELATION_NAME FROM RDB$RELATIONS
> WHERE RDB$RELATION_NAME = 'SCHEMA_VERSION') then 1 else 0 end;
> 
> Error: GDS Exception. 335544569. Dynamic SQL Error
> SQL error code = -104
> Unexpected end of command - line 2, column 62
> SQLState: 42000
> ErrorCode: 335544569
> 
> I thought maybe firebird wants named result so I tried
> 
> select (case when exists(SELECT RDB$RELATION_NAME FROM RDB$RELATIONS
> WHERE RDB$RELATION_NAME = 'SCHEMA_VERSION') then 1 else 0 end) as
> result;
> 
> Error: GDS Exception. 335544569. Dynamic SQL Error
> SQL error code = -104
> Unexpected end of command - line 2, column 70
> SQLState: 42000
> ErrorCode: 335544569
> 
> I am now down to some very basic queries that work in MS SQL but not in
> firebird:
> 
> SELECT CASE
> WHEN 4 = 5 THEN 1
> WHEN 5 = 6 THEN 2
> ELSE 0
> END;
> 
> Error: GDS Exception. 335544569. Dynamic SQL Error
> SQL error code = -104
> Unexpected end of command - line 5, column 2
> SQLState: 42000
> ErrorCode: 335544569
> 
> or
> 
> SELECT (CASE
> WHEN 4 = 5 THEN 1
> WHEN 5 = 6 THEN 2
> ELSE 0
> END) as result;
> 
> Error: GDS Exception. 335544569. Dynamic SQL Error
> SQL error code = -104
> Unexpected end of command - line 5, column 10
> SQLState: 42000
> ErrorCode: 335544569
> 
> I have looked at the following documentation but I don't see what I am
> doing wrong
> 
> http://www.firebirdsql.org/file/documentation/reference_manuals/reference_material/html/langrefupd25.html
> 
> 
> thank you for any help you can give,
> 
> Jim s
> 
> 

-- 
Mit freundlichen Grüßen,

Thomas Beckmann
Diplom-Informatiker


Wielandstraße 14c • 23558 Lübeck
Tel +49 (22 25) 91 34 - 545 • Fax +49 (22 25) 91 34 - 604
Mail [email protected] <mailto:[email protected]>

ASSFINET-Logo

*ASSFINET Dienstleistungs-GmbH*
Max-Planck-Straße 14 • 53501 Grafschaft bei Bonn
[email protected] <mailto:[email protected]> • www.assfinet.de
<http://www.assfinet.de/>

Geschäftsführer: Dipl. Wirtschaftsinformatiker Marc Rindermann
Registergericht Koblenz HRB 23331

Diese E-Mail enthält vertrauliche Informationen. Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben,
informieren Sie bitte sofort den Absender und vernichten Sie diese Mail.
Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist
nicht gestattet.



------------------------------------

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Visit http://www.firebirdsql.org and click the Resources item
on the main (top) menu.  Try Knowledgebase and FAQ links !

Also search the knowledgebases at http://www.ibphoenix.com 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Yahoo Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/firebird-support/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo Groups is subject to:
    https://info.yahoo.com/legal/us/yahoo/utos/terms/

Reply via email to