Fix upgrade85.sql

This commit is contained in:
Dany De Bontridder 2010-07-31 19:14:25 +00:00
parent 8afda28ad6
commit 5c4bd5c9c4

View file

@ -1,5 +1,31 @@
begin;
ALTER TABLE quant_purchase
CREATE OR REPLACE FUNCTION comptaproc.jrnx_ins()
RETURNS trigger AS
$BODY$
declare
n_fid bigint;
begin
if NEW.j_qcode is NULL then
return NEW;
end if;
NEW.j_qcode=trim(upper(NEW.j_qcode));
if length (NEW.j_qcode) = 0 then
NEW.j_qcode=NULL;
else
select f_id into n_fid from fiche join jnt_fic_att_value using (f_id) join attr_value using(jft_id) where ad_id=23 and av_text=NEW.j_qcode;
if NOT FOUND then
raise exception 'La fiche dont le quick code est % n''existe pas',NEW.j_qcode;
end if;
end if;
return NEW;
end;
$BODY$
LANGUAGE 'plpgsql' ;
ADD CONSTRAINT quant_purchase_qp_internal_fkey FOREIGN KEY (qp_internal)
REFERENCES jrn (jr_internal) MATCH SIMPLE
ON UPDATE CASCADE ON DELETE CASCADE;