Re: Testing for null record in plpgsql

Поиск
Список
Период
Сортировка
От Craig Ringer
Тема Re: Testing for null record in plpgsql
Дата
Msg-id 47FF1605.8050301@postnewspapers.com.au
обсуждение исходный текст
Ответ на Testing for null record in plpgsql  (Erik Jones <erik@myemma.com>)
Ответы Re: Testing for null record in plpgsql  (Erik Jones <erik@myemma.com>)
Список pgsql-sql
Erik Jones wrote:
> Now, let's say I want to call this from another function and test the 
> result to see if I have a null record (null, null),.  I've got the 
> following working but it feels like there should be something much 
> simpler but I just can't seem to hit on it.  Is this it?
I'm assuming that returns_null_maybe() is  a dummy to show general 
behavior. I can't imagine why you'd ever want to do what it's doing.

In general I'm suspicious of code that's testing for a real, known value 
and returning NULL in its place. It seems like an odd thing to do. 
Still, I'm sure you have your reasons and they probably make sense in 
the real application rather than the simplified example.

You can tidy test_null_rec a little by just using:

RETURN row(res.*) IS DISTINCT FROM row(null_rec.*);

but otherwise, without incorporating it into the containing query as a 
subquery I don't see much to be done. I'm still curious about the 
purpose of using null values like this is, though.

--
Craig Ringer


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

Предыдущее
От: Erik Jones
Дата:
Сообщение: Testing for null record in plpgsql
Следующее
От: "Pavel Stehule"
Дата:
Сообщение: Re: Testing for null record in plpgsql