Subject Re: [IBO] TIB_Query Problem
Author Helen Borrie
Peter,

At 04:40 PM 30/08/2004 +0000, Peter Chaisty wrote:
>Hi
>
>I am having some very strange problems with a TIB_Query.
>
>I have some very simple sql in the query
>
>SELECT ID
> , TITLE
> , DATABASE_VERSION
> , SW_VERS
>FROM VERSION_INFO
>
>If I use the inbuilt data fetch in the IB_Query component I can see
>the results without any problems, sw_vers is there.
>
>When I access it from code I cannot access the sw_vers field at all.
>
>
>IB_DB_Version.Open;
>IB_DB_Version.Refresh;
>IB_DB_Version.Last;
>Version := IB_DB_Version.FieldByname('ID').asInteger;
>Prog_Version := IB_DB_Version.FieldByname('SW_VERS').asString;
>Writelog('Database Version - ' + IntToStr(Version),0);
>
>If I hookup an sql monitor component I get
>
>17:25:02 /*---
>PREPARE STATEMENT
>TR_HANDLE = 23279720
>STMT_HANDLE = 23279912
>
>SELECT TITLE
> , DATABASE_VERSION
> , ID
>FROM VERSION_INFO
>
>PLAN (VERSION_INFO NATURAL)
>
>FIELDS = [ Version 1 SQLd 3 SQLn 30
> SYSDBA.VERSION_INFO.TITLE = <NIL>
> SYSDBA.VERSION_INFO.DATABASE_VERSION = <NIL>
> SYSDBA.VERSION_INFO.ID = <NIL> ]
>
>
>which implies that the sw_vers fetch is not in the final sql that goes
>to Firebird.
>
>If however I create a new project and try the above code it works fine.
>I have tried deleting the TIB_Query and then put a new one back on the
>form that gives problems and each time it has the same problem.
>
>Any ideas anybody ?

My first assessment of your problem is that you have some code somewhere
that is overriding the original SQL property of the query. At the start,
you give this as your SQL:

SELECT ID
, TITLE
, DATABASE_VERSION
, SW_VERS
FROM VERSION_INFO

But, from the monitor, you report this:
SELECT TITLE
, DATABASE_VERSION
, ID
FROM VERSION_INFO

So, not only is SW_VERS missing, but it's a different statement.

Helen