From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Cc: | Tomas Macek <macek(at)fortech(dot)cz> |
Subject: | Re: how to return 0 rows in function |
Date: | 2007-05-18 09:04:36 |
Message-ID: | 200705181104.36560.peter_e@gmx.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Am Freitag, 18. Mai 2007 10:20 schrieb Tomas Macek:
> ----------------
> CREATE OR REPLACE FUNCTION f(varchar) RETURNS varchar AS $FUNC$
> DECLARE
> addr ALIAS FOR $1;
> BEGIN
> -- return NULL;
> -- return '';
> END
> $FUNC$ LANGUAGE 'plpgsql';
> -----------------
>
> This function is returning varchar and it always returns at least one row.
> How can I make it to return 0 rows? Is it possible or not and how?
Your function is returning a scalar value, not rows. If you want it to return
0 rows, the first change should be to make it return rows at all, by
declaring the return type to be, say, SETOF varchar. Then you can return no
rows by doing something like SELECT '' WHERE false;.
--
Peter Eisentraut
http://developer.postgresql.org/~petere/
From | Date | Subject | |
---|---|---|---|
Next Message | Marco Colombo | 2007-05-18 09:20:29 | Re: a few questions on backup |
Previous Message | Richard Huxton | 2007-05-18 08:56:59 | Re: how to return 0 rows in function |