本文介绍了ODP.NET程序的编写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试使用ODP.NET我回去ORA-24344执行创建过程:在编译错误的成功。然而,当我在SQL Developer中运行相同的声明中编译成功。有谁知道我需要改变让我的步骤来编译?它是一个字符集问题?
我使用Oracle 10g防爆preSS,.NET 3.5 SP 1和ODP.NET 2.111.7.20(版本从Oracle.DataAccess.dll)
[TestMethod的]
公共无效OdpNet_CreateProcedure()
{
ConnectionStringSettings设置= ConfigurationManager.ConnectionStrings [ODP.NET];
使用(VAR CON =新的OracleConnection(settings.ConnectionString))
{
con.InfoMessage + =新OracleInfoMessageEventHandler(con_InfoMessage);
con.Open();
VAR CMD =新的OracleCommand();
cmd.Connection = CON;
cmd.CommandText = @
CREATE OR REPLACE PROCEDURE TABLE1_GET
(
P_CURSOR OUT SYS_REFCURSOR
)
IS
开始
OPEN FOR P_CURSOR
选择 *
FROM表1;
结束;;
cmd.ExecuteNonQuery(); // ORA-24344:成功编译错误
cmd.CommandText = @ALTER PROCEDURE TABLE1_GET纂;
cmd.ExecuteNonQuery(); // ORA-24344:成功编译错误
}
}
无效con_InfoMessage(对象发件人,EventArgs的OracleInfoMessageEventArgs)
{
System.Diagnostics.Debug.WriteLine(eventArgs.Message);
}
解决方案
解决的办法是:
cmd.CommandText = cmd.CommandText.Replace(\ r \ N,\ N);
When I try to execute a create procedure using ODP.NET I get back ORA-24344: success with compilation error. However, when I run the same statement in SQL Developer it compiles successfully. Does anyone know what I need to change to get my procedure to compile? Is it a character set issue?
I am using Oracle 10g Express, .NET 3.5 SP 1, and ODP.NET 2.111.7.20 (version from Oracle.DataAccess.dll)
[TestMethod]
public void OdpNet_CreateProcedure()
{
ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["ODP.NET"];
using (var con = new OracleConnection(settings.ConnectionString))
{
con.InfoMessage += new OracleInfoMessageEventHandler(con_InfoMessage);
con.Open();
var cmd = new OracleCommand();
cmd.Connection = con;
cmd.CommandText = @"
CREATE OR REPLACE PROCEDURE TABLE1_GET
(
P_CURSOR OUT SYS_REFCURSOR
)
IS
BEGIN
OPEN P_CURSOR FOR
SELECT *
FROM TABLE1;
END;";
cmd.ExecuteNonQuery(); // ORA-24344: success with compilation error
cmd.CommandText = @"ALTER PROCEDURE TABLE1_GET COMPILE";
cmd.ExecuteNonQuery(); // ORA-24344: success with compilation error
}
}
void con_InfoMessage(object sender, OracleInfoMessageEventArgs eventArgs)
{
System.Diagnostics.Debug.WriteLine(eventArgs.Message);
}
解决方案
The solution is:
cmd.CommandText = cmd.CommandText.Replace("\r\n", "\n");
这篇关于ODP.NET程序的编写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!