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=<NULL>
INFO: a=<NULL>
INFO: a=<NULL> ready
It looks that value of the array `a' is lost after the loop. Is this
normal? What do I do wrong?
Daniel
---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at
http://www.postgresql.org/about/donate