简体   繁体   English

PLS-00201:必须声明标识符“ schema.cursorname”

[英]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. 我知道这里还有两个完全相同的问题,但是我100%肯定我没有任何类型的权限问题。 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. 该过程可以从查询编辑器中很好地执行,但是由于某种原因,我无法从一个非常简单的ASP.net页面执行此proc。 I should note this is my first attempt at creating an Oracle Proc. 我应该注意,这是我第一次创建Oracle Proc。

Here is my code that calls the proc (just trying to call it and force results into the label) 这是我的代码,调用proc(只是尝试调用它并将结果强制放入标签中)

    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 假设架构名称为X ,程序包名称为REJECTS_DATA ,过程名称为GETCURSORS ,则至少需要使用以下命令:

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. 如果您实际上在PL / SQL中使用区分大小写的标识符(强烈建议避免使用),则还需要在过程名称中使用区分大小写的标识符。

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. 我们在代码中遇到了相同的问题,因此不得不将SCHEMA_NAME排除在C#的proc调用之外,即PACKAGE_NAME.PROC_NAME。 We resolved this by creating a Synonym in the database with the SCHEMA_NAME 我们通过在数据库中使用SCHEMA_NAME创建同义词来解决了这一问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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