Compiling the ODP.NET Procedure

When I try to complete the creation procedure using ODP.NET, I return to ORA-24344: success with a compilation error. However, when I run the same statement in SQL Developer, it compiles successfully. Does anyone know what I need to change in order to compile my procedure? Is this a character set problem?

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);
    }
+3
source share
2 answers

Decision:

cmd.CommandText = cmd.CommandText.Replace("\r\n", "\n");
+5
source

Make SELECT * FROM USER_ERRORS and you should see what is written as an error. There may be some odd characters creeping in.

PS. .

+1

Source: https://habr.com/ru/post/1744062/


All Articles