I'm using PL/SQL developer to créate this trigger, I read somewhere that it could be a CR-LF missinterpretation by Oracle, but it is the first time this occurs. Below the code is the Error log:
create or replace trigger Terreno_nomenc
before update of circ_prov,sector_prov,cod_div_prov,nro_div_prov,nro_parc_prov on adminmo.terreno
for each row
declare
circ integer:= 0;
sector integer:= 0;
cod_div integer:= 0;
nro_div integer:= 0;
nro_par integer:= 0;
nueva_nomenc varchar2(18) := ' ';
vieja_nomenc varchar2(18) := ' ';
dominio integer:= 0;
begin
vieja_nomenc:= :old.nomenc;
if (:new.circ_prov <> :old.circ_prov) then {
circ := :new.circ_prov;
}
else {
circ := :old.circ_prov;
}
end if;
if(:new.sector_prov <> :old.sector_prov) then {
sector := :new.sector_prov;
}
else {
sector := :old.sector_prov;
}
end if;
if(:new.cod_div_prov <> :old.cod_div_prov) then {
cod_div := :new.cod_div_prov;
}
else{
cod_div := :old.cod_div_prov;
}
end if;
if(:new.nro_div_prov <> :old.nro_div_prov) then {
nro_div := :new.nro_div_prov;
}
else{
nro_div := :old.nro_div_prov;
}
end if;
if(:new.nro_parc_prov <> :old.nro_parc_prov) then {
nro_par := :new.nro_parc_prov;
}
else{
nro_par := :old.nro_parc_prov;
}
end if;
if(circ > 0 and sector > 0 and cod_div > 0 and nro_div > 0) {
nueva_nomenc := to_char(circ,'999') || '-' || to_char(sector,'99') || '-' || to_char(cod_div,'99') || '-' || to_char(nro_div,'9999') || '-' || to_char(nro_par, '999');
select t.refnro into dominio
from geoimax.comodoro_ejido_dom_ref t
where t.reftex = vieja_nomenc;
update terreno set nomenc = nueva_nomenc where terreno.subsistema = :new.subsistema and terreno.partida = :new.partida;
update geoimax.Comodoro_Ejido_Dom_Ref c set c.reftex = nueva_nomenc where c.refnro = dominio;
}
end if;
end Terreno_nomenc;
Error: PLS-00103: Encountered the symbol "{" when expecting one of the following:
( begin case declare 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
The symbol "begin was inserted before "{" to continue.
Line: 19 Text: if (:new.circ_prov <> :old.circ_prov) then {
Error: PLS-00103: Encountered the symbol "}" when expecting one of the following:
( begin case declare end exception 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
Line: 21 Text: }