VBS呼叫Stored Procedure(接Output參數值)
假設有一個Oracle Package Stored Procedure,相關架構如下,
名稱:Package1.StoredProcedure1
參數1:input,料號
參數2:output,成本
VBS可以透過下面的寫法取得Output參數的回傳值,
Reference Web:
http://docs.starquest.com/Supportdocs/techStarSQL/StarSQLODBC/Programming/SQ055_VBScript.shtml
http://stackoverflow.com/questions/10017872/calling-sql-stored-procedure-with-output-parameter-in-vbscript
名稱:Package1.StoredProcedure1
參數1:input,料號
參數2:output,成本
VBS可以透過下面的寫法取得Output參數的回傳值,
SET con = CreateObject("ADODB.Connection") con.Open DB_Connection_String strItemNo = "ABC00001" curItemCost = 0 SET cmd = CreateObject("ADODB.Command") cmd.CommandText = "Package1.StoredProcedure1" cmd.ActiveConnection = con cmd.NamedParameters = true cmd.CommandType = adCmdStoredProc cmd.Parameters.Append(cmd.CreateParameter("ItemNo", adVarChar, adParamInput, 50, strItemNo)) cmd.Parameters.Append(cmd.CreateParameter("ItemCost", adCurrency, adParamOutput, , curItemCost)) cmd.Execute msgbox "Item Cost: " & cmd.Parameters("ItemCost").Value
Reference Web:
http://docs.starquest.com/Supportdocs/techStarSQL/StarSQLODBC/Programming/SQ055_VBScript.shtml
http://stackoverflow.com/questions/10017872/calling-sql-stored-procedure-with-output-parameter-in-vbscript
留言
張貼留言