如何接到oracle procedure的out參數,
因為asp有點小冷門,每次要找資料都很辛苦,
既然試出來,就簡單分享。

**

<%
Dim OraSession
Dim OraDatabase

prod_db_name=”test_db”
prodConn_str =”scott/tiger”

Set OraSession = CreateObject("OracleInProcServer.XOraSession")
Set OraDatabase = OraSession.OpenDatabase(prod_db_name, prodConn_str ,0)

conn.beginTrans
v_return = getReturn( a, b, c,OraDatabase)
response.write v_return

conn.commitTrans


function getReturn( a, b, c, ByRef OraDatabase)
'ServerType
'ORATYPE_VARCHAR2 1 VARCHAR2
'ORATYPE_NUMBER 2 NUMBER
'ORATYPE_DATE 12 DATE

'OraDatabase.Parameters.Add name,value,type(1是input,2是output)
OraDatabase.Parameters.Add "a", a, 1
OraDatabase.Parameters("a").ServerType = 2
OraDatabase.Parameters.Add "b", b, 1
OraDatabase.Parameters("b").ServerType = 1
OraDatabase.Parameters.Add "c", c, 1
OraDatabase.Parameters("c").ServerType = 2

'result:out parameter
OraDatabase.Parameters.Add "result", "", 2
OraDatabase.Parameters("result").ServerType = 1

'XX_Procedure(v_a number,v_b varchar2,v_c number,v_err out varchar2)
sql =""
sql = sql & " begin "
sql = sql & " XX_Procedure"
sql = sql & " (:a,:b,:c ,:result); "
sql = sql & " end; "
OraDatabase.ExecuteSQL(sql)
getReturn = OraDatabase.Parameters("result").Value

'清掉變數
For i=0 To OraDatabase.Parameters.Count-1
OraDatabase.Parameters.Remove 0
Next

End Function
%>
創作者介紹
創作者 amy70016 的頭像
amy70016

黑心小兔的金玉良言

amy70016 發表在 痞客邦 留言(0) 人氣()