Bug : currency_id was nullable

script compatible PSQL 10
This commit is contained in:
sparkyx 2021-10-11 18:28:17 +02:00
parent fa530b7b0e
commit 096cfc4a20
2 changed files with 35 additions and 1 deletions

View file

@ -116,7 +116,7 @@ if ( !defined ("NOALYSS_PACKAGE_REPOSITORY")) {
if ( ! defined ("SYSINFO_DISPLAY")) {
define ("SYSINFO_DISPLAY",TRUE);
}
define ("DBVERSION",168);
define ("DBVERSION",169);
define ("MONO_DATABASE",25);
define ("DBVERSIONREPO",20);
define ('NOTFOUND','--not found--');

View file

@ -0,0 +1,34 @@
begin;
update jrn set currency_id = 0,currency_rate=1,currency_rate_ref = 1 where currency_id is null or currency_rate is null or currency_rate_ref is null;
CREATE OR REPLACE FUNCTION comptaproc.jrn_currency()
RETURNS trigger
AS $function$
begin
if new.currency_id is null then
new.currency_id := 0;
new.currency_rate := 1;
new.currency_rate_ref := 1;
end if;
return new;
end;
$function$
LANGUAGE plpgsql;
create trigger t_jrn_currency before
insert or update
on
public.jrn for each row execute procedure comptaproc.jrn_currency();
ALTER TABLE public.jrn ALTER COLUMN currency_id SET NOT NULL;
ALTER TABLE public.jrn ALTER COLUMN currency_rate SET NOT NULL;
ALTER TABLE public.jrn ALTER COLUMN currency_rate_ref SET NOT NULL;
insert into version (val,v_description) values (169,'Fix bug currency_id is null, from IMPORTBANK');
commit ;