2011-11-15 327 views
3

任何人都可以告訴我下列語法有什麼問題嗎?我只是試圖在存儲過程中運行一個簡單的SELECT語句。Oracle存儲過程

CREATE OR REPLACE PROCEDURE PVSSRDB.GETBATTERYSTATUSFORALLLOGGERS 
(
    p_Logger OUT e.comment_, 
    p_tStamp OUT h.ts, 
    p_Val OUT h.value_number 
) 
AS 
BEGIN 
    select 
    e.comment_, 
    max(h.ts), 
    avg(h.value_number) 
INTO 
    p_Logger, 
    p_tStamp, 
    p_Val 
FROM 
    PVSSRDB.ELEMENTS e inner join PVSSRDB.DB15MINHISTORY_00100009 h on h.element_id =e.element_id 
WHERE 
    e.element_name like 'System1:H%.BatteryCondition' 
GROUP BY 
    e.comment_ 
ORDER by 2 asc 
END GETBATTERYSTATUSFORALLLOGGERS; 

我不斷收到相同的3個錯誤,指出:

  • 錯誤(9,3):PL/SQL:SQL語句忽略
  • 錯誤(23,18):PL/SQL: ORA_00933:SQL命令未正確結束
  • 錯誤(24,34):PLS-00103:遇到符號「文件結束」時,期待以下某項操作:(開始case如果循環mod聲明結束異常退出空編注提升返回選擇更新,同時與< <繼續關閉當前刪除獲取鎖芯打開回滾保存點設置SQL執行提交FORALL合流管清洗

回答

4

你的ORDER BY 2 asc

後缺少一個分號你也需要正確地宣佈你OUT參數。

CREATE OR REPLACE 
PROCEDURE PVSSRDB.GETBATTERYSTATUSFORALLLOGGERS (
    p_Logger OUT PVSSRDB.ELEMENTS.comment_%TYPE, 
    p_tStamp OUT PVSSRDB.DB15MINHISTORY_00100009.ts%TYPE, 
    p_Val OUT PVSSRDB.DB15MINHISTORY_00100009.value_number%TYPE 
) 
AS 
BEGIN 
    select e.comment_, 
      max(h.ts), 
      avg(h.value_number) 
    INTO p_Logger, 
      p_tStamp, 
      p_Val 
    FROM PVSSRDB.ELEMENTS e 
    inner join PVSSRDB.DB15MINHISTORY_00100009 h on (h.element_id =e.element_id) 
    WHERE e.element_name like 'System1:H%.BatteryCondition' 
    GROUP BY e.comment_ 
    ORDER by 2 asc; 
END GETBATTERYSTATUSFORALLLOGGERS;