必须声明PLS-00201标识符"PACKAGENAME.PROCEDURENAME" [英] PLS-00201 identifier 'PACKAGENAME.PROCEDURENAME' must be declared

查看:238
本文介绍了必须声明PLS-00201标识符"PACKAGENAME.PROCEDURENAME"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iam在聊天系统的后端工作,使用了Django服务器. 我在SQL-Developer中为Oracle数据库编写了一个过程,该过程应将最新消息提供给端点.当我在SQL-Developer中运行过程时,它运行顺利.但是,如果我在端点中运行过程",则会出现以下错误消息:

iam working on the Backend of a Chat System, used whit Django Server. I wrote an procedure in SQL-Developer for the Oracle Database, which should provide the recent messages to an endpoint. When i run the Procedure in SQL-Developer it goes smoothly. But if i run the Procedure in the endpoint, there is following Error-Message:

b'{"ERROR_NO": 6550, "ERROR_MSG": "ORA-06550: line 1, column 7:\\nPLS-00201: identifier \'P_CHAT.GET_MESSAGES\' must be declared\\nORA-06550: line 1, column 7:\\nPL/SQL: Statement ignored\\n"}'

Views.py

    #getmessage
@need_get_parameters([PARAM_SENDING_USER_ID, PARAM_LAST_ID])
def get(self, request, *args, **kwargs):
    uid = request.GET.get(PARAM_SENDING_USER_ID)
    last_id = request.GET.get(PARAM_LAST_ID)

    #ToDo validate Data
    try:
        params = {"i_lastId": last_id}
        results = db_execute_procedure_ajax_response("p_chat.get_messages", params, uid)
        return HttpResponse(json.dumps(results))

    except Exception as a:
        return HttpResponse(error_json(ERR_MSG_NO_RECENT_MESSAGE))

自制的db.py方法(在所有其他端点上都有效)

Selfmade db.py Method (Works on all the other Endpoints)

@trace_db_ajax def db_execute_procedure_ajax_response(procedure_name, params, uid): params["o_data"] = {"type": cx_Oracle.CLOB} try: rparams = db_execute_procedure_lro(procedure_name, params, uid) except DBExecuteLogicalException as e: return ajax_response_bad_request(error_response(e.error_code, e.error_msg, e.error_info)) except DBExecutePhysicalException as e: return ajax_response_server_error(error_response(e.error_code, e.error_msg)) return ajax_response(rparams["o_data"])

@trace_db_ajax def db_execute_procedure_ajax_response(procedure_name, params, uid): params["o_data"] = {"type": cx_Oracle.CLOB} try: rparams = db_execute_procedure_lro(procedure_name, params, uid) except DBExecuteLogicalException as e: return ajax_response_bad_request(error_response(e.error_code, e.error_msg, e.error_info)) except DBExecutePhysicalException as e: return ajax_response_server_error(error_response(e.error_code, e.error_msg)) return ajax_response(rparams["o_data"])

过程

create or replace PACKAGE BODY P_CHAT AS
PROCEDURE get_messages
(
    i_userId    in   number,
    i_lastId    in   number,
    o_retCode   out  number,
    o_json      out  clob
)IS
    m_retCode   number := STD_C.retCode_ok;
BEGIN
    apex_json.initialize_clob_output;
    apex_json.open_array();
    if i_userId IS NULL then
        m_retCode := STD.error(P_C.ERR_USER_ID_MISSING);
    else
        for cs in(
            SELECT id, message, sender_id, gendate
            FROM Message
            WHERE (id>i_lastId OR i_lastId IS NULL)
            AND RECEIVER_ID=i_userId) loop
                apex_json.open_object();
                apex_json.write(P_C.JSON_MSG_ID, cs.id);
                apex_json.write(P_C.JSON_MSG_MESSAGE, cs.message);
                apex_json.write(P_C.JSON_MSG_SENDER_ID, cs.sender_id);
                apex_json.write(P_C.JSON_MSG_GENDATE, cs.gendate, std_c.iso_date_format);
                apex_json.close_object;
            end loop;
        apex_json.close_array();
        o_json := apex_json.get_clob_output;
    end if;

    o_retCode := m_retCode;

END get_messages;

END P_CHAT;

END P_CHAT;

我不必在过程中声明过程名称吗?

I dont have to declare the Procedure name in the Procedure or?

感谢您的回答!

推荐答案

PLS-00201: identifier must be declared表示其中一个

  1. 它真的不存在,或者
  2. 它存在,但是调用者没有执行它的特权,或者
  3. 它存在于调用者的默认模式以外的其他模式中,并且调用者需要指定哪个模式.

在#2的情况下,您需要授予调用者(或调用者具有的角色)对该程序包的执行权限.

In the case of #2, you need to grant execute permission on the package to the caller (or to a role which the caller has).

对于#3,您需要指定架构,或者将其设置为会话的默认架构,或者创建同义词.

In the case of #3, you need to either specify the schema, or set that as your default schema for the session, or create a synonym.

这篇关于必须声明PLS-00201标识符"PACKAGENAME.PROCEDURENAME"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆