Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 79CD59FBD6E for ; Tue, 30 Oct 2007 17:25:30 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 48466-08 for ; Tue, 30 Oct 2007 17:25:24 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mail.fmed.uba.ar (mail.fmed.uba.ar [157.92.152.1]) by postgresql.org (Postfix) with ESMTP id CFB1C9FBD47 for ; Tue, 30 Oct 2007 17:25:26 -0300 (ADT) Received: from [157.92.155.58] (mailbis [157.92.155.58]) by mail.fmed.uba.ar (Postfix) with ESMTP id 88CDD10E175 for ; Tue, 30 Oct 2007 17:27:38 -0300 (ART) Message-ID: <47279757.50602@fmed.uba.ar> Date: Tue, 30 Oct 2007 17:43:03 -0300 From: Gerardo Herzig User-Agent: Mozilla Thunderbird 1.0.7 (X11/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: puzzled by SELECT INTO Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/149 X-Sequence-Number: 29521 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