隨筆-26  評論-13  文章-46  trackbacks-0

          In Oracle/PLSQL, the coalesce function returns the first non-null expression in the list. If all expressions evaluate to null, then the coalesce function will return null.

          The syntax for the coalesce function is:

          coalesce( expr1, expr2, ... expr_n )


          For Example:

          You could use the coalesce function in an SQL statement as follows:

          SELECT coalesce( address1, address2, address3 ) result
          FROM suppliers;


          The above coalesce statement is equivalent to the following IF-THEN-ELSE statement:

          IF address1 is not null THEN
          ???? result := address1;

          ELSIF address2 is not null THEN
          ??? result := address2;

          ELSIF address3 is not null THEN
          ??? result := address3;

          ELSE
          ??? result := null;

          END IF;


          The coalesce function will compare each value, one by one.

          posted on 2006-04-04 10:15 似水流年 閱讀(424) 評論(0)  編輯  收藏 所屬分類: Oracle
          主站蜘蛛池模板: 全南县| 黄山市| 墨江| 资兴市| 邮箱| 沙坪坝区| 隆子县| 绥芬河市| 山西省| 万山特区| 拉孜县| 佛山市| 遂宁市| 岳普湖县| 射阳县| 上栗县| 四平市| 乐平市| 河间市| 马公市| 谢通门县| 子洲县| 绍兴市| 阜南县| 三门峡市| 阜城县| 蒲江县| 安丘市| 柳林县| 蓬溪县| 疏勒县| 桂平市| 普陀区| 隆回县| 子洲县| 武清区| 闽清县| 禄丰县| 图木舒克市| 灌南县| 莒南县|