Subject Re: [IBO] IBOQuery and Refresh
Author Petr Hartman
--- In IBObjects@yahoogroups.com, Helen Borrie <helebor@...> wrote:
> So, start with the syntax. For future-proofing use either all
> relation aliases or all table names for identifiers, since Fb 2 and
> above won't allow them to be intermixed.
>
> e.g., in this statement you need to qualify all of the fields:
> select
> TAB1.ID,
> TAB1.ZKR,
> TAB1.DATUM,
> (select TAB2.NAZ from TAB2
> where TAB2.ID = TAB1.ID and TAB2.TYP = :typ)
> as NAZ
> from TAB1
> WHERE TAB1.ID= :id

I tried it, but the behaviour was the same. I'd like to emphasize,
that the SQL statement is probably ok, IBOQuery is opened, but the
following Refresh causes the error.

> Now, double-check your metadata in TAB2, to make sure that TYP is
> actually an integer.

TYP is really an INTEGER

> >/*---
> >EXECUTE STATEMENT
> >TR_HANDLE = 3830508
> >STMT_HANDLE = 3830660
> >PARAMS = [ Version 1 SQLd 2 SQLn 2
> > [TYP] = 2
> > [DATUM] = '12 IX 2007' ] <---- W H A T I S T H I S ? At
> > best, it is a string (not a date, not a date literal).

IB_Monitor uses FormatDateTime( 'dd mmm yyyy', ...) function for it.

> Sorry, that's quite correct. Would you please test it with the
same
> triple-quoted value in the right side of the assignment, but use
> AsString instead?

It doesn't work (''1.1.2007'' is not a valid date and time). It's
Delphi's error message.

>
> >I tried also
> > IBOQuery1.ParamByName('DATUM').AsDateTime := Date;
> >without success.
>
> Try it with the full function syntax, Date(). And please describe
> what "without success" means.

I tried it with Date(). The behaviour was the same. "Without success"
means that the behaviour was the same and the error after Refresh
also causes.

I noticed that in procedure GetSeekCursor (unit IB_Components,
function TIB_BDataset.SysLookupKeyForBufferFields) there is this
piece of code:

for ii := 0 to Params.PSQLDA.SQLn - 1 - tmpPrms - incAdj - SPrmCnt do
PSeekDA.SQLVAR[ii + tmpPrms + KeyFields.PSQLDA.SQLn] :=
Params.PSQLDA.SQLVAR[ii + tmpPrms];

If I set OldParameterOrdering = 1, Params[0].FieldName = 'DATUM',
Params[1].FieldName = 'TYP' and everything is ok.
If I set OldParameterOrdering = 0, the order of these parameters is
inverse (Params[0].FieldName = 'TYP', Params[1].FieldName = 'DATUM')
and Refresh causes the error.

Thanks
Petr