PL/pgSQL Function Help

From: "Niblett, David A" <niblettda(at)gru(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: PL/pgSQL Function Help
Date: 2005-12-16 20:14:57
Message-ID: 94FE9AAAB50C92448DCF1A4B99816F660284A3@GRUCLXCHGPR01.gruadmin.gru.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-general

I've got an issue with a plpgsql function and I have not
been able to find any reference to this situation in searching.
I hope that someone can point me in the correct direction.

I'm running v8.0.3 and assuming a test set up of:
-----------------------------
CREATE TYPE myrec AS (
id int
);

CREATE OR REPLACE FUNCTION test(x int) RETURNS myrec
AS '
DECLARE
output RECORD;
BEGIN
IF x THEN
RETURN NULL;
END IF;

SELECT INTO output 9999;
RETURN output;
END;
'
LANGUAGE plpgsql;
-----------------------------

Testing the function yields:
-----------------------------
xxx=# select * from test(0);
id
------
9999
(1 row)

xxx=# select * from test(1);
id
----

(1 row)
-----------------------------

My dilema is that the program I'm trying to write this
function for (not mine) expects that if (in this case) a
1 is sent, it should have zero rows returned (0 affected
rows). It seems that any time I have a return type of
a record I'll get a nice NULL record, but it still counts
as something.

Is there no way in Postgres that I can simply not return
anything so I show zero rows?

Thanks.

--
David

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2005-12-16 20:30:01 Re: PL/pgSQL Function Help
Previous Message Jaime Casanova 2005-12-16 20:00:00 Re: Configuring postgresql8.1.1

Browse pgsql-general by date

  From Date Subject
Next Message Madison Kelly 2005-12-16 20:19:44 Re: Getting a DB password to work without editing pg_hba.conf,
Previous Message Qingqing Zhou 2005-12-16 20:14:11 Re: Migration tool from MS SQL server 7.0