Greetings from Costa Rica,
I'm starting with Oracle PL / SQL (running the systems race) and I want to build a cursor as a practice to update the registry of names, emails, telephones and cards of the entire database.
The information of clients is in 2 tables only, I already managed to add a 1 to the variable each time the cursor finds a record first I want to try with names and then enter the rest of the fields in the cursor, but I want to differentiate it between people physical (natural) and legal (companies) but I can not do the update for what I would like to see if you can guide me.
declare
v_acum number;
cursor c_actualiza
is
select a.cod_cia, a.cod_docum,a.tip_docum, a.nom_tercero, a.nom2_tercero, a.ape1_tercero,a.ape2_tercero,a.tlf_movil,
b.tlf_numero, b.email,b.tlf_numero_com,b.email_com,b.cta_cte,b.txt_email,b.cod_tarjeta,b.num_tarjeta,
b.fec_vcto_tarjeta
from a1001399 a, a1001331 b
where a.cod_cia = 1
and a.nom_tercero != 'null'
and a.tip_docum = b.tip_docum
and a.cod_docum = b.cod_docum
and a.cod_docum
in ('111810464',
'111610631',
'800870150',
'110550726',
'111830715',
'111120585',
'110030332',
'111460930',
'3101397485',
'3101294479',
'01002312815',
'011203096',
'012180004480193988',
'011203096',
'07469542');
begin
v_acum := 0;
for reg in c_actualiza loop
v_acum := v_acum + 1;
begin
UPDATE a1001399 i
SET i.nom_tercero = 'PRUEBASCR' || ' - ' || v_acum
where i.cod_cia = reg.cod_cia
and i.tip_docum = reg.tip_docum
and i.cod_docum = reg.cod_docum;
EXCEPTION
when i.tip_docum IN ( 'CJU' and 'EEX') then
UPDATE a1001399 i
SET i.nom_tercero = 'DESARROLLOCR' || ' - ' || v_acum
where i.cod_cia = reg.cod_cia
and i.tip_docum = reg.tip_docum
and i.cod_docum = reg.cod_docum;
--dbms_output.put_line('ERROR');
END;
dbms_output.put_line (reg.nom_tercero);
end loop;
end;