Re: [SQL] Testing for null record in plpgsql

2008-04-11 Thread Erik Jones
Pavel & Craig, I'm replying to both of you to save some time :) All I was really trying to demonstrate was the need to be able to distinguish a completely null record from one that isn't. I can see by both of your responses that by incorporating that in a dummy example I inadvertently adde

Re: [SQL] Testing for null record in plpgsql

2008-04-11 Thread Pavel Stehule
Hello maybe CREATE OR REPLACE FUNCTION returns_empty_set_maybe() RETURNS SETOF foo AS $$ res integer; aux foo; BEGIN SELECT INTO res extract('month' from now()::integer % 2; IF res <> 0 THEN aux = (5,5); RETURN NEXT aux; END IF;

Re: [SQL] Testing for null record in plpgsql

2008-04-11 Thread Craig Ringer
Erik Jones wrote: Now, let's say I want to call this from another function and test the result to see if I have a null record (null, null),. I've got the following working but it feels like there should be something much simpler but I just can't seem to hit on it. Is this it? I'm assuming tha

[SQL] Testing for null record in plpgsql

2008-04-10 Thread Erik Jones
Ok, let's say I have the following: CREATE TABLE foo ( val1 integer, val2 integer ); CREATE OR REPLACE FUNCTION returns_null_maybe() RETURNS foo AS $$ DECLARE res integer; BEGIN SELECT INTO res extract('month' from now()::integer % 2; IF r