Re: need help to write a function in postgresql

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/03/2012 04:37 PM, Laszlo Nagy wrote:
It is also better because with a view, you can also do " name is null ". But you cannot do that with a function (unless you write unnecessary circumstancial code.)

While I agree with you on the view - among other things, it lets the query optimiser push conditions down into the view query - there is a reasonable answer to the problem of comparing to NULL. Just use IS DISTINCT FROM, eg:

   WHERE name IS DISTINCT FROM _test_variable

"IS DISTINCT FROM" is an equality comparison that treats null as a comparable value like any other, so "NULL IS DISTINCT FROM NULL" is false. Very handy.

--
Craig Ringer

--
Sent via pgsql-admin mailing list (pgsql-admin@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux