Re: PL/pgSQL question - Mailing list pgsql-sql

From Milen A. Radev
Subject Re: PL/pgSQL question
Date
Msg-id fp1guu$6co$1@ger.gmane.org
Whole thread Raw
In response to PL/pgSQL question  ("Sebastian Ritter" <ritter.sebastian@gmail.com>)
List pgsql-sql
Sebastian Ritter написа:
> Hi all,
> 
> I have a question regarding functions.  How can I return zero rows from a
> function whose return type is a table row?  I did the following test and it
> did not work as expected:
[...]


CREATE OR REPLACE FUNCTION foobar(boolean) RETURNS SETOF x AS $_$
DECLARE    res x%ROWTYPE;
BEGIN
    if $1 THEN        RETURN NEXT res;    ELSE        RETURN;    END IF;
END;$_$

LANGUAGE plpgsql;



-- 
Milen A. Radev



pgsql-sql by date:

Previous
From: "Sebastian Ritter"
Date:
Subject: PL/pgSQL question
Next
From: "Dean Gibson (DB Administrator)"
Date:
Subject: FUNCTIONs and CASTs