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

From: Henry Drexler <alonup8tb(at)gmail(dot)com>
To: rod(at)iol(dot)ie
Cc: 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-21 20:01:15
Message-ID: CAAtgU9RDYt-H_rcjc0Wq9X_Gjm0MvqUdovHsHGP8VvKBu9PHcA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Oct 21, 2011 at 2:57 PM, Henry Drexler <alonup8tb(at)gmail(dot)com> wrote:

> I realize I have sent a lot of messages on this thread so this will be the
> last one unless I come up with a solution, then I will post that.
>
>
Resolved.

Ray - thanks again for your help.

The pattern was it was only matching those that had a change to the end of
the partner word.
so the function was going through then only returning the last comparison.

I needed to add an if statement into the function to 'return r' when it
evaluated to true.

Thus:

create or replace function nnodetestt(text) returns text language plpgsql
immutable as $$
DECLARE
newnode alias for $1;
nnlength integer;
t text;
nmarker text;
BEGIN
nnlength := length(newnode);
RAISE NOTICE 'number %', nnlength;
for i in 1..(nnlength) loop

select into t node from
(Values('one'),('on'),('fivehundredsixtyseven'),('fivehundredsixtysevens'),('one
two three fou'),('one two three four'),('onetwo three ninety'),('one two
three ninety')) blast(node) where node = left(newnode, i-1)||right(newnode,
nnlength-i);
-- RAISE NOTICE 'nnlength %', nnlength;
--raise notice 'increment %',right(newnode, nnlength-i);
RAISE NOTICE 'textbreakout: %' , left(newnode, i-1)||right(newnode,
nnlength-i);

if t = left(newnode, i-1)||right(newnode, nnlength-i) then return t;
end if;

end loop;
return t;
END;
$$

select
node,
nnodetestt(node)
from
(Values('one'),('on'),('fivehundredsixtyseven'),('fivehundredsixtysevens'),('one
two three fou'),('one two three four'),('onetwo three ninety'),('one two
three ninety'))
blast(node)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Mieslinger 2011-10-21 20:45:52 Anyone using the solaris 11 precompiled binaries on opensolaris snv_134
Previous Message Henry Drexler 2011-10-21 18:57:40 Re: plpgsql at what point does the knowledge of the query come in?