使用“Oracle.DataAccess”在 C# 中调用 Oracle 存储过程(带参数)
因此,我尝试从我的 C# .NET 应用程序调用 Oracle 存储过程。我能找到的大多数在线参考资料都建议“使用 System.Data.OracleClient;”,但 .Net 3.5 无法识别该命名空间,因此我使用“Oracle.DataAccess.Client”。
下面是我的代码的一些释义,之前设置和测试的名为“myConn”的 OracleConnection 已经填充了参数“:arg_myArg”(如果重要的话,它是一个数字):
command.Connection = myConn;
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "exec mySchema.myProc(:arg_myArg)"
command.ExecuteNonQuery();
诀窍是该过程按设计不返回任何内容,它只是填充了我从中提取的另一个表。但是,当我尝试运行上面的代码时,我在最后一行收到“OracleException”并给出此错误:
ORA-06550: line 1, column 13:
PLS-00103: Encountered the symbol "MYSCHEMA" when expecting one of the following:
:= . ( @ % ;
The symbol ":=" was substituted for "MYSCHEMA" to continue.
从命令中删除“exec”会出现此错误:
ORA-06550: line 1, column 8:
PLS-00801: internal error [22503]
ORA-06550: line 1, column 8:
PL/SQL: Statement ignored
有什么想法吗? I我很乐意澄清任何事情
这是我第一次在 stackoverflow.com 上发帖,也是我从事这份工作的最后一周,所以我感谢您的理解和相对仓促地解决这个问题
So I'm trying to call an Oracle stored procedure from my C# .NET application. Most online references I can find suggest "using System.Data.OracleClient;", but .Net 3.5 doesn't recognize that namespace so I'm using "Oracle.DataAccess.Client" instead.
Here's some paraphrasing of my code below, with a previously setup and tested OracleConnection called 'myConn' already filled with parameter ':arg_myArg' (it's a number, if that matters):
command.Connection = myConn;
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "exec mySchema.myProc(:arg_myArg)"
command.ExecuteNonQuery();
The trick is that the procedure returns nothing by design, it simply populates a different table which I pull from. However, when I try to run the code above, I get a 'OracleException' on the final line and gives this error:
ORA-06550: line 1, column 13:
PLS-00103: Encountered the symbol "MYSCHEMA" when expecting one of the following:
:= . ( @ % ;
The symbol ":=" was substituted for "MYSCHEMA" to continue.
Removing the "exec" from the command gives this error instead:
ORA-06550: line 1, column 8:
PLS-00801: internal error [22503]
ORA-06550: line 1, column 8:
PL/SQL: Statement ignored
Any ideas? I'd be happy to clarify anything
This is my first time posting on stackoverflow.com and my last week at this job, so I appreciate your understanding and relative haste with figuring this out
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你需要这样的东西
I think you need to something like this