Subject | Re: [IBO] Ambiguos field name between table... |
---|---|
Author | Helen Borrie |
Post date | 2006-07-22T00:08:15Z |
At 07:39 AM 22/07/2006, you wrote:
First, there are more ambiguities in your query, beyond the one that
IBO has discovered.
a) the field UMG_NOMBRE has no qualifier
b) the third table has no alias
c) the join criterion for the third table has no alias
Next, lose the SELECT UME.* and select the output fields specifically by name.
If you want to use this as a dataset, consider replacing those outer
joins with correlated subqueries, viz.
SELECT
UME.IME_ID
, UME.UME_REFERENCIA
, UME.UME_GRUPO
, UME.UME_NOMBRE
, UME.blah
, UME.DOTDOTDOTDOTDOT....
, (SELECT UME2.UME_NOMBRE FROM LAB_UNIDADESMEDIDAS UME2
WHERE UME2.UME_ID = UME.UME_REFERENCIA) AS UME2_NOMBRE
, (SELECT UMG.UMG_NOMBRE FROM LAB_UNIDADESMEDIDASGRUPO UMG
WHERE UMG.UMG_ID = UME.UME_GRUPO) AS UMG_UMG_NOMBRE
FROM LAB_UNIDADESMEDIDAS UME
However, this is an opportunity where you could take benefit from
creating a view, especially if you are going to filter the set with
parameters. The syntax for views will force you to lose your "select
*" approach, which isn't a bad thing either. Essentially, what a
view is doing on the server side is what you are trying
(unsuccessfully) to make IBO do at the client. As a result, the
server takes care of managing the contributing cursor sets and IBO
only has to be aware of the Keylink.
Here's the view definition:
create view simplicity_encapsulated (
IME_ID
, UME_REFERENCIA
, UME_GRUPO
, UME_NOMBRE
, blah
, DOTDOTDOTDOTDOT....
, UME2_NOMBRE
, UMG_UMG_NOMBRE)
as
SELECT
UME.IME_ID
, UME.UME_REFERENCIA
, UME.UME_GRUPO
, UME.UME_NOMBRE
, UME.blah
, UME.DOTDOTDOTDOTDOT....
, (SELECT UME2.UME_NOMBRE FROM LAB_UNIDADESMEDIDAS UME2
WHERE UME2.UME_ID = UME.UME_REFERENCIA)
, (SELECT UMG.UMG_NOMBRE FROM LAB_UNIDADESMEDIDASGRUPO UMG
WHERE UMG.UMG_ID = UME.UME_GRUPO)
FROM LAB_UNIDADESMEDIDAS UME
Helen
>We are using a TIBOQuery for the update of the table LAB_It looks to me as though you need a different approach here.
>UNIDADESMEDIDAS using this Query:
>
>
>SELECT UME.*
> , UME2.UME_NOMBRE
> , UMG_NOMBRE
>FROM LAB_UNIDADESMEDIDAS UME
>LEFT JOIN LAB_UNIDADESMEDIDAS UME2 ON (UME2.UME_ID = UME.UME_
>REFERENCIA)
>LEFT JOIN LAB_UNIDADESMEDIDASGRUPO ON (UME.UME_GRUPO = UMG_ID)
>
>with Keylinks = UME_ID
>
>But when opening we get this error:
>
>"Ambiguos field name between table LAB_UNIDADESMEDICAS
> and table LAB_UNIDADESMEDICAS UME_ID"
>
>The problem is that we are using two references to the same table LAB_
>UNIDADESMEDIDAS but with different aliases for each one... UME and UME
>2
>
>alredy try using UME.UME_ID in the KeyLinks, and naming the UpdateSQL
>Table with the Alias but the porblem persists...
>
>How must we configure the IBOQuery to avoid this error????
First, there are more ambiguities in your query, beyond the one that
IBO has discovered.
a) the field UMG_NOMBRE has no qualifier
b) the third table has no alias
c) the join criterion for the third table has no alias
Next, lose the SELECT UME.* and select the output fields specifically by name.
If you want to use this as a dataset, consider replacing those outer
joins with correlated subqueries, viz.
SELECT
UME.IME_ID
, UME.UME_REFERENCIA
, UME.UME_GRUPO
, UME.UME_NOMBRE
, UME.blah
, UME.DOTDOTDOTDOTDOT....
, (SELECT UME2.UME_NOMBRE FROM LAB_UNIDADESMEDIDAS UME2
WHERE UME2.UME_ID = UME.UME_REFERENCIA) AS UME2_NOMBRE
, (SELECT UMG.UMG_NOMBRE FROM LAB_UNIDADESMEDIDASGRUPO UMG
WHERE UMG.UMG_ID = UME.UME_GRUPO) AS UMG_UMG_NOMBRE
FROM LAB_UNIDADESMEDIDAS UME
However, this is an opportunity where you could take benefit from
creating a view, especially if you are going to filter the set with
parameters. The syntax for views will force you to lose your "select
*" approach, which isn't a bad thing either. Essentially, what a
view is doing on the server side is what you are trying
(unsuccessfully) to make IBO do at the client. As a result, the
server takes care of managing the contributing cursor sets and IBO
only has to be aware of the Keylink.
Here's the view definition:
create view simplicity_encapsulated (
IME_ID
, UME_REFERENCIA
, UME_GRUPO
, UME_NOMBRE
, blah
, DOTDOTDOTDOTDOT....
, UME2_NOMBRE
, UMG_UMG_NOMBRE)
as
SELECT
UME.IME_ID
, UME.UME_REFERENCIA
, UME.UME_GRUPO
, UME.UME_NOMBRE
, UME.blah
, UME.DOTDOTDOTDOTDOT....
, (SELECT UME2.UME_NOMBRE FROM LAB_UNIDADESMEDIDAS UME2
WHERE UME2.UME_ID = UME.UME_REFERENCIA)
, (SELECT UMG.UMG_NOMBRE FROM LAB_UNIDADESMEDIDASGRUPO UMG
WHERE UMG.UMG_ID = UME.UME_GRUPO)
FROM LAB_UNIDADESMEDIDAS UME
Helen