pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Nunes Melo <al_nunes@atua.com.br>
To: PostgreSQL - SQL <pgsql-sql@postgresql.org>
Subject: Set Returning Function problem
Date: Mon, 06 Dec 2004 16:06:44 -0200
Message-ID: <1102356404.7459.10.camel@localhost> (raw)

Hi, 

I noticed what i think is a weird behaviour with SRFs. When I use them
in a SELECT clause, and the SRF returns no rows, the query returns no
rows too, when I think it should return an a null column. I'm posting an
example below:


test=> CREATE TABLE foo (cod SERIAL, bar TEXT);
NOTICE:  CREATE TABLE will create implicit sequence "foo_cod_seq" for
"serial" column "foo.cod"
CREATE TABLE

test=> 
test=> INSERT INTO foo (bar) VALUES ('asdasd');
INSERT 60702758 1

test=> CREATE OR REPLACE FUNCTION srf_foo(INTEGER)
test-> RETURNS setof foo
test-> AS '
test'>   SELECT * FROM foo WHERE cod = $1;
test'> ' LANGUAGE 'SQL';
CREATE FUNCTION

test=> 
test=> SELECT cod, (srf_foo(cod)).bar
test-> FROM foo;
 cod |  bar   
-----+--------
   1 | asdasd
(1 record)

test=>
test=> SELECT cod, (srf_foo(50)).bar
test-> FROM foo;
 cod | bar
-----+-----
(0 records)

Thanks in advance,

-- 
+---------------------------------------------------+
|  Alvaro Nunes Melo    Atua Sistemas de Informacao |
| al_nunes@atua.com.br        www.atua.com.br       |
|    UIN - 42722678            (54) 327-1044        |
+---------------------------------------------------+




view thread (2+ messages)  latest in thread

Message-ID: <1102356404.7459.10.camel@localhost>
Permalink:  ../1102356404.7459.10.camel@localhost/
Also on:    postgresql.org/message-id/1102356404.7459.10.camel@localhost

 · 

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: al_nunes@atua.com.br
  Subject: Re: Set Returning Function problem
  In-Reply-To: <1102356404.7459.10.camel@localhost>

* 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