2017-04-26 13 views
0

一部のテーブルからデータを削除するパッケージがあります。初期化ロジックで別のテーブルや手続きで監査する機能を持つパッケージを作った。私は奇妙なオラ誤りに立ち止まった。たぶんあなたは何が間違っているのか考えているかもしれません。Oracleパッケージエラー

これは仕様です:

CREATE OR REPLACE PACKAGE CLIENT_DELETE_PACKAGE 
IS 
    deletion_results VARCHAR2(200); 
    deletedEntries  NUMBER; 
    min_date   DATE; 
    max_date   DATE; 
    -- Enable/disable logging 
    Enable_Audit_Trail BOOLEAN := True; 
    -- Enable Safe Mode 
    Enable_Safe_Mode BOOLEAN := True; 
    PROCEDURE AUDIT_TRAIL(
     MyTYPE  IN VARCHAR2, 
     MyDATA  IN VARCHAR2, 
     MyDatasource IN VARCHAR2, 
     MyResultData IN VARCHAR2); 
    -- ECHO Check that the package is available. 
    FUNCTION ECHO(
     MyDATA IN VARCHAR2) 
    RETURN VARCHAR2; 
    -- JOB_REQUEST 
    FUNCTION DEL_WLM_ALERT(
     MyAlertKey IN NUMBER) 
    RETURN VARCHAR2; 
    PROCEDURE INIT; 
END CLIENT_DELETE_PACKAGE; 
/

と体:

CREATE OR REPLACE PACKAGE BODY CLIENT_DELETE_PACKAGE 
AS 
    -- Auditing 
    PROCEDURE AUDIT_TRAIL(
     MyTYPE  IN VARCHAR2, 
     MyDatasource IN VARCHAR2, 
     MyResultData IN VARCHAR2) 
    AS 
    --allow to keep the entry even if a roll-back occurs in the other procedure. 
    pragma autonomous_transaction; 
    BEGIN 
    /*ID: provided by sequence 
    EVENT_TIME: default value SysDate 
    TYPE: DELETED/LOCKED ITEM 
    DATASOURCE_NAME: datasource name 
    RESULT_DATA: data link to type 
    */ 
    IF (Enable_Audit_Trail) THEN 
     INSERT INTO CLIENT_DELETION_AUDIT 
     (id, TYPE, DATASOURCE_NAME, RESULT_DATA 
     ) 
     SELECT SEQ_AUDIT_TRAIL.NEXTVAL, MyTYPE, MyDatasource, MyResultData FROM dual; 
     COMMIT; 
    END IF; 
    END AUDIT_TRAIL; 
-- ------------------------------------------------------------------------- 
-- Echoing function 
-- ------------------------------------------------------------------------- 
    FUNCTION ECHO(
     MyDatasource IN VARCHAR2) 
    RETURN VARCHAR2 
    AS 
    BEGIN 
    /*check if the package is available */ 
    RETURN 'i am here'; 
    END ECHO; 
-- ------------------------------------------------------------------------- 
-- Delete WLM Alert Data 
-- ------------------------------------------------------------------------- 
    FUNCTION DEL_WLM_ALERT(
     MyAlertKey IN NUMBER) 
    RETURN VARCHAR2 
    AS 
    countLookUp  NUMBER; 
    countTotalEntries NUMBER; 
    deletedEntries NUMBER; 
    dataSourceToCheck VARCHAR2(200); 
    numberOfAlertLeft NUMBER; 
    alert_trx_id  NUMBER; 
    trx_group_id  NUMBER; 
    large_str_id  NUMBER; 
    BEGIN 
    countTotalEntries:=0; 
    deletedEntries :=0; 
    ---Get transaction ID for usage later--- 
    SELECT TRANSACTION_ID 
    INTO alert_trx_id 
    FROM WLM_RULE_ALERT WRA 
    JOIN WLM_ALERT_HEADER WAH 
    ON WAH.ALERT_IDENTIFIER = WRA.ALERT_IDENTIFIER 
    WHERE wah.alert_key  = MyAlertKey 
    AND rownum    =1; 
    ---Get transaction GRoup ID for usage later--- 
    SELECT TRANSACTION_GROUP_ID 
    INTO trx_group_id 
    FROM ALERTING_TRANSACTION AT 
    JOIN WLM_RULE_ALERT WRA 
    ON WRA.TRANSACTION_ID = AT.ID 
    JOIN WLM_ALERT_HEADER WAH 
    ON WAH.ALERT_IDENTIFIER = WRA.ALERT_IDENTIFIER 
    WHERE wah.alert_key  = MyAlertKey 
    AND rownum    =1; 
    ---Get LargeString ID for usage later--- 
    SELECT MIN(tg.largestring_id) 
    INTO large_str_id 
    FROM transaction_group tg 
    WHERE tg.ID = trx_group_id 
    AND rownum =1; 
    -- deleted from ALERT_MATCH_DATA -- 
    DELETE 
    FROM ALERT_MATCH_DATA AMD 
    WHERE ALERT_MATCH_ID IN 
     (SELECT AM.ID 
     FROM ALERT_MATCH AM 
     JOIN WLM_RULE_ALERT WRA 
     ON WRA.id = AM.WLM_RULE_ALERT_ID 
     JOIN WLM_ALERT_HEADER WAH 
     ON WAH.ALERT_IDENTIFIER = WRA.ALERT_IDENTIFIER 
     WHERE wah.alert_key  = MyAlertKey 
    ); 
    -- deleted from ALERT_MATCH -- 
    DELETE 
    FROM ALERT_MATCH AM 
    WHERE AM.WLM_RULE_ALERT_ID IN 
     (SELECT WRA.id 
     FROM WLM_RULE_ALERT WRA 
     JOIN WLM_ALERT_HEADER WAH 
     ON WAH.ALERT_IDENTIFIER = WRA.ALERT_IDENTIFIER 
     WHERE wah.alert_key  = MyAlertKey 
    ); 
    deletedEntries  :=deletedEntries+SQL%ROWCOUNT; 
    IF(numberOfAlertLeft =0) THEN 
     -- deleted from DATA_SOURCE_CUSTOMER -- 
     DELETE 
     FROM DATA_SOURCE_CUSTOMER DSC 
     WHERE ID  = alert_trx_id; 
     deletedEntries:=deletedEntries+SQL%ROWCOUNT; 
     -- deleted from DATA_SOURCE_SWIFT -- 
     DELETE 
     FROM DATA_SOURCE_SWIFT DSC 
     WHERE ID  = alert_trx_id; 
     deletedEntries:=deletedEntries+SQL%ROWCOUNT; 
     -- deleted from ALERTING_TRANSACTION -- 
     DELETE 
     FROM ALERTING_TRANSACTION AT 
     WHERE AT.ID    = alert_trx_id 
     OR AT.TRANSACTION_GROUP_ID = trx_group_id; 
     deletedEntries   :=deletedEntries+SQL%ROWCOUNT; 
     IF(countLookUp   = 1) THEN 
     -- deleted from TRANSACTION_GROUP -- 
     DELETE 
     FROM TRANSACTION_GROUP AT 
     WHERE AT.ID = trx_group_id; 
     deletedEntries:=deletedEntries+SQL%ROWCOUNT; 
     -- deleted from LARGESTRING_PART -- 
     DELETE 
     FROM LARGESTRING_PART 
     WHERE LARGESTRING_ID    IN large_str_id; 
     deletedEntries  :=deletedEntries+SQL%ROWCOUNT; 
     -- deleted from LARGESTRING -- 
     DELETE 
     FROM LARGESTRING 
     WHERE id  = large_str_id; 
     deletedEntries:=deletedEntries+SQL%ROWCOUNT; 
     END IF; 
    END IF; 
    countTotalEntries:=countTotalEntries+countLookUp; 
    -- deleted from WLM_RULE_ALERT -- 
    DELETE 
    FROM WLM_RULE_ALERT WRA 
    WHERE WRA.ALERT_IDENTIFIER IN 
     (SELECT WAH.ALERT_IDENTIFIER 
     FROM WLM_ALERT_HEADER WAH 
     WHERE wah.alert_key= MyAlertKey 
    ); 
    deletedEntries:=deletedEntries+SQL%ROWCOUNT; 
    -- deleted from WLM_CUSTOMER_MATCH_DETAILS -- 
    DELETE 
    FROM WLM_CUSTOMER_MATCH_DETAILS 
    WHERE ALERT_KEY= MyAlertKey; 
    deletedEntries:=deletedEntries+SQL%ROWCOUNT; 
    -- deleted from WORKFLOW_ACTION_LOG -- 
    DELETE 
    FROM WORKFLOW_ACTION_LOG 
    WHERE WORKFLOW_WORKITEM_ID IN 
     (SELECT id 
     FROM WORKFLOW_WORKITEM 
     WHERE ENTITY_KEY=TO_CHAR(MyAlertKey) 
     AND ENTITY_NAME ='WLM Alert' 
    ); 
    deletedEntries:=deletedEntries+SQL%ROWCOUNT; 
    -- deleted from WORKFLOW_WORKITEM_LINK -- 
    DELETE 
    FROM WORKFLOW_WORKITEM_LINK 
    WHERE ENTITY_KEY=MyAlertKey 
    AND ENTITY_NAME ='WLM Alert'; 
    deletedEntries :=deletedEntries+SQL%ROWCOUNT; 
    -- deleted from WORKFLOW_WORKITEM -- 
    DELETE 
    FROM WORKFLOW_WORKITEM 
    WHERE ENTITY_KEY= TO_CHAR(MyAlertKey) 
    AND entity_name ='WLM Alert'; 
    deletedEntries :=deletedEntries+SQL%ROWCOUNT; 
    -- deleted from WLM_ALERT_HEADER -- 
    DELETE 
    FROM WLM_ALERT_HEADER 
    WHERE alert_key = MyAlertKey; 
    deletedEntries :=deletedEntries+SQL%ROWCOUNT; 
    END DEL_WLM_ALERT; 
-- initialization procedure 
    PROCEDURE INIT 
    AS 
    CURSOR alert_id 
    IS 
    WITH alerts AS 
     (SELECT wah.ALERT_KEY              AS alert_key, 
     ds.NAME                 AS datasource_name, 
     NVL(el.ENTITY_ID,0)              AS alert_key_locked, 
     MIN(EVENT_DATE) OVER (PARTITION BY DATASOURCE_NAME order by EVENT_DATE) AS min_date, 
     MAX(EVENT_DATE) OVER (PARTITION BY DATASOURCE_NAME order by EVENT_DATE) AS max_date 
     FROM WLM_ALERT_HEADER wah 
     LEFT JOIN WORKFLOW_WORKITEM ww 
     ON wah.ALERT_KEY=ww.ENTITY_KEY 
     LEFT JOIN DATA_SOURCE ds 
     ON wah.AT_DATASOURCE_ID=ds.ID 
     LEFT JOIN CLIENT_DELETION_SETTINGS rds 
     ON ds.NAME =rds.DATASOURCE_NAME 
     LEFT JOIN ENTITY_LOCKS el 
     ON el.ENTITY_ID =wah.ALERT_KEY 
     WHERE EVENT_DATE < (sysdate - rds.PERIOD) 
    UNION ALL 
    SELECT wah.ALERT_KEY              AS alert_key, 
     ds.NAME                 AS datasource_name, 
     NVL(el.ENTITY_ID,0)              AS alert_key_locked, 
     MIN(EVENT_DATE) OVER (PARTITION BY DATASOURCE_NAME order by EVENT_DATE) AS min_date, 
     MAX(EVENT_DATE) OVER (PARTITION BY DATASOURCE_NAME order by EVENT_DATE) AS max_date 
    FROM WLM_ALERT_HEADER wah 
    LEFT JOIN WORKFLOW_WORKITEM ww 
    ON wah.ALERT_KEY=ww.ENTITY_KEY 
    LEFT JOIN 
     (SELECT ID, NAME 
     FROM DATA_SOURCE 
     WHERE NAME NOT IN 
     (SELECT DATASOURCE_NAME FROM CLIENT_DELETION_SETTINGS 
     ) 
    ) ds 
    ON wah.AT_DATASOURCE_ID=ds.ID 
    LEFT JOIN CLIENT_DELETION_SETTINGS rds 
    ON ds.NAME =rds.DATASOURCE_NAME 
    LEFT JOIN ENTITY_LOCKS el 
    ON el.ENTITY_ID = wah.ALERT_KEY 
    WHERE EVENT_DATE < (sysdate - 
     (SELECT period FROM CLIENT_deletion_settings WHERE datasource_name='DEFAULT' 
    )) 
    ) 
    SELECT * 
    FROM CLIENT_DELETION_SETTINGS rbs 
    LEFT JOIN alerts al 
    ON al.datasource_name=rbs.datasource_name; 

    BEGIN 
    FOR x IN alert_id 
    LOOP 
     IF (x.alert_key_locked > 0) THEN 
     AUDIT_TRAIL('LOCKED', x.datasource_name, x.alert_key); 
     COMMIT; 
     ELSE 
     -- execute deletion for each alert_id 
     deletion_results:=DEL_WLM_ALERT(x.alert_key); 
     COMMIT; 
     END IF; 
     AUDIT_TRAIL('DELETED', x.datasource_name, deletedEntries || ' | ' || MIN(min_date) || ' -- ' || MAX(max_date)); 
    END LOOP; 
END INIT; 
END CLIENT_DELETE_PACKAGE; 
/

ものはエラーです:あなたは両方の場所での手順と機能を宣言した

Error(11,13): PLS-00323: subprogram or cursor 'AUDIT_TRAIL' is declared in a package specification and must be defined in the package body 
Error(17,12): PLS-00323: subprogram or cursor 'ECHO' is declared in a package specification and must be defined in the package body 
Error(234,9): PL/SQL: Statement ignored 
Error(234,33): PLS-00302: component 'DATASOURCE_NAME' must be declared 
Error(241,7): PL/SQL: Statement ignoredError(241,32): PLS-00302: component 'DATASOURCE_NAME' must be declared 
Error(241,32): PLS-00302: component 'DATASOURCE_NAME' must be declared 
+0

私はちょうどそれを追加したい: サブプログラムまたはカーソル 'AUDIT_TRAILは、' パッケージ仕様部で宣言され、定義されなければなりませんパッケージ本体のエラー(17,12): 次の関数も宣言されています...これは私を狂ってしまいます。 おかげさまでありがとうございます。 –

答えて

1

が、引数が異なるため、PL/SQLコンパイラはそれらを異なるものとして認識します。仕様で宣言されたプロシージャと関数はありますが、決して定義されていません。身体に限定された手続きと機能 - 完全に独立しています。

あなたが合うように仕様を変更する必要があります:あなたはカーソルのクエリで重複する列名を持っているので

CREATE OR REPLACE PACKAGE CLIENT_DELETE_PACKAGE 
IS 
    ... 
    PROCEDURE AUDIT_TRAIL(
     MyTYPE  IN VARCHAR2, 
     -- MyDATA  IN VARCHAR2, -- this isn't in the body version 
     MyDatasource IN VARCHAR2, 
     MyResultData IN VARCHAR2); 
    -- ECHO Check that the package is available. 
    FUNCTION ECHO(
     -- MyDATA IN VARCHAR2) -- wrong name 
     MyDatasource IN VARCHAR2) 
    RETURN VARCHAR2; 
    ... 

PLS-00302です。あなたは単純な例で何を見ることができます。

column dummy format a6 

select * 
from dual 
cross join dual; 

DUMMY DUMMY 
------ ------ 
X  X  

のようなクエリを実行すると、クライアントは同じヘッダーを持つ結果セットに両方の列を表示できます。たとえば、そのクエリに基づいてビューを作成しようとすると、ビューDDLの列名が同じでなければならないため、「ORA-00957:列名が重複しています」というエラーが発生します。

何か似たようなことが起こっていますが、カーソルには両方の列に対して一意の列エイリアスが暗黙的に与えられています。結合条件ON al.datasource_name=rbs.datasource_nameが示すように、結合するテーブルとCTEの両方に同じ列名が表示されるため、select *は同じ列名を2回取得します。どちらも暗黙的にユニークなものにエイリアスされているため、実際にはdatasource_nameという列はありません。

ブランケットを使用しないようにカーソルクエリを変更する必要がありますselect *;実際に必要な列を表とCTEからリストします。それはとにかくお勧めです。

+0

良い答え/説明。また、 'select *'を使用しないことについての優れた点 – unleashed

0

AUDIT_TRAIL仕様は本体宣言に従いません。どちらの "ヘッダー"も同じでなければなりません - 同じ引数。 arg名を含む。

ECHOと同じです。

DATASOURCE_NAMEについて - 本当にCLIENT_DELETION_AUDITという表の列ですか?それが欠けていないのですか?

+0

素早い回答に感謝します。 エラー(235,33):PLS-00302:PLS-00302:コンポーネントのDATASOURCE_NAME " エラー(242,32)を宣言する必要がありますコンポーネントのDATASOURCE_NAMEは「 これを宣言する必要があります私はちょうど2つのエラーが残って DESCのCLIENT_DELETION_AUDITの結果は次のとおりです。 名ヌルタイプ --------------- -------- ---------- --- ID NOT NULL NUMBER EVENT_TIME DATE TYPE VARCHAR2(200) DATASOURCE_NAME VARCHAR2(200) RESULT_DATA VARCHAR2(200) –

+0

問題は 'TYPE'列名にあると思います。 TYPEはOracleの予約語です。そのため、SQLステートメントに問題が発生します。 insert into ...(...、 "TYPE"、...)、またはカラム名を例えばに変更することができます。 ITEM_TYPE – pvanek

+0

@pvanek - TYPEは[キーワード](https://docs.oracle.com/database/121/SQLRF/ap_keywd002.htm)ですが、[予約語](https://docs.oracle.com)ではありません。 /database/121/SQLRF/ap_keywd001.htm)。それは問題を引き起こす可能性がありますが、問題はありません。カーソルループ内に例外がスローされています。 –

0

多くのお返事に感謝します。以前のエラーはなくなりました。 コードを少し変更して、下記のパッケージとエラーを確認してください。 これは正しくコンパイルされましたが、現在はDEL_WLM_ALERT関数で他の問題があります。 カーソルのalert_idにNULL値が存在しません。
ここで、alert_keyはNULLではありません。

何が間違っているのか分かりますか教えてください。

  create or replace PACKAGE CLIENT_DELETE_PACKAGE 
    IS 
     deletion_results VARCHAR2(200); 
     deletedEntries  NUMBER; 
     min_date   DATE; 
     max_date   DATE; 
     min_min_date  DATE; 
     max_max_date  DATE; 
     -- Enable/disable logging 
     Enable_Audit_Trail BOOLEAN := True; 
     -- Enable Safe Mode 
     Enable_Safe_Mode BOOLEAN := True; 
     PROCEDURE AUDIT_TRAIL(
      MyTYPE  IN VARCHAR2, 
      MyDatasource IN VARCHAR2, 
      MyResultData IN VARCHAR2); 
     -- ECHO Check that the package is available. 
     FUNCTION ECHO(
      MyDatasource2 IN VARCHAR2) 
     RETURN VARCHAR2; 
     -- JOB_REQUEST 
     FUNCTION DEL_WLM_ALERT(
      MyAlertKey IN NUMBER) 
     RETURN VARCHAR2; 
     PROCEDURE INIT; 
    END CLIENT_DELETE_PACKAGE; 
    /

と体:

  create or replace PACKAGE BODY CLIENT_DELETE_PACKAGE 
    AS 
     -- Auditing 
     PROCEDURE AUDIT_TRAIL(
      MyTYPE  IN VARCHAR2, 
      MyDatasource IN VARCHAR2, 
      MyResultData IN VARCHAR2) 
     AS 
     --allow to keep the entry even if a roll-back occurs in the other procedure. 
     pragma autonomous_transaction; 
     BEGIN 
     /*ID: provided by sequence 
     EVENT_TIME: default value SysDate 
     ITEM_TYPE: DELETED/LOCKED ITEM 
     DATASOURCE_NAME: datasource name 
     RESULT_DATA: data link to type 
     */ 
     IF (Enable_Audit_Trail) THEN 
      INSERT INTO CLIENT_DELETION_AUDIT 
      (id, ITEM_TYPE, DATASOURCE_NAME, RESULT_DATA 
      ) 
      SELECT SEQ_AUDIT_TRAIL.NEXTVAL, MyTYPE, MyDatasource, MyResultData FROM dual; 
      COMMIT; 
     END IF; 
     END AUDIT_TRAIL; 
    -- ------------------------------------------------------------------------- 
    -- Echoing function 
    -- ------------------------------------------------------------------------- 
     FUNCTION ECHO(
      MyDatasource2 IN VARCHAR2) 
     RETURN VARCHAR2 
     AS 
     BEGIN 
     /*check if the package is available */ 
     RETURN 'i am here'; 
     END ECHO; 
    -- ------------------------------------------------------------------------- 
    -- Delete WLM Alert Data 
    -- ------------------------------------------------------------------------- 
     FUNCTION DEL_WLM_ALERT(
      MyAlertKey IN NUMBER) 
     RETURN VARCHAR2 
     AS 
     countLookUp  NUMBER; 
     countTotalEntries NUMBER; 
     deletedEntries NUMBER; 
     dataSourceToCheck VARCHAR2(200); 
     numberOfAlertLeft NUMBER; 
     alert_trx_id  NUMBER; 
     trx_group_id  NUMBER; 
     large_str_id  NUMBER; 
     BEGIN 
     countTotalEntries:=0; 
     deletedEntries :=0; 
     ---Get transaction ID for usage later--- 
     SELECT TRANSACTION_ID 
     INTO alert_trx_id 
     FROM WLM_RULE_ALERT WRA 
     JOIN WLM_ALERT_HEADER WAH 
     ON WAH.ALERT_IDENTIFIER = WRA.ALERT_IDENTIFIER 
     WHERE wah.alert_key  = MyAlertKey 
     AND rownum    =1; 
     ---Get transaction GRoup ID for usage later--- 
     SELECT TRANSACTION_GROUP_ID 
     INTO trx_group_id 
     FROM ALERTING_TRANSACTION AT 
     JOIN WLM_RULE_ALERT WRA 
     ON WRA.TRANSACTION_ID = AT.ID 
     JOIN WLM_ALERT_HEADER WAH 
     ON WAH.ALERT_IDENTIFIER = WRA.ALERT_IDENTIFIER 
     WHERE wah.alert_key  = MyAlertKey 
     AND rownum    =1; 
     ---Get LargeString ID for usage later--- 
     SELECT MIN(tg.largestring_id) 
     INTO large_str_id 
     FROM transaction_group tg 
     WHERE tg.ID = trx_group_id 
     AND rownum =1; 
     -- deleted from ALERT_MATCH_DATA -- 
     DELETE 
     FROM ALERT_MATCH_DATA AMD 
     WHERE ALERT_MATCH_ID IN 
      (SELECT AM.ID 
      FROM ALERT_MATCH AM 
      JOIN WLM_RULE_ALERT WRA 
      ON WRA.id = AM.WLM_RULE_ALERT_ID 
      JOIN WLM_ALERT_HEADER WAH 
      ON WAH.ALERT_IDENTIFIER = WRA.ALERT_IDENTIFIER 
      WHERE wah.alert_key  = MyAlertKey 
      ); 
     -- deleted from ALERT_MATCH -- 
     DELETE 
     FROM ALERT_MATCH AM 
     WHERE AM.WLM_RULE_ALERT_ID IN 
      (SELECT WRA.id 
      FROM WLM_RULE_ALERT WRA 
      JOIN WLM_ALERT_HEADER WAH 
      ON WAH.ALERT_IDENTIFIER = WRA.ALERT_IDENTIFIER 
      WHERE wah.alert_key  = MyAlertKey 
      ); 
     deletedEntries  :=deletedEntries+SQL%ROWCOUNT; 
     IF(numberOfAlertLeft =0) THEN 
      -- deleted from DATA_SOURCE_CUSTOMER -- 
      DELETE 
      FROM DATA_SOURCE_CUSTOMER DSC 
      WHERE ID  = alert_trx_id; 
      deletedEntries:=deletedEntries+SQL%ROWCOUNT; 
      -- deleted from DATA_SOURCE_SWIFT -- 
      DELETE 
      FROM DATA_SOURCE_SWIFT DSC 
      WHERE ID  = alert_trx_id; 
      deletedEntries:=deletedEntries+SQL%ROWCOUNT; 
      -- deleted from ALERTING_TRANSACTION -- 
      DELETE 
      FROM ALERTING_TRANSACTION AT 
      WHERE AT.ID    = alert_trx_id 
      OR AT.TRANSACTION_GROUP_ID = trx_group_id; 
      deletedEntries   :=deletedEntries+SQL%ROWCOUNT; 
      IF(countLookUp   = 1) THEN 
      -- deleted from TRANSACTION_GROUP -- 
      DELETE 
      FROM TRANSACTION_GROUP AT 
      WHERE AT.ID = trx_group_id; 
      deletedEntries:=deletedEntries+SQL%ROWCOUNT; 
      -- deleted from LARGESTRING_PART -- 
      DELETE 
      FROM LARGESTRING_PART 
      WHERE LARGESTRING_ID    IN large_str_id; 
      deletedEntries  :=deletedEntries+SQL%ROWCOUNT; 
      -- deleted from LARGESTRING -- 
      DELETE 
      FROM LARGESTRING 
      WHERE id  = large_str_id; 
      deletedEntries:=deletedEntries+SQL%ROWCOUNT; 
      END IF; 
     END IF; 
     countTotalEntries:=countTotalEntries+countLookUp; 
     -- deleted from WLM_RULE_ALERT -- 
     DELETE 
     FROM WLM_RULE_ALERT WRA 
     WHERE WRA.ALERT_IDENTIFIER IN 
      (SELECT WAH.ALERT_IDENTIFIER 
      FROM WLM_ALERT_HEADER WAH 
      WHERE wah.alert_key= MyAlertKey 
      ); 
     deletedEntries:=deletedEntries+SQL%ROWCOUNT; 
     -- deleted from WLM_CUSTOMER_MATCH_DETAILS -- 
     DELETE 
     FROM WLM_CUSTOMER_MATCH_DETAILS 
     WHERE ALERT_KEY= MyAlertKey; 
     deletedEntries:=deletedEntries+SQL%ROWCOUNT; 
     -- deleted from WORKFLOW_ACTION_LOG -- 
     DELETE 
     FROM WORKFLOW_ACTION_LOG 
     WHERE WORKFLOW_WORKITEM_ID IN 
      (SELECT id 
      FROM WORKFLOW_WORKITEM 
      WHERE ENTITY_KEY=TO_CHAR(MyAlertKey) 
      AND ENTITY_NAME ='WLM Alert' 
      ); 
     deletedEntries:=deletedEntries+SQL%ROWCOUNT; 
     -- deleted from WORKFLOW_WORKITEM_LINK -- 
     DELETE 
     FROM WORKFLOW_WORKITEM_LINK 
     WHERE ENTITY_KEY=MyAlertKey 
     AND ENTITY_NAME ='WLM Alert'; 
     deletedEntries :=deletedEntries+SQL%ROWCOUNT; 
     -- deleted from WORKFLOW_WORKITEM -- 
     DELETE 
     FROM WORKFLOW_WORKITEM 
     WHERE ENTITY_KEY= TO_CHAR(MyAlertKey) 
     AND entity_name ='WLM Alert'; 
     deletedEntries :=deletedEntries+SQL%ROWCOUNT; 
     -- deleted from WLM_ALERT_HEADER -- 
     DELETE 
     FROM WLM_ALERT_HEADER 
     WHERE alert_key = MyAlertKey; 
     deletedEntries :=deletedEntries+SQL%ROWCOUNT; 
     END DEL_WLM_ALERT; 
    -- initialization procedure 
     PROCEDURE INIT 
     AS 
     CURSOR alert_id 
     IS 
     WITH alerts AS 
      (SELECT wah.ALERT_KEY              AS alert_key, 
      ds.NAME                 AS datasource_name_item, 
      NVL(el.ENTITY_ID,0)              AS alert_key_locked, 
      MIN(EVENT_DATE) OVER (PARTITION BY DATASOURCE_NAME order by EVENT_DATE) AS min_date, 
      MAX(EVENT_DATE) OVER (PARTITION BY DATASOURCE_NAME order by EVENT_DATE) AS max_date 
      FROM WLM_ALERT_HEADER wah 
      LEFT JOIN WORKFLOW_WORKITEM ww 
      ON wah.ALERT_KEY=ww.ENTITY_KEY 
      LEFT JOIN DATA_SOURCE ds 
      ON wah.AT_DATASOURCE_ID=ds.ID 
      LEFT JOIN CLIENT_DELETION_SETTINGS rds 
      ON ds.NAME =rds.DATASOURCE_NAME 
      LEFT JOIN ENTITY_LOCKS el 
      ON el.ENTITY_ID =wah.ALERT_KEY 
      WHERE EVENT_DATE < (sysdate - rds.PERIOD) 
     UNION ALL 
     SELECT wah.ALERT_KEY              AS alert_key, 
      ds.NAME                 AS datasource_name_item, 
      NVL(el.ENTITY_ID,0)              AS alert_key_locked, 
      MIN(EVENT_DATE) OVER (PARTITION BY DATASOURCE_NAME order by EVENT_DATE) AS min_date, 
      MAX(EVENT_DATE) OVER (PARTITION BY DATASOURCE_NAME order by EVENT_DATE) AS max_date 
     FROM WLM_ALERT_HEADER wah 
     LEFT JOIN WORKFLOW_WORKITEM ww 
     ON wah.ALERT_KEY=ww.ENTITY_KEY 
     LEFT JOIN 
      (SELECT ID, NAME 
      FROM DATA_SOURCE 
      WHERE NAME NOT IN 
      (SELECT DATASOURCE_NAME FROM CLIENT_DELETION_SETTINGS 
      ) 
      ) ds 
     ON wah.AT_DATASOURCE_ID=ds.ID 
     LEFT JOIN CLIENT_DELETION_SETTINGS rds 
     ON ds.NAME =rds.DATASOURCE_NAME 
     LEFT JOIN ENTITY_LOCKS el 
     ON el.ENTITY_ID = wah.ALERT_KEY 
     WHERE EVENT_DATE < (sysdate - 
      (SELECT period FROM CLIENT_deletion_settings WHERE datasource_name='DEFAULT' 
      )) 
      ) 
     SELECT * 
     FROM CLIENT_DELETION_SETTINGS rbs 
     LEFT JOIN alerts al 
     ON al.datasource_name_item=rbs.datasource_name 
     WHERE alert_key IS NOT NULL; 

     BEGIN 
     FOR x IN alert_id 
     LOOP 
      IF (x.alert_key_locked > 0) THEN 
      AUDIT_TRAIL('LOCKED', x.datasource_name_item, x.alert_key); 
      COMMIT; 
      ELSE 
      -- execute deletion for each alert_id 
      deletion_results:=DEL_WLM_ALERT(x.alert_key); 
      COMMIT; 
      END IF; 
      --min_min_date := Select MIN(min_date) from dual; 
      --max_max_date := Select MIN(max_date) from dual; 
      AUDIT_TRAIL('DELETED', x.datasource_name_item, deletedEntries || ' | ' || min_date || ' -- ' || max_date); 
     END LOOP; 
    END INIT; 
    END CLIENT_DELETE_PACKAGE; 
    /

エラー:

  Error starting at line : 1 in command - 
     exec CLIENT_DELETE_PACKAGE.INIT 
     Error report - 
     ORA-06503: PL/SQL: Function returned without value 
     ORA-06512: at "TEST_DEV.CLIENT_DELETE_PACKAGE", line 179 
     ORA-06512: at "TEST_DEV.CLIENT_DELETE_PACKAGE", line 240 
     ORA-06512: at line 1 
     06503. 00000 - "PL/SQL: Function returned without value" 
     *Cause: A call to PL/SQL function completed, but no RETURN statement was 
       executed. 
     *Action: Rewrite PL/SQL function, making sure that it always returns 
       a value of a proper type. 
+0

質問をキャンセルしてください。 最後にDEL_WLM_ALERT関数の "RETURN deletionEntities" がありません。 良い一日を! –

関連する問題