Fungsi PostgreSQL yang sama dengan NVL milik Oracle

Bagi anda yang sering berkutat dengan Oracle, pasti sering membutuhkan fungsi NVL dalam operasi query. NVL sangat berguna untuk operasi view data. Sayangnya fungsi ini tidak ada di PostgreSQL (atau saya yang tidak tahu?). Setelah berpusing-pusing ria dengan manual PostgreSQL, akhirnya saya menemukan satu fungsi yang memiliki perilaku sama. Yaitu fungsi COALESCE.
Deskripsi dari manual adalah sebagai berikut :

The COALESCE function returns the first of its arguments that is not null. Null is returned only if all arguments are null. It is often used to substitute a default value for null values when data is retrieved for display, for example:

SELECT COALESCE(description, short_description, '(none)') ...

Like a CASE expression, COALESCE will not evaluate arguments that are not needed to determine the result; that is, arguments to the right of the first non-null argument are not evaluated. This SQL-standard function provides capabilities similar to NVL and IFNULL, which are used in some other database systems.

  • Arief Bayu Purwanto

    #1 : kekekekekeke, tapi gue juga ga’ ngerti algoritma game <img src='http://bayu.blogsome.com/wp-images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> . Jadi 1 sama deh hehehe

  • L_O_J

    sumpeh kagak ngerti SQL, NVL, …. apa itu ya ??? kalo functor ngerti gak ??? ;D. hahaha harus belajar nih keknya, duit IT ada di Database sih :p

blog comments powered by Disqus