隨筆-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
          主站蜘蛛池模板: 盘山县| 北流市| 临武县| 农安县| 乌兰浩特市| 建平县| 邻水| 体育| 安平县| 三门县| 南川市| 满洲里市| 潍坊市| 商河县| 德庆县| 肥东县| 拜泉县| 宝坻区| 景泰县| 南丹县| 莱芜市| 滨海县| 民丰县| 察哈| 万盛区| 陈巴尔虎旗| 兰溪市| 澎湖县| 吉安县| 财经| 丹阳市| 兴义市| 房产| 潜山县| 旺苍县| 曲松县| 三都| 张家口市| 宝山区| 贵溪市| 清丰县|