Subject Re: [IBO] View with table editable
Author Helen Borrie
At 00:58 16/09/2008, you wrote:
>Hy
>I am testing its component to create a commercial application,
>however I am having difficulties in implementing a routine that uses
>chacheupdade to a query based on a view.
>I did tests with the previous version 4.2 and could table editeable
>simulate the with view that has several joins. In version 4.8 which
>download to update the compiler Delphi (7 for 2007), does not accept.
>Informed that the query is read only. Something has changed in
>version? Please, you can help me? It is important to remember that
>was already running.

Views are not updatable, since they are not tables. However, the database engine can enable you to make *some* views appear as though they are updatable, provided there is a way to direct a DML operation to a single, specific record in an underlying table. Some single-table views without aggregations are "naturally updatable". Some other cases, where there are no aggregations, can be made "updatable" by defining triggers on the view.

There is no way that the database engine can present your view as "updatable". The SELECT DISTINCT aggregation prevents it totally: there is no way by which any individual record in any underlying table could be traced through this view.

Whatever you did before, if you were using this view then you could not have updated anything through it. This problem does not lie with IBO but with the view definition itself.

Possibly you can recreate your view and find a way to write triggers for it that would present it to the client as "updatable". It cannot happen with SELECT DISTINCT in the definition but it may be possible otherwise, provided the keys involved can track precisely into a specific underlying record. You will need to study the documentation for the database engine version of your database to find out how to do this. Different DB engine versions have different rules.

If the engine presents an updatable view then, with RequestLive set true *and* 100% correct KeyLinks, IBO would treat it like a regular table.

Helen


>thats view:
>CREATE VIEW VI_VENDAS_PRODUTOS_TAB(
> PROD_CODIGOALTER,
> COD_BARRAS,
> PROD_DESCRICAO,
> COD_PRODUTO,
> PROD_UNIDADE,
> FAB_DESCRICAO,
> MAR_DESCRICAO,
> PRECO_VENDA,
> QTDEPED,
> QTDECX,
> QTDEMIN,
> FLAG,
> COD_EMPRESA,
> COD_TABELA,
> DESCONTO,
> COD_MARCA,
> COD_LOTE,
> COD_TIPOPRODUTO,
> PROD_INATIVO,
> LIN_DESCRICAO,
> SEC_DESCRICAO,
> GR_DESCRICAO,
> SGR_DESCRICAO,
> CAT_DESCRICAO,
> SIM_DESCRICAO,
> PROD_CUSTOMEDIO,
> PROD_PRECOCUSTO,
> PROD_PRECOAQUISICAO,
> TODAS_EMPRESAS,
> TP_DESCRICAO)
>AS
>select distinct PROD_CODIGOALTER, D.COD_BARRAS, D.PROD_DESCRICAO,
>D.COD_PRODUTO, D.PROD_UNIDADE, D1.FAB_DESCRICAO,
> D2.MAR_DESCRICAO, D3.PRECO_VENDA, D.QTDE, D.PROD_QTDENACAIXA,
>D.PROD_ESTOQUEMIN, D.FLAG, D3.COD_EMPRESA,
> D3.COD_TABELA, D.PROD_DESCONTO, D2.COD_MARCA, COD_LOTE,
>D.COD_TIPOPRODUTO, D.PROD_INATIVO, D4.LIN_DESCRICAO,
> D5.SEC_DESCRICAO, D6.GR_DESCRICAO, D7.SGR_DESCRICAO,
>D8.CAT_DESCRICAO, D9.SIM_DESCRICAO, D.PROD_CUSTOMEDIO,
> D.PROD_PRECOCUSTO, D.PROD_PRECOAQUISICAO, D10.TODAS_EMPRESAS,
>D11.TP_DESCRICAO
>from PRODUTOS D
> inner join FABRICANTE D1 on (D.COD_FABRICANTE = D1.COD_FABRICANTE)
> inner join MARCA D2 on (D.COD_MARCA = D2.COD_MARCA)
> inner join TABELA_PRECO_PRODUTOS D3 on (D.COD_PRODUTO =
>D3.COD_PRODUTO)
> inner join LINHA D4 on (D.COD_LINHA = D4.COD_LINHA)
> inner join SECAO D5 on (D.COD_SECAO = D5.COD_SECAO)
> inner join GRUPO D6 on (D.COD_GRUPO = D6.COD_GRUPO)
> inner join SUBGRUPO D7 on (D.COD_SUBGRUPO = D7.COD_SUBGRUPO)
> inner join CATEGORIA D8 on (D.COD_CATEGORIA = D8.COD_CATEGORIA)
> inner join SIMILAR D9 on (D.COD_SIMILAR = D9.COD_SIMILAR)
> inner join TABELA_PRECO D10 on (D3.COD_TABELA = D10.COD_TABELA)
> inner join PRODUTOS_TIPO D11 on (D.COD_TIPOPRODUTO =
>D11.COD_TIPOPRODUTO);