Hi all. Im having some trouble here that cannot understand.
Consider this function:
CREATE OR REPLACE FUNCTION read_words(bigint, varchar)
returns varchar
as
$$
declare
   returnValue varchar ;
BEGIN
select * into returnValue from array_to_string(array(select word from words where page_id=$1 and word_position in ($2)), ' ');
return returnValue;
END;
$$ language plpgsql;

So far, so good. But...
select * from read_words(99466::bigint, '2994,2995,2996');
read_words
------------

(1 row)

But...if i do a
select * from array_to_string(array(select word from words where page_id=99466 and word_position in (2994,2995,2996)), ' ')
      array_to_string
-----------------------------
man page inside

Means that the query itself seems OK, but something in the SELECT INTO thing is not working to me.
Mmmm...i guess is not that. I just make the sql version of that function
CREATE OR REPLACE FUNCTION read_words(bigint, varchar)
returns varchar
as
$$
select * from array_to_string(array(select word from words where page_id=$1 and word_position in ($2)), ' ');
$$
language sql;

with the same (NULL) results....Looks like im having some mistake near 'and word_position in ($2)...'
Wreird enough to me, need some advice plz!

Thanks!
Gerardo

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

               http://www.postgresql.org/about/donate

Reply via email to