altocompta/sql/trunk/06_get_tree_account.sql
2010-04-24 10:55:54 +00:00

22 lines
No EOL
423 B
PL/PgSQL

drop function if exists get_pcm_tree(account_type);
create or replace function get_pcm_tree(source account_type) returns setof account_type
as
$_$
declare
i account_type;
e account_type;
begin
for i in select pcm_val from tmp_pcmn where pcm_val_parent=source
loop
return next i;
for e in select get_pcm_tree from get_pcm_tree(i)
loop
return next e;
end loop;
end loop;
return;
end;
$_$
language plpgsql;