Subject Re: [IBO] TIBOTable and field names that require quoting.
Author mspencewasunavailable
--- In, Helen Borrie <helebor@...> wrote:
> At 12:33 PM 27/09/2006, Geoff wrote:
> >In my native (TIB_*) component applications I have quite a lot
> >of quoted table and field names and I have not come across the
> >problem since Jason made a fix for me in 4.6A.
> >
> >Here is an example of one from my apps (IBO v4.6.Aa), as
> >captured from the SQL Monitor (direct copy-n-paste):
> >
> >SELECT * FROM "JT-Contact History"
> >WHERE "JT-Contact History"."Contact OID"=? /* "MLNK_Contact
OID_0" */
> >ORDER BY "Timestamp" DESC
> >
> >You can see that IBO successfully managed the quoted table and
> >field names in this instance.
> >
> >Notice that the comment marker includes "MLNK_" - indicating it
> >is an automatically generated master link parameter. You have
> >not included the same in your reported problem... that makes me
> >wonder what you have set up for your detail dataset. Are you
> >using MasterLinks or MasterParamLinks etc.
> Geoff, mspencewasunavailable isn't using native IBO. The TDataset
> components do master-detail linking quite differently to the way
> does it. "Automatically-generated masterlink parameters" for
> (such as they are) use the inherited TDataset methods, which work
> with internally generated TField objects and are subject to some
> givens that are absent from his situation. Essentially he has no
> choice but to use the explicitly parameterised query method
> here. You might like to review what I wasted my time on for
> an hour last night on this thread.
> Helen

Sorry, my bad. Helen was right:

> 1. For masterlinking a query to work automatically in the
> architecture, the fieldnames of the primary key in the master set
> must have exactly the same names as the linking foreign key fields
> the detail; otherwise you must write the WHERE clause for the
> set yourself and supply your own valid parameter names.

The actual problem is that the BDE was happy with this:

tblSchedQty.MasterFields := 'Acc ID;Serv ID';

because Paradox allowed fields to have such names. Since the code
had been working for around 10 years like this, then I mistakenly
blamed the new guy (IBObjects).

However, TIBOTable works fine if you just quote the field names:

tblSchedQty.MasterFields := '"Acc ID";"Serv ID"';

which is an inconsistency between the way TTable and TIBOTable
operate but not, I suspect, one that occurs often enough to warrant
any attention. The trouble is that more often than not these
settings are in the .dfm so they'll be hard to track down.

There are a lot of situations like this where quoting is now
required, as well as situations where the TIBO* code tries to
accomodate things. For example, field names with spaces and/or
lower case in a Locate() list now have to be properly quoted, but
such a field name in a TField need not be.

> 2. The other half of the problem is that parameter names are
> actually Delphi identifiers. For that reason, you cannot have
> or spaces in the identifiers.

This is news to me. Did you mean SQL identifiers?

Anyway, sorry for noise.

Michael D. Spence
Mockingbird Data Systems, Inc.