array handling on 8.0.3
array handling on 8.0.3
От:
Daniel Drotos <drdani@mazsola.iit.uni-miskolc.hu>
Дата:
Hi,
I have to run a function on a 9.0.3 server. Following part
(of a bigger function):
create or replace function t(p varchar) returns void as
$$
declare v varchar; f varchar; a varchar[]; i integer;
begin a:= '{}'; if p like '%/%' then v:= trim_null(split_part(p, '/', 1)); f:= v; a:= a||v; i:= 2; while v != '' loop v:= trim_null(split_part(p, '/', i)); raise INFO 'splitted=%',v; a:= a||v; i:= i+1; raise INFO 'a=%',a; end loop; raise INFO 'a=% ready',a; else f:= p; end if; return;
end;
$$
language 'plpgsql' volatile;
raises (if called as t('a/b')):
INFO: splitted=b
INFO: a={a,b}
INFO: splitted=
INFO: a=
INFO: a= ready
It looks that value of the array `a' is lost after the loop. Is this
normal? What do I do wrong?
Daniel