Subject Re: [IBO] How should I set masterlinks property, using Select ... union ...Select
Author Helen Borrie
At 07:41 AM 14/09/2007, you wrote:
>Hello,
>
>I have the following SQL in a TIB_Query:
>
>select Cast(wProduto_id as integer) Produto_id,
> Cast(wVendedor_id as integer) Vendedor_id,
> Cast(wVendedor as varchar(60)) Vendedor,
> Cast(wSaldo as Integer) Estoque
>from sp_localizacao_estoque
>
>union all
>
>Select Cast(registro_id as Integer),
> Cast( 0 as Integer),
> Cast('DEPÓSITO' as VarChar(60)),
> Cast(estoque as Integer)
> from produtos
>
>This is working fine, tested in IBExpert.
>
>
>This is a detail query, and I need to link this through masterlinks in
>my master query:
>
>SELECT P.REGISTRO_ID
> , P.PRODUTO
> , P.ESTOQUE
>FROM PRODUTOS P
>
>
>I never used masterlinks when using UNION in one of the queries. I
>tried a couple of statements, and none of them works.


>Can anyone help me?

Create a view from the UNION set (e.g.
aView). Use the full view syntax and convert
your aliased fieldnames in the first selection
into fieldnames for the view. For the detail dataset, make the SQL as

select * from aView

..then set your master query as its Mastersource. Masterlinks will be

aView.Produto_id=Produtos.Registro_id


>registro_id is the PK of produtos and wProduto_ID is FK of
>sp_localizacao_estoque

Those relationships are irrelevant, since the
detail set is made completely of manufactured data.

Helen