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 33 34 35 36 37 38 39 40 41 42 43 44 45
| create or replace function archivage() returns trigger as
$$
declare
nometud varchar;
prenometud varchar;
numsta integer;
titresta varchar;
objetsta varchar;
anneescol date;
numetud integer;
regimeetud varchar;
numconta integer;
numprofsuiv integer;
remarque varchar;
begin
nometud:=old.nometudiant;
select nometudiant into nometud from etudiants where nometudiant=nometud;
prenometud:=old.prenometudiant;
select prenometudiant into prenometud from etudiants where prenometudiant=prenometud;
numsta:=old.numstage;
select numstage into numsta from stages where numstage=numsta;
titresta:=old.titrestage;
select titrestage into titresta from stages where numstage=numsta;
objetsta:=old.objetstage;
select objetstage into objetsta from stages where numstage=numsta;
anneescol:=old.anneescolaire;
select anneescolaire into anneescol from stages where numstage=numsta;
numetud:=old.numetudiant;
select numetudiant into numetud from stages where numstage=numsta;
regimeetud:=old.regimeetudiant;
select regimeetudiant into regimeetud from stages where numstage=numsta;
numconta:=old.numcontact;
select numcontact into numconta from stages where numstage=numsta;
numprofsuiv:=old.numprofsuiveur;
select numprofsuiveur into numprofsuiv from stages where numstage=numsta;
remarque:=old.remarques;
select remarques into remarque from stages where numstage=numsta;
insert into archive values (default,nometud,prenometud,numsta,titresta,objetsta,anneescol,numetud,regimeetud,numconta,numprofsuiv,remarque);
return old;
end;
$$
language plpgsql; |
Partager