diff --git a/html/admin/sql/mod2/schema.sql b/html/admin/sql/mod2/schema.sql
index a26f2029f..4345c4ecb 100644
--- a/html/admin/sql/mod2/schema.sql
+++ b/html/admin/sql/mod2/schema.sql
@@ -628,6 +628,20 @@ begin
raise notice 'Max code %',maxcode;
return maxcode+1;
end;
+$$
+LANGUAGE plpgsql;
+
+
+CREATE FUNCTION attribut_insert(p_f_id integer, p_ad_id integer, p_value character varying) RETURNS void
+ AS $$
+declare
+ n_jft_id integer;
+begin
+ select nextval('s_jnt_fic_att_value') into n_jft_id;
+ insert into jnt_fic_att_value (jft_id,f_id,ad_id) values (n_jft_id,p_f_id,p_ad_id);
+ insert into attr_value (jft_id,av_text) values (n_jft_id,p_value);
+return;
+end;
$$
LANGUAGE plpgsql;
@@ -652,7 +666,7 @@ begin
nParent:=account_parent(p_account);
insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent)
values (p_account,sName,nParent);
- attribut_insert(p_f_id,5,to_char(nNew,'999999999999'));
+ perform attribut_insert(p_f_id,5,to_char(nNew,'999999999999'));
end if;
else
@@ -677,7 +691,7 @@ raise debug 'nNew %', nNew;
return 0;
end;
$$
- LANGUAGE plpgsql;
+LANGUAGE plpgsql;
CREATE FUNCTION account_parent(p_account poste_comptable) RETURNS poste_comptable
AS $$
@@ -735,34 +749,20 @@ return njft_id;
end;
$$
LANGUAGE plpgsql;
-
-CREATE FUNCTION attribut_insert(p_f_id integer, p_ad_id integer, p_value character varying) RETURNS void
- AS $$
-declare
- n_jft_id integer;
-begin
- select nextval('s_jnt_fic_att_value') into n_jft_id;
- insert into jnt_fic_att_value (jft_id,f_id,ad_id) values (n_jft_id,p_f_id,p_ad_id);
- insert into attr_value (jft_id,av_text) values (n_jft_id,p_value);
-return;
-end;
-$$
- LANGUAGE plpgsql;
-
-CREATE FUNCTION card_class_base(p_f_id integer) RETURNS poste_comptable
- AS $$
+CREATE FUNCTION card_class_base(p_f_id integer) RETURNS fiche_def.fd_class_base%type
+AS $$
declare
- n_poste fiche_def.fd_class_base%type;
+ n_poste fiche_def.fd_class_base%type;
begin
- select fd_class_base into n_poste from fiche_def join fiche using (fd_id)
- where f_id=p_f_id;
- if not FOUND then
- raise exception 'Invalid fiche card_class_base(%)',p_f_id;
- end if;
-return;
+ select fd_class_base into n_poste from fiche_def join fiche using (fd_id)
+ where f_id=p_f_id;
+ if not FOUND then
+ raise exception 'Invalid fiche card_class_base(%)',p_f_id;
+ end if;
+return n_poste;
end;
$$
- LANGUAGE plpgsql;
+ LANGUAGE plpgsql;
CREATE FUNCTION check_balance(p_grpt integer) RETURNS numeric
AS $$
diff --git a/html/admin/sql/patch/upgrade13.sql b/html/admin/sql/patch/upgrade13.sql
index 0f35cbc11..906b53b9f 100644
--- a/html/admin/sql/patch/upgrade13.sql
+++ b/html/admin/sql/patch/upgrade13.sql
@@ -86,6 +86,25 @@ $body$ language plpgsql;
+create or replace function attribut_insert ( p_f_id integer, p_ad_id integer, p_value varchar)
+returns void
+as
+$$
+-- attribut_integer
+-- parameter : f_id, ad_id, p_value
+-- purpose add an attribute to a card
+-- it inserts a row into jnt_fic_att_value and attr_value
+declare
+ n_jft_id integer;
+begin
+ select nextval('s_jnt_fic_att_value') into n_jft_id;
+ insert into jnt_fic_att_value (jft_id,f_id,ad_id) values (n_jft_id,p_f_id,p_ad_id);
+ insert into attr_value (jft_id,av_text) values (n_jft_id,p_value);
+return;
+end;
+$$
+language plpgsql volatile;
+
CREATE OR REPLACE FUNCTION account_insert(p_f_id fiche.f_id%type,p_account tmp_pcmn.pcm_val%type)
@@ -122,7 +141,7 @@ begin
insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent)
values (p_account,sName,nParent);
-- insert as card's attribute
- attribut_insert(p_f_id,5,to_char(nNew,'999999999999'));
+ perform attribut_insert(p_f_id,5,to_char(nNew,'999999999999'));
end if;
else
@@ -157,6 +176,7 @@ return 0;
end;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
+
create or replace function account_parent(p_account tmp_pcmn.pcm_val%type)
returns
-- account_parent
@@ -237,25 +257,6 @@ end;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
-
-create or replace function attribut_insert ( p_f_id integer, p_ad_id integer, p_value varchar)
-returns void
-as
-$$
--- attribut_integer
--- parameter : f_id, ad_id, p_value
--- purpose add an attribute to a card
--- it inserts a row into jnt_fic_att_value and attr_value
-declare
- n_jft_id integer;
-begin
- select nextval('s_jnt_fic_att_value') into n_jft_id;
- insert into jnt_fic_att_value (jft_id,f_id,ad_id) values (n_jft_id,p_f_id,p_ad_id);
- insert into attr_value (jft_id,av_text) values (n_jft_id,p_value);
-return;
-end;
-$$
-language plpgsql volatile;
create or replace function account_add (p_id tmp_pcmn.pcm_val%type,p_name varchar)
returns void
as
@@ -325,7 +326,7 @@ alter table document_modele add constraint md_type foreign key (md_type) referen
create or replace function card_class_base(p_f_id fiche.f_id%type)
-returns poste_comptable
+returns fiche_def.fd_class_base%type
as
$$
@@ -342,7 +343,7 @@ begin
if not FOUND then
raise exception 'Invalid fiche card_class_base(%)',p_f_id;
end if;
-return;
+return n_poste;
end;
$$ language plpgsql;
diff --git a/html/admin/sql/patch/upgrade8.sql b/html/admin/sql/patch/upgrade8.sql
index 3ef3ace0b..447d4685a 100644
--- a/html/admin/sql/patch/upgrade8.sql
+++ b/html/admin/sql/patch/upgrade8.sql
@@ -68,7 +68,7 @@ CREATE TABLE import_tmp (
code text not null,
date_exec date not null ,
date_valeur date not null,
- montant number(20,4) not null default 0,
+ montant numeric(20,4) not null default 0,
devise text,
compte_ordre text,
detail text,