2017-05-31 150 views
0

iam在聊天系統的後端工作,使用惠普Django服務器。 我在SQL-Developer中爲Oracle數據庫編寫了一個過程,它應該向最終消息提供一個端點。當我在SQL-Developer中運行過程時,它很順利。但是,如果我運行在端點上的程序,有以下錯誤-消息:必須聲明PLS-00201標識符'PACKAGENAME.PROCEDURENAME'

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方法(在所有其他端點工程)

@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;

我不必在程序中聲明Procedure name嗎?

感謝您的回答!

+0

可能是模式問題?在你創建包的模式中,你可以嘗試給出模式名稱,當你從python訪問它時 –

+0

Didnt工作......我也沒有在其他端點使用它,所以我不認爲它需要。但是,無論如何感謝^^ – Tim

回答

0

PLS-00201: identifier must be declared意味着要麼

  1. 這真的不存在,或
  2. 它的存在,但調用者沒有權限來執行它,或
  3. 它存在於比其他一些其他架構調用者的默認值,並且調用者需要指定哪一個。

在#2的情況下,您需要將包的執行權限授予給調用者(或調用者具有的角色)。

對於#3,您需要指定架構,或將其設置爲會話的默認架構,或者創建同義詞。

+0

也試過這個!沒有工作:/ – Tim

+0

你嘗試了什麼?錯誤是什麼?你是否將其稱爲包裹所有者? –

+0

我發現了錯誤。它不是代碼或模式。我正在爲Endpoint運行Django測試,並且Django在TEST-Database中運行測試,但該過程位於DEV-Database上,因此django無法找到它。邏輯,但我已經監督了。無論如何感謝^^。 – Tim