Skip to content
Snippets Groups Projects
Commit 254b229f authored by Justine Ouellette's avatar Justine Ouellette
Browse files

trigger done but not tested

parent 0e890aa5
No related branches found
No related tags found
No related merge requests found
CREATE TRIGGER max_odometre_atteint AFTER UPDATE OF odometre ON vehicule
REFERENCING OLD TABLE AS voiture
WHEN (NEW.odometre >= caracteristiques_vehicule.odometre_max FROM vehicule JOIN caracteristiques_vehicule ON vehicule.type = caracteristiques_vehicule.type)
EXECUTE FUNCTION vendre_vehicule();
CREATE FUNCTION vendre_vehicule() RETURNS trigger AS $test$
BEGIN
CREATE TABLE avendre (
immatriculation TypeImmatriculation,
marque TypeTexteCourt,
modele TypeTexteCourt,
odometre INT NOT NULL,
date_mise_en_service DATE NOT NULL,
consommation FLOAT NOT NULL,
"type" TypeVehicule NOT NULL,
kw_recharge FLOAT,
);
INSERT INTO avendre (
SELECT
voiture.immatriculation,
voiture.marque,
voiture.modele,
voiture.odometre,
voiture.date_mise_en_service,
voiture.consommation,
voiture.type,
voiture.kw_recharge
FROM voiture
);
END;
$test$
LANGUAGE plpgsql;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment