使用输入和返回参数从 ASP VBSCRIPT 调用 oracle 存储过程
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3529668/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Call oracle stored procedure from ASP VBSCRIPT with input and returned parameters
提问by andreas777
I connect to an oracle database from an ASP-VBSCRIPT website and want to execute a stored procedure which accepts input parameters as well as returning some. The stored procedure is the following:
我从 ASP-VBSCRIPT 网站连接到一个 oracle 数据库,并希望执行一个接受输入参数并返回一些参数的存储过程。存储过程如下:
p_std_currency.get_currency_details(input1,input2,input3,input4,output1,output2)
Input 1-4 are the parameters (3rd is date) sent to the procedure whereas output1-2 are the fields/items to where the returned parameters are sent. I have tried to adjust the above into following ASP VBsript with no success:
输入 1-4 是发送到过程的参数(第三个是日期),而输出 1-2 是返回参数发送到的字段/项目。我试图将上述内容调整为以下 ASP VBsript,但没有成功:
Set oConn_send = Server.CreateObject ( "ADODB.Connection" )
sConnectString_send = "Provider=MSDAORA.1;Data Source=demodbas;User Id=user Password=pas;"
oConn_send.Open sConnectString_send
oConn_send.ActiveConnection = oConn_send
oConn_send.CommandType = adCmdStoredProc
oConn_send.Properties("PLSQLRSet") = TRUE
oConn_send.CommandText = "p_std_currency.get_currency_details"
oConn_send.Parameters.Append oConn_send.CreateParameter(9,10,"01-JAN-10",1,crate_value,crate_id_no)
Set objSearch = oConn_send.Execute
Response.Write crate_value
Response.Write crate_id_no
Any ideas? Thanks.
有任何想法吗?谢谢。
回答by andreas777
I can see at least these three problems:
我至少可以看到这三个问题:
You must call
CreateParameter
once per parameter, i.e. 6 times.You must use
ADODB.Command
, notADODB.Connection
, to send the command.The output parameters can be retrieved using
cmd.Parameters(0)
andcmd.Parameters(1)
.
CreateParameter
每个参数必须调用一次,即 6 次。您必须使用
ADODB.Command
,而不是ADODB.Connection
来发送命令。可以使用
cmd.Parameters(0)
和检索输出参数cmd.Parameters(1)
。
I recommend to have a look at this example: http://support.microsoft.com/kb/164485/en-us. It is for SQL Server, but should also work with Oracle.
我建议看看这个例子:http: //support.microsoft.com/kb/164485/en-us。它适用于 SQL Server,但也适用于 Oracle。