Subject Re: [IBO] Parser messes up SQL containing FIRST
Author Helen Borrie
At 10:40 PM 13/10/2003 +0000, you wrote:
>Hi,
>
>I'm using IBO 4.2Ie with Firebird 1.5 RC6 and D7 and I'm having
>trouble executing this simple SQL:
>
>SELECT FIRST 1 * FROM Table WHERE (ID = 1)
>
>The preparation process of IBOQuery seems to damage the SQL so that
>this gets sent to the server:
>
>SELECT FIRST 1 *
> , Table.RDB$DB_KEY
>FROM Table WHERE (ID = 1)
>
>Needles to say, this statement fails miserably. Any help is
>appreciated...

Aleksander,

It shouldn't fail. It will fail to return any rows if there is no row with
ID = 1. What is the "failure" you are encountering?

To get rid of the DB_KEY, simply set the KeyLinks to the primary key
column(s) of the table. It will have to be more than just ID, apparently,
otherwise you wouldn't use SELECT FIRST.

Is there any reason to use brackets on your simple WHERE clause? It's not
"invalid" in SQL terms but it will cost you unnecessary processing cycles
on the client side. The normal use of brackets is to get correct logic with
complex search conditions, so using it unnecessarily causes the parser to
set itself up to manage nested logic.

Helen