ORACLE常用函數收藏

1.substr

SUBSTR(string,start,count)

取子字符串,從start開始,取count個

2.to_number

 

例子

declare v_c number; v_pc varchar2(100); v_p number; begin select d.data_name into v_pc from data_dictionary d left join data_type t on d.data_type_id=t.data_type_id where d.data_type_id='0017' and d.status=1; v_c:=to_number(substr(v_pc,1,1)); v_p:=to_number(substr(v_pc,3,1)); dbms_output.put_line(v_c/(v_c+v_p)); end;

 

3.nvl

直接處理NULL值,NVL有兩個參數:NVL(x1,x2),x1和x2都式表達式,當x1爲null時返回X2,否則返回x1。

但是實際怎麼沒效果呢?比如:

 

select SUM(nvl(t.tc_fee,0))*v_datano into v_thirdcost from THIRD_COST T; if v_thirdcost is null then v_thirdcost:=0; end if;

 

 還是要判斷一下才行,奇怪?

4.round(,)

返回舍入小數點右邊n2位的n1的值,n2的缺省值爲0,這回將小數點最接近的整數,如果n2爲負數就舍入到小數點左邊相應的位上,n2必須是整數。

 

 

發佈了10 篇原創文章 · 獲贊 0 · 訪問量 6289
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章