Re: Providing an alternative result when there is no result
В списке pgsql-general по дате отправления:
| От | David Fetter |
|---|---|
| Тема | Re: Providing an alternative result when there is no result |
| Дата | |
| Msg-id | 20090519130811.GC7537@fetter.org обсуждение исходный текст |
| Ответ на | Providing an alternative result when there is no result (Joshua Berry <yoberi@gmail.com>) |
| Список | pgsql-general |
On Mon, May 18, 2009 at 03:13:56PM -0400, Joshua Berry wrote: > Hello all, > > Is there an easy and efficient way to return a boolean false for a query > that returns no result, and true for one that does return a result? > > Currently we select the result into a temp table. > > SELECT INTO temp_table id FROM ... ; > IF temp_table IS NULL THEN > resp:= 'NO'; > ELSE > resp:= 'YES'; > END IF; SELECT EXISTS (SELECT 1 FROM ....); will get you a boolean which can't be NULL. You can either map that to "yes/no" or return it as is. Hope this helps :) Cheers, David. -- David Fetter <david@fetter.org> http://fetter.org/ Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter Skype: davidfetter XMPP: david.fetter@gmail.com Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера