Skip site navigation (1) Skip section navigation (2)

Re: PL/pgSQL question

From: "Milen A(dot) Radev" <milen(at)radev(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: PL/pgSQL question
Date: 2008-02-14 13:50:13
Message-ID: fp1guu$6co$1@ger.gmane.org (view raw or flat)
Thread:
Lists: 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


In response to

pgsql-sql by date

Next:From: Dean Gibson (DB Administrator)Date: 2008-02-14 23:08:20
Subject: FUNCTIONs and CASTs
Previous:From: Sebastian RitterDate: 2008-02-14 13:23:33
Subject: PL/pgSQL question

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group