altocompta/sql/format_account.sql
Dany De Bontridder e894eb5333 update script SQL
2011-11-22 22:44:52 +00:00

28 lines
633 B
PL/PgSQL

CREATE OR REPLACE FUNCTION comptaproc.format_account(p_account account_type)
RETURNS account_type AS
$BODY$
declare
sResult account_type;
begin
sResult := lower(p_account);
sResult := translate(sResult,'éèêëàâäïîüûùöô','eeeeaaaiiuuuoo');
sResult := translate(sResult,' $€µ£%.+-/\!(){}(),;_&|"#''^','');
if not sResult similar to '^[[:alnum:]_]+$' then
raise exception 'Invalid character in %',p_account;
end if;
return upper(sResult);
end;
$BODY$
LANGUAGE plpgsql;
COMMENT ON FUNCTION comptaproc.format_account(account_type) IS 'format the accounting :
- upper case
- remove space and special char.
';