Oracle 存储过程中的 ASP.NET 数据集
我从这个网站上阅读了很多问题和文章。 然而,我厌倦了寻找我想要操纵的东西。 在 SQL Server 中,我曾经调用类似“EXEC Some_Procedure_name arg1, 'arg2', arg3, 'arg4'”的过程。 当输入参数为数字时,我不会使用单引号。 但是在oracle中,我真的需要写一些像使用输入和输出参数这样的东西吗? 假设程序如下:
CREATE OR REPLACE PROCEDURE GET_JOB
(
p_JOB_ID IN varchar2,
outCursor OUT MYGEN.sqlcur
)
IS
BEGIN
OPEN outCursor FOR
SELECT *
FROM JOB
WHERE JOB_ID = p_JOB_ID;
END GET_JOB;
/
那么我必须在我的 C# 代码中指定输入参数名称,如下所示:
var userNameParameter = command.Parameters.Add("p_JOB_ID", Job_ID);
returnValueParameter.Direction = ParameterDirection.In;
我不能像“执行 GET_JOB 'j208';”那样调用它吗?
I have read so many questions and articles from this web site.
However I am getting tired of looking for something I want to manipulate.
In SQL Server, I used to call procedures like "EXEC Some_Procedure_name arg1, 'arg2', arg3, 'arg4'".
When input parameters are in numeric, I woudn't use sing quotation.
But in oracle, do I really need to write something like using Input and Output parameters?
Let's say that the procedure is below:
CREATE OR REPLACE PROCEDURE GET_JOB
(
p_JOB_ID IN varchar2,
outCursor OUT MYGEN.sqlcur
)
IS
BEGIN
OPEN outCursor FOR
SELECT *
FROM JOB
WHERE JOB_ID = p_JOB_ID;
END GET_JOB;
/
Then I must specify the name of input parameter's name in my c# code like below:
var userNameParameter = command.Parameters.Add("p_JOB_ID", Job_ID);
returnValueParameter.Direction = ParameterDirection.In;
Can't I just call it like "Execute GET_JOB 'j208';"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要从 Oracle 中的存储过程返回数据集,您需要使用“REF CURSOR”。
此处使用 .NET 的代码示例详细解释了这一点:
http://www.oracle.com/technetwork/articles/dotnet/williams-refcursors-092375.html
To return datasets from a stored procedure in Oracle, you need to use a "REF CURSOR".
This is explained in detail, with code examples for .NET, here:
http://www.oracle.com/technetwork/articles/dotnet/williams-refcursors-092375.html