From: | Gerardo Herzig <gherzig(at)fmed(dot)uba(dot)ar> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | puzzled by SELECT INTO |
Date: | 2007-10-30 20:43:03 |
Message-ID: | 47279757.50602@fmed.uba.ar |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Rodrigo De León | 2007-10-30 20:57:21 | Re: puzzled by SELECT INTO |
Previous Message | Fernando Hevia | 2007-10-30 20:42:18 | Perfomance benefit using Min() against order by & limit 1? |