Re: plpgsql at what point does the knowledge of the query come in?

From: Henry Drexler <alonup8tb(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: plpgsql at what point does the knowledge of the query come in?
Date: 2011-10-20 20:51:10
Message-ID: CAAtgU9R44BtRn9unjwEBU+gLWGehu=BOy50+iwSvGrNk4f78AA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I found the problem, it looks like nnlength := length(newnode); is not
getting reset

create or replace function nnodetestt(text) returns text language plpgsql as
$$
DECLARE
newnode alias for $1;
nnlength integer;
t text;
nmarker text;
BEGIN
nnlength := length(newnode);
for i in 1..(nnlength-1) loop
select into t
node
from
(Values('threeee','N'),('threee',''),('fiveu','N'),('five',''))
blast(node,nmarker)
where node = substring(newnode,1,i-1)||substring(newnode,i+1,nnlength);
end loop;
return t;
END;
$$

select
node as node_orig,
nmarker,
nnodetestt(node),
case
when nmarker = 'N' then
nnodetestt(node)
end
from
(Values('threeee','N'),('threee',''),('fiveu','N'),('five',''))
blast(node,nmarker)

"threeee";"N";"threee";"threee"
"threee";"";"";""
"fiveu";"N";"";""
"five";"";"";""

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Raymond O'Donnell 2011-10-20 20:57:24 Re: plpgsql at what point does the knowledge of the query come in?
Previous Message S. Balch 2011-10-20 20:34:58 force JDBC driver fetch / autocommit parameters?