Re: How can I create null value from function call with no results?
От | Seref Arikan |
---|---|
Тема | Re: How can I create null value from function call with no results? |
Дата | |
Msg-id | CA+4ThdrghtXyxk=yCcUCGxA97dESrePU4FDrC0puk3Vu9q4O+g@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: How can I create null value from function call with no results? (David G Johnston <david.g.johnston@gmail.com>) |
Список | pgsql-general |
Hi David,
Thanks for the feedback. I've actually tried to do what you've suggested, but I always found myself unable to do the check for empty result for query in an elegant way.
That is, I end up thinking about creating a temp table to put the query results in (which can be > 1), then check if the temp table is empty and return Null if that is the case.
Your response reads as if there is a more elegant way of doing this, could you write down a dummy version of the alternative to return query you're suggesting? Thanks for the feedback. I've actually tried to do what you've suggested, but I always found myself unable to do the check for empty result for query in an elegant way.
That is, I end up thinking about creating a temp table to put the query results in (which can be > 1), then check if the temp table is empty and return Null if that is the case.
On Wed, Jul 30, 2014 at 7:26 PM, David G Johnston <david.g.johnston@gmail.com> wrote:
Seref Arikan wrote
> select 1,test_empty_row(1);
SELECT 1, (SELECT test_empty_row(1)) AS func_result
You can also adjust the function to either return the result of the query OR
"RETURN NULL" if no results were found. i.e., do not use "RETURN QUERY"
David J.
--
View this message in context: http://postgresql.1045698.n5.nabble.com/How-can-I-create-null-value-from-function-call-with-no-results-tp5813311p5813313.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
В списке pgsql-general по дате отправления: