PLS-00302:告诉我我的存储过程没有声明

时间:2010-05-14 13:48:21

标签: c# asp.net oracle plsql ora-06550

这是堆栈中发生错误的地方:

public static IKSList<DataParameter> Search(int categoryID, int departmentID, string title)
        {
            Database db = new Database(DatabaseConfig.CommonConnString, DatabaseConfig.CommonSchemaOwner, "pkg_data_params_new", "spdata_params_search");
            db.AddParameter("category_id", categoryID);
            db.AddParameter("department_id", departmentID);
            db.AddParameter("title", title, title.Length);

            DataView temp = db.Execute_DataView();

            IKSList<DataParameter> dps = new IKSList<DataParameter>();

            foreach (DataRow dr in temp.Table.Rows)
            {
                DataParameter dp = new DataParameter();
                dp.Load(dr);
                dps.Add(dp);
            }

            return dps;
        }

这是错误文本:

ORA-06550: line 1, column 38:
PLS-00302: component 'SPDATA_PARAMS_SEARCH' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
  

描述:执行期间发生了未处理的异常   当前的网络请求。请查看堆栈跟踪了解更多信息   有关错误的信息以及它在代码中的起源。

     

异常详细信息:System.Data.OracleClient.OracleException:   ORA-06550:第1行,第38列:PLS-00302:组分   'SPDATA_PARAMS_SEARCH'必须声明为ORA-06550:第1行第7列:   PL / SQL:忽略语句

来源错误:

Line 161:            db.AddParameter("title", title, title.Length);
Line 162:
Line 163:            DataView temp = db.Execute_DataView();
Line 164:
Line 165:            IKSList<DataParameter> dps = new IKSList<DataParameter>();

我的web.config指向正确的位置和所有内容,所以我不知道它来自哪里。

2 个答案:

答案 0 :(得分:2)

首先确保调用该过程的用户对该过程具有执行权限,其次确保调用该过程的用户可以直接使用schemaname.procedurename或synonymname.procedure name查看该过程,同义词可以是公共或私人。

希望有所帮助

答案 1 :(得分:0)

janbo的回答是现实,给他一个upvote。这是一个放入数据库部署的脚本,以确保不再发生这种情况:

  

sqlplus @ CreateSynonyms.sql

-- CreateSynonyms.sql : Creates synonyms on XYZ_USER for all packages that don't already have synonyms

spool CreateSynonyms.log

DECLARE
  owner        VARCHAR2(20) := 'XYZ';
  currentUser  VARCHAR2(20);
  executeLine  VARCHAR2(200);
BEGIN
  -- Get the user we're currently executing as
  SELECT sys_context('USERENV', 'SESSION_USER') INTO currentUser FROM dual;

  FOR x IN (SELECT p.table_name FROM user_tab_privs p
              WHERE p.owner = owner
                AND p.privilege = 'EXECUTE'
                AND p.table_name NOT IN (
                  SELECT table_name FROM user_synonyms
                    WHERE table_owner = owner
                )
            ) LOOP
    executeLine := 'CREATE OR REPLACE SYNONYM ' || x.table_name || ' FOR ' || owner || '.' || x.table_name;
    DBMS_OUTPUT.PUT_LINE(executeLine);
    EXECUTE IMMEDIATE executeLine;
  END LOOP;
END;
/   
spool off