Last upgrade for version 3.0
This commit is contained in:
parent
35203bd753
commit
8793b3dc0b
1 changed files with 72 additions and 0 deletions
72
html/admin/sql/patch/upgrade34.sql
Normal file
72
html/admin/sql/patch/upgrade34.sql
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
begin;
|
||||
|
||||
CREATE or replace FUNCTION t_jrn_def_sequence() RETURNS "trigger"
|
||||
AS $$
|
||||
declare
|
||||
nCounter integer;
|
||||
|
||||
BEGIN
|
||||
select count(*) into nCounter
|
||||
from pg_class where relname='s_jrn_'||NEW.jrn_def_id;
|
||||
if nCounter = 0 then
|
||||
execute 'create sequence s_jrn_'||NEW.jrn_def_id;
|
||||
raise notice 'Creating sequence s_jrn_%',NEW.jrn_def_id;
|
||||
end if;
|
||||
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$
|
||||
LANGUAGE plpgsql;
|
||||
|
||||
create or replace function correct_sequence_jrn () returns void
|
||||
as $$
|
||||
declare
|
||||
nCounter integer;
|
||||
nJrn_id record;
|
||||
begin
|
||||
for nJrn_id in select jrn_Def_id from jrn_def loop
|
||||
select count(*) into nCounter
|
||||
from pg_class where relname='s_jrn_'||nJrn_id.jrn_def_id;
|
||||
if nCounter = 0 then
|
||||
execute 'create sequence s_jrn_'||nJrn_id.jrn_def_id;
|
||||
raise notice 'Creating sequence s_jrn_%',nJrn_id.jrn_def_id;
|
||||
end if;
|
||||
|
||||
|
||||
end loop;
|
||||
end;
|
||||
$$
|
||||
LANGUAGE plpgsql;
|
||||
select correct_sequence_jrn();
|
||||
|
||||
drop function correct_sequence_jrn();
|
||||
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION tva_delete(int4)
|
||||
RETURNS void AS
|
||||
$BODY$
|
||||
declare
|
||||
p_tva_id alias for $1;
|
||||
nCount integer;
|
||||
begin
|
||||
nCount=0;
|
||||
select count(*) into nCount from quant_sold where qs_vat_code=p_tva_id;
|
||||
if nCount != 0 then
|
||||
return;
|
||||
|
||||
end if;
|
||||
select count(*) into nCount from quant_purchase where qp_vat_code=p_tva_id;
|
||||
if nCount != 0 then
|
||||
return;
|
||||
|
||||
end if;
|
||||
|
||||
delete from tva_rate where tva_id=p_tva_id;
|
||||
return;
|
||||
end;
|
||||
$BODY$
|
||||
LANGUAGE 'plpgsql' VOLATILE;
|
||||
|
||||
update version set val=35;
|
||||
commit;
|
||||
Loading…
Add table
Add a link
Reference in a new issue