pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gerardo Herzig <gherzig@fmed.uba.ar>
To: pgsql-sql@postgresql.org
Subject: puzzled by SELECT INTO
Date: Tue, 30 Oct 2007 17:43:03 -0300
Message-ID: <47279757.50602@fmed.uba.ar> (raw)

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



view thread (3+ messages)  latest in thread

Message-ID: <47279757.50602@fmed.uba.ar>
Permalink:  ../47279757.50602@fmed.uba.ar/
Also on:    postgresql.org/message-id/47279757.50602@fmed.uba.ar

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: gherzig@fmed.uba.ar
  Subject: Re: puzzled by SELECT INTO
  In-Reply-To: <47279757.50602@fmed.uba.ar>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox