Subject TIB_LocateCursor problem
Author Andreas Hesse
I have a problem with TIB_Query.Locate().

The base SQL Text is a JOIN statement, like:

select a.*
from a
join b on a.id_b = b.id_b

with MasterSource to table "c" and MasterLinks set to: b.id_c = c.id_c

But if I want to locate "a.id_b", the resulting SQL looks like:

SELECT a.id_a
join b on a.id_b = b.id_b
WHERE b.id_c=? /* BIND_0 */
AND b.id_c=? /* MLNK_id_c_0 */
AND (((id_b = ? /* LOC_2 */ )))

That leads to an error:

ISC Fehlermeldung:
Dynamic SQL Error
SQL error code = -204
Ambiguous field name between table a and table b

I found 2 problems:

1) the double b.id_c=? ... comes from using a hardcoded ? as ParamChar
(ParamChar was :)

2) the search-condition should be "a.id_b = ? ..." and not "id_b = ?",
but the relation name is not used because in
"procedure TIB_LocateCursor.SysPrepareSQL;"

I found this line:
if BDataset.SysFieldNames.Count = BDataset.FieldCount then
"use only FieldName" else "useFullFieldName"

==> solution
it should be checked if the SQL is a join (JoinLinks not empty or
contains the key word 'JOIN').
Than the locate cursor should allways use the fullFieldName.

Andreas Hesse