Estou com um problema quando vou salvar o select abaixo em um pacote/procedure no oracle 8. Eu fiz este SQL no oracle 9 e neste versão do oracle compilou certo mas quando fui coloca-lo em produção, oracle 8, o mesmo select deu um erro e não compila.
Abaixo estou enviando o SQL e erro se alguém puder me ajudar eu agradeço.
Atenciosamente,
Sheila
**** SQL *****
SELECT
sum(DECODE(C.NUM_PARCELA
,0 ,((((C.NUM_FIM_PARCELA - C.NUM_INI_PARCELA) + 1) * R.VLR_RECEITA) * 2.0514)
,(R.VLR_RECEITA * 2.0514)
)) AS VLR_RECEITA
, MAX (( SELECT sum(D.VLR_PAGO_RECEITA)
FROM ARC_PAG_EFET Pa
,ARC_DISTRIB_RECEITA D
WHERE D.DTA_REPASSE = '31/07/2006'
AND D.SEQ_PAGAMENTO = Pa.SEQ_PAGAMENTO
AND D.COD_RECEITA = 277
and Pa.Cod_Identificacao = c.cod_identificacao
GROUP BY D.SEQ_PAGAMENTO
) )AS VLR_PAGO_RECEITA
FROM ARC_PAG_EFET P
, ARC_PARCELA C
, ARC_RECEITA_CONTRIBUICAO R
WHERE P.DTA_COLETA = '31/07/2006'
AND C.COD_IDENTIFICACAO = P.COD_IDENTIFICACAO
AND R.SEQ_LANCAMENTO = C.SEQ_LANCAMENTO
AND R.NUM_EMISSAO = C.NUM_EMISSAO
AND R.COD_RECEITA = 277
group by r.seq_lancamento, c.cod_identificacao
***********************************************************
****** ERRO *********
Compilation errors for PACKAGE BODY PKG_ARC_RELATORIOS
Error: PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
( - + mod not null others <an identifier>
<a double-quoted delimited-identifier> <a bind variable> avg
count current exists max min prior sql stddev sum variance
execute forall time timestamp interval date
<a string literal with character set specification>
<a number> <a single-quoted SQL string>
Line: 168
Text: , (SELECT SUM(D.VLR_PAGO_RECEITA)
Error: PLS-00103: Encountered the symbol "FROM"
Line: 177
Text: FROM ARC_PAG_EFET P
Compilation errors for PACKAGE BODY PKG_ARC_RELATORIOS
Error: PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
( - + all mod null <an identifier>
<a double-quoted delimited-identifier> <a bind variable> avg
count current distinct max min prior sql stddev sum unique
variance execute forall time timestamp interval date
<a string literal with character set specification>
<a number> <a single-quoted SQL string>
Line: 168
Text: , MAX(SELECT SUM(D.VLR_PAGO_RECEITA)
Error: PLS-00103: Encountered the symbol "AS" when expecting one of the following:
; return returning and or
Line: 176
Text: )