Returning NULL results?

Поиск
Список
Период
Сортировка
От Mario Splivalo
Тема Returning NULL results?
Дата
Msg-id 1129040845.7911.9.camel@ekim
обсуждение исходный текст
Ответы Re: Returning NULL results?
Список pgsql-sql
_SQL := 'SELECT TmessageId FROM tmpBids WHERE TphoneNumber = ' || quote_literal(phoneNumber) || ' AND Tbid = ' ||
aBid;
FOR rec IN EXECUTE _SQL LOOP bidCount := rec._qv; END LOOP;

This works ok as long as the SELECT query returns rows. Of course, if it
returns multiple rows bidCount variable will hold just the last row
value, but the design of application is like that so the query from the
start returns only one row, or returns no rows.

Of course, if it returns no rows, I'm presented with an error, saying:

ERROR:  record "rec" has no field "_qv"

This is logical. My question would be is there a way around this
withouth first doing SELECT COUNT(*) FROM tmbBids WHERE ..., and then if
COUNT(*) is zero THEN bidCount := NULL ELSE if COUNT(*) is not zero then
do SELECT from the begining?
Mike
-- 
Mario Splivalo
Mob-Art
mario.splivalo@mobart.hr

"I can do it quick, I can do it cheap, I can do it well. Pick any two."




В списке pgsql-sql по дате отправления:

Предыдущее
От: Richard Huxton
Дата:
Сообщение: Re: Difference from average
Следующее
От: Tom Lane
Дата:
Сообщение: Re: ichar