lysle
Messages postés2Date d'inscriptionmercredi 16 avril 2008StatutMembreDernière intervention25 décembre 2009
-
17 déc. 2009 à 22:03
khadoudj09
Messages postés3Date d'inscriptionmardi 13 mai 2008StatutMembreDernière intervention25 décembre 2009
-
25 déc. 2009 à 22:44
bjr, a tous,
voila j'ai fait un code en sql mais le souci c'est que cela me retourne une erreur du style:
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:
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