Subject Problem with KeyLinks
Author Mihai Chezan
I have the following table:
CREATE TABLE person (
id INTEGER NOT NULL,
name VARCHAR(50) NOT NULL,
id_boss INTEGER NOT NULL,
CONSTRAINT pk_person PRIMARY KEY (id)
);
ALTER TABLE person ADD CONSTRAINT fk_person FOREIGN KEY (id_boss)
REFERENCES person(id);

IB_Query.SQL =
SELECT
p1.*,
p2.name Boss
FROM
person p1
inner join person p2
on p1.id_boss = p2.id

IB_Query.FetchWholeRows = false
IB_Query.KeyLinks = person.id
IB_Query.KeyRelation = person

when I open the query I get this error:


Multiple rows in singleton fetch

Check KeyLinks and JoinLinks properties

SELECT
p1.*,
p2.name Boss
FROM
person p1
inner join person p2
on p1.id_boss = p2.id
WHERE person.id=? /* BIND_0 */


I understand why IB_Query and Firebird gets confused:
"WHERE person.id=?"
How to solve this? I've tried assigning to KeyLinks = p1.id but I get
another error: "Invalid KeyLinks entry: p1.id."
So ibo doesn't like me to use aliases in KeyLinks or KeyRelation.
What should I do?

if you need a test-case I've uploaded one:
http://groups.yahoo.com/group/IBObjects/files/Problem-KeyLinks-Alias.
zip