Board index » delphi » Help needed with SQL Query on a local table

Help needed with SQL Query on a local table

Is there a way to use an IF statement with Delphi's implementation of
SQL?

I'm trying to do some checking on records as I query them. I know of
other SQL implementations that support IIF statements but I can't seem
to get this to work with Delphi.

If it doesn't support IF statements, can you think of another way to
do conditionals on a query without running 2+ queries?

Any help is appreciated!!!!!!

Bill
arte...@worldnet.att.net

 

Re:Help needed with SQL Query on a local table


Hi Bill,

Quote
>Is there a way to use an IF statement with Delphi's implementation of
>SQL?

>I'm trying to do some checking on records as I query them. I know of
>other SQL implementations that support IIF statements but I can't seem
>to get this to work with Delphi.

>If it doesn't support IF statements, can you think of another way to
>do conditionals on a query without running 2+ queries?

In SQL the if statement is only allowed in stored procedures and triggers.
Both are not supported by Local SQL because you are already working
on a local database.
So write with nativ Delphi code what you want to do. Depending on what
you want to do, you must (conditionally) start several queries.

Dirk Seifert

Seif...@Geutebrueck.de

Re:Help needed with SQL Query on a local table


Yo Bill:

Have you tried:

SELECT ( IF ColA = ColB, 'Y', 'N' ) AS SOMECOL, etc...?

Rob

Re:Help needed with SQL Query on a local table


Helle Robert,

Quote
>SELECT ( IF ColA = ColB, 'Y', 'N' ) AS SOMECOL, etc...?

This is a nice construction, but on what server or local database can you
use it ?

My Interbase server tells me: "-Token unknown - line 1, char 9  -IF".
And and on a DBase Table (with local SQL) the error message is nearly the
same.

What server are you working with?

Dirk Seifert

Seif...@Geutebrueck.de

Re:Help needed with SQL Query on a local table


Dirk:

Sorry mon, me syntax was wrong..

Quote
> >SELECT ( IF ColA = ColB, 'Y', 'N' ) AS SOMECOL, etc...?

Its really:

SELECT ( IF ColA = ColB THEN 'Y' ELSE 'N' ENDIF ) AS SOMECOL

Quote

> What server are you working with?

The Mighty Sybase SQL Anywhere 5.5.03 BDE > ODBC action..
They support embedded CASE statements as well, its disgusting!

Rob..

Other Threads