简体   繁体   中英

PLS-00201: identifier 'schema.cursorname' must be declared

I know there are a couple of other questions on here with the exact same issue, but I am 100% positive I don't have any type of permissions issue. The procedure executes fine from the query editor, but for some reason I can't get this proc to execute from a very simple ASP.net page. I should note this is my first attempt at creating an Oracle Proc.

Here is my code that calls the proc (just trying to call it and force results into the label)

    string oradb = "connection string here";

    OracleConnection conn = new OracleConnection(oradb);

    OracleCommand cmd = new OracleCommand();
    cmd.Connection = conn;
    cmd.CommandText = "x.GETCURSORS";
    cmd.CommandType = CommandType.StoredProcedure;

    OracleParameter ACTNUM = new OracleParameter();
    ACTNUM.OracleDbType = OracleDbType.Decimal;
    ACTNUM.Direction = ParameterDirection.Input;
    ACTNUM.Value ="12345";
    cmd.Parameters.Add(ACTNUM);

    OracleParameter REJECTS_C = new OracleParameter();
    REJECTS_C.OracleDbType = OracleDbType.RefCursor;
    REJECTS_C.Direction = ParameterDirection.Output;
    cmd.Parameters.Add(REJECTS_C);


    try
    {
        conn.Open();
        OracleDataReader objReader = cmd.ExecuteReader();
        Label3.Text = objReader.ToString();
    }
    catch (Exception ex)
    {
        Label3.Text = string.Format("Exception: {0}", ex.ToString());

    }

Package specification:

PACKAGE "x"."REJECTS_DATA" IS

PROCEDURE "GETCURSORS" (
"ACTNUM" IN NUMBER, 
"REJECTS_C" OUT SYS_REFCURSOR);

 END "REJECTS_DATA";

Package body:

PACKAGE BODY "x"."REJECTS_DATA" IS

PROCEDURE "GETCURSORS" (
"ACTNUM" IN NUMBER, 
"REJECTS_C" OUT SYS_REFCURSOR) IS

BEGIN

OPEN REJECTS_C FOR SELECT * FROM x.a
WHERE  x.a.ACCOUNT = ACTNUM;

END "GETCURSORS";

END "REJECTS_DATA";

Assuming that the schema name is X , the package name is REJECTS_DATA , and the procedure name is GETCURSORS , at a minimum, the command would need to be

cmd.CommandText = "x.REJECTS_DATA.GETCURSORS";

If you are actually using case-sensitive identifers in PL/SQL (which I would strongly suggest avoiding), you would need to use case-sensitive identifiers in the procedure name as well.

We faced the same issue in our code and had to keep SCHEMA_NAME out of our proc call in C#, ie PACKAGE_NAME.PROC_NAME. We resolved this by creating a Synonym in the database with the SCHEMA_NAME

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM