On Fri, Oct 21, 2011 at 2:57 PM, Henry Drexler <alonup8tb@xxxxxxxxx> 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)