1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
/*Procédure d'ajout d'un client*/
create or replace procedure add_client(client_id number,client_last_name varchar2,client_first_name varchar2,client_address varchar2,client_tel number,client_mail varchar2,client_ca number,client_category varchar2) is
begin
insert into client values(client_id,client_last_name,client_first_name,client_address,client_tel,client_mail,client_ca,client_category);
commit;
end;
/*Procédure de maj de la catégorie*/
create or replace procedure maj_client_category(arg_client_id number) is
v_client_category client.client_category%type;
begin
select client_category into v_client_category from client where client_id=arg_client_id;
if (v_client_category < 5000) then
update client set client_category='passager';
elsif (v_client_category > 10000) then
update client set client_category='potentiel';
else
update client set client_category='important';
end if;
end;
/
/*Trigger qui appelle la procédure précédente à la suite de chaque insertion d'un client*/
create or replace trigger tr_after_add_client
after insert
on client
for each row
begin
maj_client_category(:new.client_id);
end;
/ |
Partager