GARANTIR DESCONTO

Fórum Erro ao criar um view (Invalid command ... SQL error code) #57837

08/02/2007

0

O que esta errado nesta view
CREATE VIEW VW_nivel1(
    graud,
    grauc,
    n_nivel,
    debito,
    credito,
    mes,
    ano)
AS
select tgrau1_d.graud, tgrau1_d.n_nivel,
       sum( tgrau1_d.valor ) as Debito,
       ( 0.0 ) as Credito,
       extract( month from tgrau1_d.datalcto) as mes,
       extract( month from tgrau1_d.datalcto) as ano
from tgrau1_d
inner join tgrau1_c on
       ( tgrau1_c.grauc = tgrau1_d.graud )
group by tgrau1_d.graud, tgrau1_d.n_nivel, tgrau1_d.datalcto

UNION ALL

select tgrau1_c.grauc, tgrau1_c.n_nivel,
       ( 0.0 ) as Debito,
       sum( tgrau1_c.valor ) as Credito,
       extract( month from tgrau1_c.datalcto) as mes,
       extract( month from tgrau1_c.datalcto) as ano
from tgrau1_c
inner join tgrau1_d on
       ( tgrau1_d.graud = tgrau1_c.grauc )
group by tgrau1_c.grauc, tgrau1_c.n_nivel, tgrau1_c.datalcto
;


Apareçe o sequinte erro:
[color=red:b3576749fb]This operation is not defined for system tables.
Dynamic SQL Error.
SQL error code = -607.
Invalid command.
number of columns does not match select list.[/color:b3576749fb]

Obrigado pela ajuda
Adriano.


Adriano_servitec

Adriano_servitec

Responder

Posts

08/02/2007

Adriano_servitec

Desculpe pelo post, nao tinha percebido que tinha um [b:fadbb5aa4d]fields[/b:fadbb5aa4d] a mais :oops: Pura falta de atenção minha.

O correto eh assim
CREATE VIEW VW_nivel1( graud, [color=red:fadbb5aa4d]--//grauc,[/color:fadbb5aa4d] [color=green:fadbb5aa4d]Sem este campo[/color:fadbb5aa4d] n_nivel, debito, credito, mes, ano) AS select tgrau1_d.graud, tgrau1_d.n_nivel, sum( tgrau1_d.valor ) as Debito, ( 0.0 ) as Credito, extract( month from tgrau1_d.datalcto) as mes, extract( month from tgrau1_d.datalcto) as ano from tgrau1_d inner join tgrau1_c on ( tgrau1_c.grauc = tgrau1_d.graud ) group by tgrau1_d.graud, tgrau1_d.n_nivel, tgrau1_d.datalcto UNION ALL select tgrau1_c.grauc, tgrau1_c.n_nivel, ( 0.0 ) as Debito, sum( tgrau1_c.valor ) as Credito, extract( month from tgrau1_c.datalcto) as mes, extract( month from tgrau1_c.datalcto) as ano from tgrau1_c inner join tgrau1_d on ( tgrau1_d.graud = tgrau1_c.grauc ) group by tgrau1_c.grauc, tgrau1_c.n_nivel, tgrau1_c.datalcto ;


Mais uma vez desculpe pelo post.


Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar