ORACLE常用函式收藏

2021-08-22 16:07:01 字數 817 閱讀 6947

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必須是整數。

收藏PHP常用函式

收藏php常用函式 function getip else else fnum if fnum fnum 0 return fnum 去除html標記 function text2html txt isu rn txt return txt 相對路徑轉化成絕對路徑 function relative...

php 常用函式收藏(二)

讀取快取,預設為檔案快取,不載入快取配置。param string name 快取名稱 param filepath 資料路徑 模組名稱 caches cache filepath param string config 配置名稱 function getcacheinfo name,filepat...

MySQL常用函式(建議收藏)

一 數學函式 數學函式主要用於處理數字,包括整型 浮點數等。abs x 返回x的絕對值 select abs 1 返回1 ceil x ceiling x 返回大於或等於x的最小整數 select ceil 1.5 返回2 floor x 返回小於或等於x的最大整數 select floor 1.5...