From: | Alvaro Nunes Melo <al_nunes(at)atua(dot)com(dot)br> |
---|---|
To: | PostgreSQL - SQL <pgsql-sql(at)postgresql(dot)org> |
Subject: | Set Returning Function problem |
Date: | 2004-12-06 18:06:44 |
Message-ID: | 1102356404.7459.10.camel@localhost |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)atua(dot)com(dot)br www.atua.com.br |
| UIN - 42722678 (54) 327-1044 |
+---------------------------------------------------+
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2004-12-06 18:47:00 | Re: Set Returning Function problem |
Previous Message | pgsql-sql | 2004-12-06 17:35:39 | Making dirty reads possible? |