Am trying to select between two values from two different tables. If the value of PORC in table RISK_PRODUCTOR is 0 or null
I check the value in PORCIENTO in table RISK_RIESGOS_PRODUCTORES and use that instead if exist. If not I will assign null.
But am getting this error in this code:
declare
l_porc_productor number;
l_com_productor number;
begin
select
nullif(porc,0)
into
l_porc_productor
from
risk_productor p
where
p.productor_id = :p42_productor_id
and r.organizacion_id = :APP_GET_ORGANIZACION_ID;
exception
when no_data_found
then
l_porc_productor := null;
if l_porc_productor is not null then
:P42_PORC_PRODUCTOR := l_porc_productor;
else
select
nullif(porciento, 0)
,nvl2(nullif(porciento, 0), null, cantidad)
into
:p42_PORC_PRODUCTOR
,:p42_COM_PRODUCTOR
from
risk_riesgos_productores r
where
r.agencia_id = :p42_agencia_id
and r.compania_id = :p42_compania_id
and r.riesgo_id = :p42_riesgo_id
and r.productor_id = :p42_productor_id
and nvl(:P42_PORC_PRODUCTOR,'0') = 0
and r.organizacion_id = :APP_GET_ORGANIZACION_ID;
ORA-06550: line 43, column 6: PLS-00103: Encountered the symbol "EXCEPTION" when expecting one of the following: ( begin case declare end exit for goto if loop mod null pragma raise return select update while with <an identifier> <a double-quoted delimited-identifier> <a bind variable> << continue close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe purge json_exists json_value json_query json_object json_array
exception
when no_data_found
then
:p42_porc_productor := null;
:p42_com_productor := null;
end if;
end;
What am missing here?
Thanks for any help!!!
This post has been answered by
mathguy
on Jun 14 2020