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
| DECLARE identifiant ALIAS FOR $1;
DECLARE r record;
BEGIN
SELECT INTO r * FROM inscription_temp WHERE id_ins = identifiant;
INSERT INTO francais (id_antiquaire, nom_antiquaire, nom_boutique, adresse_boutique, id_village, telephone, email, site, date_saisie, no_departement)
VALUES (nextval('francais_id_antiquaire_seq'), r.nom || ' ' || r.prenom, r.nom_boutique, r.adresse, r.id_village, r.telephone, r.email, r.site, r.date_ins, r.departement);
IF r.spec1 IS NULL THEN
ELSE
INSERT INTO boutique_specialites VALUES (r.spec1, currval('francais_id_antiquaire_seq'), 1);
END IF;
IF r.spec2 IS NULL THEN
ELSE
INSERT INTO boutique_specialites VALUES (r.spec2, currval('francais_id_antiquaire_seq'), 2);
END IF;
IF r.spec3 IS NULL THEN
ELSE
INSERT INTO boutique_specialites VALUES (r.spec3, currval('francais_id_antiquaire_seq'), 3);
END IF;
DELETE FROM inscription_temp WHERE id_ins = identifiant;
return 0;
END; |
Partager