在 Oracle 的一个 ExecuteScalar 中运行多个命令
我有一批sql语句,例如...
insert into...; 插入.... ; 删除 .........;
等
当我尝试针对oracle执行它们时,它给了我 this 错误(ORA-00911无效字符)
现在我可以理解这是因为语句之间的分号,我在 SQL Server 上尝试过并且它有效,但在 Oracle 中到目前为止还没有运气。
有没有办法通过使用 ExecuteScalar 或其他函数来针对 Oracle 运行多个语句?
I have a batch of sql statements such as ...
insert into.... ;
insert into.... ;
delete .........;
etc
When i try to execute them against oracle it gives me this error (ORA-00911 Invalid Character)
now i can understand that this is because of the semicolon between the statements, i tried this on SQL Server and it worked but in Oracle no luck so far.
Is there a way to run multiple statements against oracle by using the ExecuteScalar or some other function?
DUPLICATE: How can I execute multiple Oracle SQL statements with .NET
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试用
BEGIN..END
包装Try wrapping with a
BEGIN..END
尝试 BEGIN END 对我来说不起作用。
我所做的是创建一个新方法,给定一个连接(我尝试最小化我的打开连接),它使用 ; 分割语句。 作为分隔符并单独运行每个
我的灵感来自 这篇在Petros告诉我之后发布关于它
PS,您可能需要根据您的需要更改它,在我的情况下,我需要打开连接,并在调用者发生某些情况时相应地关闭连接。
trying the BEGIN END did not work for me.
What i did was make a new method that given a connection(i try to minimize my open connections) it splits the statements using the ; as a delimiter and runs each one seperatly
My inspiration came from this post after Petros told me about it
PS you may need to change it according to your needs, in my case i require the connection to be open, and closed accordingly if something happens from the caller.