Oracle 函式(function)學習

2021-09-29 02:47:48 字數 1379 閱讀 3488

create[or

replace

]function 函式名

([p1,p2.

..pn]

)return datatypeis|

as--宣告部分

begin

--pl/sql程式塊

end

語法解析:

1、function 是建立函式的關鍵字。

2、p1,p2...pn是函式的入參,oracle建立的函式也可以不需要入參。

3、return datatype:是函式的返回值的型別。

4、通過is承接著pl/sql程式塊。這部分是函式的計算內容。

案例:

create

orreplace

function getcnmonth(calmonth varchar2)

return varchar2

as v_calmonth varchar2(15)

;begin

select

case calmonth

when

'01'

then

'1月份'

when

'02'

then

'2月份'

when

'03'

then

'3月份'

when

'04'

then

'4月份'

when

'05'

then

'5月份'

when

'06'

then

'6月份'

when

'07'

then

'7月份'

when

'08'

then

'8月份'

when

'09'

then

'9月份'

when

'10'

then

'10月份'

when

'11'

then

'11月份'

else

'12月份'

endinto v_calmonth

from dual;

return v_calmonth;

end;

結果如下:

select getcnmonth(

'01'

)from dual;

---------

'1月份'

ECMAScript中函式function型別

說起來ecmascript中上面最有意思,我想那莫過於函式了,有意思的根源,則在於函式實際上是物件。每個函式都是function型別的例項,而且都與其他引用型別一樣具有屬性和方法。由於函式是物件,因此函式名實際上也是乙個指向函式物件的指標,不會與某個函式繫結。函式通常是使用函式宣告語法定義的,如下例...

JCo3 呼叫簡單SAP函式(Function)

本文闡述如何使用jco呼叫簡單sap函式。1.建立一sap使用者 test01 關於如何建立使用者,請參考我上一部落格 jco3 建立連線到sap 1 直接連線 2.編寫 3.編譯 4.執行 執行結果 本例呼叫sap function stfc connection 然後使用得到importpara...

js作用域小記var變數和function區別

首先來乙個例子做實驗 function created return dir function myctrl var yourctrl function var d created d.ctrl d.ctrl2 可以猜一下輸出結果 輸出 d.ctrl 輸出 my ctrld.ctrl2 輸出 unc...