views:

122

answers:

2

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);
    }
+1  A: 

Do a SELECT * FROM USER_ERRORS and you should see what is being recorded as the error. There may be some odd characters creeping in..

PS. It seems odd to be creating procedures within an application.

Gary
Thanks for the reply. Odd yes, but still a requirement!<NewDataSet> <Table> <NAME>TABLE1_GET</NAME> <TYPE>PROCEDURE</TYPE> <SEQUENCE>1</SEQUENCE> <LINE>1</LINE> <POSITION>21</POSITION> <TEXT>PLS-00103: Encountered the symbol "" when expecting one of the following: ( ; is with authid as cluster compress order using compiled wrapped external deterministic parallel_enable pipelined</TEXT> <ATTRIBUTE>ERROR</ATTRIBUTE> <MESSAGE_NUMBER>103</MESSAGE_NUMBER> </Table></NewDataSet>
Bobcat1506
+1  A: 

The solution is:

cmd.CommandText = cmd.CommandText.Replace("\r\n", "\n");
Bobcat1506