pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedSet Returning Function problem
2+ messages / 2 participants
[nested] [flat]
* Set Returning Function problem
@ 2004-12-06 18:06 Alvaro Nunes Melo <al_nunes@atua.com.br>
2004-12-06 18:47 ` Re: Set Returning Function problem Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 2+ messages in thread
From: Alvaro Nunes Melo @ 2004-12-06 18:06 UTC (permalink / raw)
To: pgsql-sql
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 |
+---------------------------------------------------+
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Set Returning Function problem
2004-12-06 18:06 Set Returning Function problem Alvaro Nunes Melo <al_nunes@atua.com.br>
@ 2004-12-06 18:47 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 2004-12-06 18:47 UTC (permalink / raw)
To: Alvaro Nunes Melo <al_nunes@atua.com.br>; +Cc: pgsql-sql
Alvaro Nunes Melo <al_nunes@atua.com.br> writes:
> 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.
Why would you think that? The behavior is exactly right as-is.
regards, tom lane
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2004-12-06 18:47 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-12-06 18:06 Set Returning Function problem Alvaro Nunes Melo <al_nunes@atua.com.br>
2004-12-06 18:47 ` Tom Lane <tgl@sss.pgh.pa.us>
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