如何从 WebMatrix 调用 Oracle 存储过程?
我正在尝试使用 Microsoft WebMatrix 中的 WebMatrix.Data 执行 Oracle 存储过程。我可以使用正常的 select 语句很好地获取数据...但我一生都无法弄清楚如何执行 Oracle 过程。据我所知,它不像 T-SQL 过程那样执行。请帮忙!
我正在尝试恢复单个值。我只是想证明我可以使用 webmatrix.data 访问 oracle 存储过程。这是一个查询,所以我不确定 db.Execute 是否有效,因为它适用于非查询。
这是代码:
CREATE OR REPLACE PROCEDURE COUNT_JOB_HISTORY
(
reccount OUT NUMBER
)
IS
BEGIN
SELECT COUNT(*) INTO reccount
FROM JOB_HISTORY;
END COUNT_JOB_HISTORY;
这是 .Net 代码
public static dynamic GetJobHistoryCount()
{
var db = Database.OpenConnectionString(connectionString, providerName);
var jobs = db.QueryValue("exec COUNT_JOB_HISTORY(:0)", "count");
return jobs;
}
它会爆炸为 ORA-00900:无效的 SQL 语句
谢谢!
I am trying to execute an oracle stored procedure using WebMatrix.Data from Microsoft's WebMatrix. I can get data just fine with normal select statements...but I can't for the life of me figure out how to execute an oracle proc. It's not executed like a T-SQL proc I know that. Please help!
I'm trying to get a single value back. I'm just trying to prove that I can access an oracle stored proc with webmatrix.data. It is a query so I'm not sure db.Execute would work since that is for non-queries.
here's the code:
CREATE OR REPLACE PROCEDURE COUNT_JOB_HISTORY
(
reccount OUT NUMBER
)
IS
BEGIN
SELECT COUNT(*) INTO reccount
FROM JOB_HISTORY;
END COUNT_JOB_HISTORY;
Here's the .Net code
public static dynamic GetJobHistoryCount()
{
var db = Database.OpenConnectionString(connectionString, providerName);
var jobs = db.QueryValue("exec COUNT_JOB_HISTORY(:0)", "count");
return jobs;
}
It blows up as an ORA-00900 : invalid SQL statement
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用
db.Execute()
(请参阅http://msdn.microsoft.com/en-us/library/webmatrix.data.database.execute%28v=vs.99%29.aspx)...关于过程本身以及处理参数/结果很难说,因为您没有提供足够的信息,例如
过程返回什么?一个值?一排?光标?
编辑-在OP显示存储过程之后:
每个存储过程都是“非查询”-WebMatrix不知道存储过程内部发生的事情......
我从未使用过 WebMatrix...所以这只是一个猜测:
或者也许
编辑2 - 另一次尝试:
you need to use
db.Execute()
(see http://msdn.microsoft.com/en-us/library/webmatrix.data.database.execute%28v=vs.99%29.aspx)...Regardings the procedure itself and dealing with params/result it is hard to tell because you did not provide enough information like
What exactly does the procedure return ? one value ? one row ? a cursor ?
EDIT- after the OP showed the Stored Procedure:
Every Stored Procedure is a "Non-Query" - WebMatrix does not know anything about what happens inside the Stored Procedure...
I never used WebMatrix... so this is only a guess:
or perhaps
EDIT 2 - another try: