隨筆-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 似水流年 閱讀(419) 評論(0)  編輯  收藏 所屬分類: Oracle
          主站蜘蛛池模板: 廉江市| 星座| 遵义市| 施秉县| 无为县| 湟中县| 平利县| 五家渠市| 黄龙县| 关岭| 祁东县| 广丰县| 南开区| 渭源县| 峡江县| 包头市| 潼南县| 磐安县| 揭阳市| 焉耆| 西青区| 嘉善县| 泾阳县| 西城区| 长汀县| 盐亭县| 古浪县| 介休市| 平湖市| 上虞市| 新乡县| 北碚区| 安岳县| 双牌县| 樟树市| 通辽市| 博乐市| 思茅市| 盱眙县| 尼勒克县| 香格里拉县|