pb create function postgresql,requete
bjr, a tous,
voila j'ai fait un code en sql mais le souci c'est que cela me retourne une erreur du style:
Citation:
ERROR: query has no destination for result data
HINT: If you want to discard the results of a SELECT, use PERFORM instead.
CONTEXT: PL/pgSQL function "som_capac" line 8 at SQL statement
voila le code:
Code:
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
| CREATE function som_capac() returns trigger as $som_capac$
declare
som integer;
cap integer;
begin
select sum(nombre_billets) into som from billets,repres_local where date_repres_local=NEW.date_billets_spec and id_repres_local=NEW.ref_id_repres_local_billets;
select capacite into cap from pieces,repres_local,billets where id_repres_local=NEW.ref_id_repres_local_billets and ref_id_pieces_local=id_pieces and id_pieces=NEW.ref_id_repres_local_billets;
if cap>NEW.nombre_billets+som
then insert into billets values(NEW.id_billets,NEW.ref_id_repres_local_billets,NEW.ref_code_tarifs_billets,NEW.nombre_billets,NEW.date_achat,NEW.date_billets_spec);
else set message_text='il n ya plus de place pour le nombre donne, veuillez le diminuer';
end if;
return new;
end;
$som_capac$ language plpgsql;
create trigger som_capac before insert or update on billets
for each row execute procedure som_capac(); |
j'aimerais aussi savoir si syntaxiquement mon code est correct.
voila merci d'avance