select tcibem.codbem,
tcibem.descrabrev,
tcibem.numnota,
nvl(ad_depacel.saldo, 0) as saldo,
tcibem.dtfimdep,
tcitax.taxa,
tcibem.vlrsaldo,
saldos.referencia,
nvl(saldos.vlr_depreciado, 0) as vlr_depreciado
from tcibem,
ad_depacel,
tgfpro,
tcitax,
(
select tcisal.codprod as codprod
, tcisal.codbem as codbem
, to_char(tcisal.referencia, 'mm/yyyy') as referencia
, tcisal.saldo as vlr_depreciado
from tcisal
) saldos
pivot xml
(sum(nvl(vlr_depreciado, 0)) as vlr_depreciado for (referencia) in
(
select to_char(referencia, 'mm/yyyy') as referencia from tcisal
)
)
where ad_depacel.codbem (+) = tcibem.codbem
and tgfpro.codprod = tcibem.codprod
and tcitax.codprod = tcibem.codprod
and tcibem.codbem <> '<TODOS>'
and tcibem.numnota is not null
and saldos.referencia is not null
and saldos.codprod (+) = tcibem.codprod
and saldos.codbem (+) = tcibem.codbem
Problema com PIVOT XML em query ORA-00904
-
- Rank: Estagiário Pleno
- Mensagens: 5
- Registrado em: Qui, 04 Jan 2018 10:18 am
- dr_gori
- Moderador
- Mensagens: 5024
- Registrado em: Seg, 03 Mai 2004 3:08 pm
- Localização: Portland, OR USA
- Contato:
Thomas F. G
Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered
Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered
Hmm...
http://www.dba-oracle.com/t_ora_00904_s ... tifier.htm
https://asktom.oracle.com/pls/apex/f?p= ... 0346783166
No caso dele, a solução foi colocar entre aspas duplas o nome do campo.
Veja as respostas no link acima.
http://www.dba-oracle.com/t_ora_00904_s ... tifier.htm
Parece que o Tom Kyte tem um problema semalhante ao seu:ORA-00904 string: invalid identifier
Cause: The column name entered is either missing or invalid.
Action: Enter a valid column name. A valid column name must begin with a letter, be less than or equal to 30 characters, and consist of only alphanumeric characters and the special characters $, _, and #.
If it contains other characters, then it must be enclosed in double quotation marks. It may not be a reserved word.
https://asktom.oracle.com/pls/apex/f?p= ... 0346783166
No caso dele, a solução foi colocar entre aspas duplas o nome do campo.
Veja as respostas no link acima.
-
- Rank: Estagiário Pleno
- Mensagens: 5
- Registrado em: Qui, 04 Jan 2018 10:18 am
Me desculpe mas está bem longe de ser o mesmo problema, pois a query é bem diferente.
-
- Rank: Estagiário Pleno
- Mensagens: 5
- Registrado em: Qui, 04 Jan 2018 10:18 am
select distinct * from
(
select tcibem.codbem,
tcibem.descrabrev,
tcibem.numnota,
nvl(ad_depacel.saldo, 0) as saldo,
tcibem.dtfimdep,
tcitax.taxa,
tcibem.vlrsaldo,
saldos.referencia,
nvl(saldos.vlr_depreciado, 0) as vlr_depreciado
from tcibem,
ad_depacel,
tgfpro,
tcitax,
(
select tcisal.codprod as codprod
, tcisal.codbem as codbem
, to_char(tcisal.referencia, 'mm/yyyy') as referencia
, tcisal.saldo as vlr_depreciado
from tcisal
) saldos
where ad_depacel.codbem (+) = tcibem.codbem
and tgfpro.codprod = tcibem.codprod
and tcitax.codprod = tcibem.codprod
and tcibem.codbem <> '<TODOS>'
and tcibem.numnota is not null
and saldos.referencia is not null
and saldos.codprod (+) = tcibem.codprod
and saldos.codbem (+) = tcibem.codbem
)
pivot xml (sum(nvl(vlr_depreciado, 0)) as vlr_depreciado for (referencia) in (select to_char(referencia, 'mm/yyyy') as referencia from tcisal))
Se alguém puder ajudar agradeço.
-
- Informação
-
Quem está online
Usuários navegando neste fórum: Nenhum usuário registrado e 7 visitantes