Subject | Re: [IBO] How to access field when there are dupe field names |
---|---|
Author | Helen Borrie |
Post date | 2005-06-20T13:49:15Z |
At 01:27 PM 20/06/2005 +0000, you wrote:
redundancies. The point I was making was that a joined set is not
naturally updatable. Therefore, you are up the creek if you refuse to use
aliases to resolve redundancies and simplify what you do with IBO.
Taking your original SQL:
SELECT aaa.num, aaa.name, ppp.num, ppp.mod_date
FROM aaa
JOIN ppp ON ppp.aaa_id=aaa.id // ppp is a SP
Replace this with
SELECT aaa.num,
aaa.name,
ppp.num AS pp_num,
ppp.mod_date
FROM aaa JOIN ppp
ON ppp.aaa_id=aaa.id // ppp is a SP
That's all that is needed for your InsertSQL to work:
INSERT INTO aaa VALUES (:id, :num, :name)
However, if you insist on avoiding the aliasing, then you need to separate
the InsertSQL into its own stand-alone DSQL. Then the names of the
parameters don't matter, as long as they are all different.
An even easier way to do this would be to use KeyRelation to make the
natural table "updatable". However, since you don't have the primary key
of the natural table in your dataset, this won't be possible.
Helen
>The problem is that there is no way to access the correct field in aExactly. That's why SQL provides aliasing - to resolve such
>dataset, when the query returns two (or more) columns with the same name.
redundancies. The point I was making was that a joined set is not
naturally updatable. Therefore, you are up the creek if you refuse to use
aliases to resolve redundancies and simplify what you do with IBO.
Taking your original SQL:
SELECT aaa.num, aaa.name, ppp.num, ppp.mod_date
FROM aaa
JOIN ppp ON ppp.aaa_id=aaa.id // ppp is a SP
Replace this with
SELECT aaa.num,
aaa.name,
ppp.num AS pp_num,
ppp.mod_date
FROM aaa JOIN ppp
ON ppp.aaa_id=aaa.id // ppp is a SP
That's all that is needed for your InsertSQL to work:
INSERT INTO aaa VALUES (:id, :num, :name)
However, if you insist on avoiding the aliasing, then you need to separate
the InsertSQL into its own stand-alone DSQL. Then the names of the
parameters don't matter, as long as they are all different.
An even easier way to do this would be to use KeyRelation to make the
natural table "updatable". However, since you don't have the primary key
of the natural table in your dataset, this won't be possible.
Helen