DBA Data[Home] [Help]

APPS.PO_AP_PURGE_PVT SQL Statements

The following lines contain the word 'select', 'insert', 'update' or 'delete':

Line: 104

PROCEDURE delete_reqs
( x_return_status       OUT NOCOPY  VARCHAR2,
  p_range_size          IN          NUMBER,
  p_req_lower_limit     IN          NUMBER,
  p_req_upper_limit     IN          NUMBER
);
Line: 111

PROCEDURE delete_pos
( x_return_status       OUT NOCOPY  VARCHAR2,
  p_range_size          IN          NUMBER,
  p_po_lower_limit      IN          NUMBER,
  p_po_upper_limit      IN          NUMBER
);
Line: 985

PROCEDURE delete_records
(  p_api_version   IN NUMBER,
   p_init_msg_list IN VARCHAR2,
   p_commit        IN VARCHAR2,
   x_return_status OUT NOCOPY VARCHAR2,
   x_msg_data      OUT NOCOPY VARCHAR2,
   p_purge_name IN VARCHAR2,
   p_purge_category IN VARCHAR2,
   p_range_size IN NUMBER
) IS

l_api_name      CONSTANT VARCHAR2(50) := 'delete_records';
Line: 1051

          p_error_text      => 'Internal Error. delete_records must commit'
        );
Line: 1070

    delete_reqs
    ( x_return_status       => l_return_status,
      p_range_size          => p_range_size,
      p_req_lower_limit     => l_req_lower_limit,
      p_req_upper_limit     => l_req_upper_limit
    );
Line: 1099

        delete_pos
        ( x_return_status   => l_return_status,
          p_range_size      => p_range_size,
          p_po_lower_limit  => l_po_lower_limit,
          p_po_upper_limit  => l_po_upper_limit
        );
Line: 1112

        RCV_AP_PURGE_PVT.delete_receipts
        ( x_return_status   => l_return_status,
          p_range_size      => p_range_size,
          p_po_lower_limit  => l_po_lower_limit,
          p_po_upper_limit  => l_po_upper_limit
        );
Line: 1145

END delete_records;
Line: 1182

PROCEDURE delete_purge_lists
(  p_api_version   IN NUMBER,
   p_init_msg_list IN VARCHAR2,
   p_commit        IN VARCHAR2,
   x_return_status OUT NOCOPY VARCHAR2,
   x_msg_data      OUT NOCOPY VARCHAR2,
   p_purge_name     IN VARCHAR2
) IS


l_api_name      CONSTANT VARCHAR2(50) := 'delete_purge_lists';
Line: 1213

    SAVEPOINT delete_purge_lists_pvt;
Line: 1238

    DELETE
    FROM    po_purge_req_list;
Line: 1241

    DELETE
    FROM    po_purge_po_list;
Line: 1260

    ROLLBACK TO delete_purge_lists_pvt;
Line: 1269

END delete_purge_lists;
Line: 1307

PROCEDURE delete_history_tables
(  p_api_version   IN NUMBER,
   p_init_msg_list IN VARCHAR2,
   p_commit        IN VARCHAR2,
   x_return_status OUT NOCOPY VARCHAR2,
   x_msg_data      OUT NOCOPY VARCHAR2,
   p_purge_name IN VARCHAR2
) IS


l_api_name      CONSTANT VARCHAR2(50) := 'delete_history_tables';
Line: 1339

    SAVEPOINT delete_history_tables_pvt;
Line: 1364

    DELETE
    FROM    po_history_pos
    WHERE   purge_name = p_purge_name;
Line: 1370

    DELETE
    FROM    po_history_requisitions
    WHERE   purge_name = p_purge_name;
Line: 1376

    DELETE
    FROM    po_history_receipts
    WHERE   purge_name = p_purge_name;
Line: 1396

    ROLLBACK TO delete_history_tables_pvt;
Line: 1405

END delete_history_tables;
Line: 1503

    SELECT  COUNT(1)
    INTO    x_po_hdr_count
    FROM    po_headers;
Line: 1509

    SELECT  COUNT(1)
    INTO    x_rcv_line_count
    FROM    rcv_shipment_lines;
Line: 1515

    SELECT  COUNT(1)
    INTO    x_req_hdr_count
    FROM    po_requisition_headers;
Line: 1521

    SELECT  COUNT(1)
    INTO    x_vendor_count
    FROM    po_vendors;
Line: 1527

    SELECT  COUNT(1)
    INTO    x_asl_count
    FROM    po_approved_supplier_list;
Line: 1533

    SELECT  COUNT(1)
    INTO    x_asl_attr_count
    FROM    po_asl_attributes;
Line: 1539

    SELECT  COUNT(1)
    INTO    x_asl_doc_count
    FROM    po_asl_documents;
Line: 1628

    INSERT INTO po_purge_req_list
    (   requisition_header_id,
        purge_name,
        double_check_flag
    )
    SELECT  PRH.requisition_header_id,
            p_purge_name,
            'Y'
    FROM    po_requisition_headers PRH
    WHERE   PRH.last_update_date <= p_last_activity_date
    AND     (PRH.closed_code = 'FINALLY CLOSED'
             OR PRH.authorization_status = 'CANCELLED')
    AND     NOT EXISTS
                (SELECT NULL
                 FROM   po_requisition_lines PRL
                 WHERE  PRL.requisition_header_id = PRH.requisition_header_id
                 AND    NVL(PRL.modified_by_agent_flag, 'N') = 'N'
                 AND    (PRL.last_update_date > p_last_activity_date
                         OR
                         PRL.line_location_id IS NOT NULL
                         OR
                         PRL.source_type_code = 'INVENTORY'
                         OR
                         EXISTS (
                            SELECT  NULL
                            FROM    po_price_differentials PPD
                            WHERE   PPD.entity_type = 'REQ LINE'
                            AND     PPD.entity_id = PRL.requisition_line_id
                            AND     PPD.last_update_date >
                                    p_last_activity_date)
                         OR
                         EXISTS (
                            SELECT  NULL
                            FROM    po_req_distributions PRD
                            WHERE   PRD.requisition_line_id =
                                    PRL.requisition_line_id
                            AND     PRD.last_update_date >
                                    p_last_activity_date)));
Line: 1672

          message   => 'Inserted ' || SQL%ROWCOUNT || ' Reqs to purge list'
        );
Line: 1795

            INSERT INTO po_purge_po_list
            (   po_header_id,
                purge_name,
                double_check_flag
            )
            SELECT  PH.po_header_id,
                    p_purge_name,
                    'Y'
            FROM    po_headers PH
            WHERE   PH.type_lookup_code IN ('STANDARD', 'PLANNED',
                                            'BLANKET',  'CONTRACT')
            AND     PH.last_update_date <= p_last_activity_date
            AND     (PH.closed_code = 'FINALLY CLOSED'
                     OR PH.cancel_flag = 'Y')
            AND     NOT EXISTS
                        (SELECT NULL
                         FROM   po_releases PR
                         WHERE  PR.po_header_id = PH.po_header_id
                         AND    PR.last_update_date > p_last_activity_date)
            AND     NOT EXISTS
                        (SELECT NULL
                         FROM   po_lines PL
                         WHERE  PL.po_header_id = PH.po_header_id
                         AND    PL.last_update_date > p_last_activity_date)
            AND     NOT EXISTS
                        (SELECT NULL
                         FROM   po_line_locations PLL
                         WHERE  PLL.po_header_id = PH.po_header_id
                         AND    PLL.last_update_date > p_last_activity_date)
            AND     NOT EXISTS
                        (SELECT NULL
                         FROM   po_distributions PD
                         WHERE  PD.po_header_id = PH.po_header_id
                         AND    (PD.last_update_date > p_last_activity_date
                                 OR
                                 EXISTS
                                    (SELECT NULL
                                     FROM   ap_invoice_distributions AD
                                     WHERE  AD.po_distribution_id =
                                            PD.po_distribution_id)))
            AND     NOT EXISTS
                        (SELECT NULL
                         FROM   rcv_transactions RT
                         WHERE  RT.po_header_id = PH.po_header_id
                         AND    RT.last_update_date > p_last_activity_date)
            AND     PO_AP_PURGE_GRP.validate_purge(PH.po_header_id) = 'T';
Line: 1856

            INSERT INTO po_purge_po_list
            (   po_header_id,
                purge_name,
                double_check_flag
            )
            SELECT  PH.po_header_id,
                    p_purge_name,
                    'Y'
            FROM    po_headers PH
            WHERE   PH.type_lookup_code IN ('STANDARD', 'PLANNED',
                                            'BLANKET',  'CONTRACT')
            AND     PH.last_update_date <= p_last_activity_date
            AND     (PH.closed_code = 'FINALLY CLOSED'
                     OR PH.cancel_flag = 'Y')
            AND     NOT EXISTS
                        (SELECT NULL
                         FROM   po_releases PR
                         WHERE  PR.po_header_id = PH.po_header_id
                         AND    PR.last_update_date > p_last_activity_date)
            AND     NOT EXISTS
                        (SELECT NULL
                         FROM   po_lines PL
                         WHERE  PL.po_header_id = PH.po_header_id
                         AND    PL.last_update_date > p_last_activity_date)
            AND     NOT EXISTS
                        (SELECT NULL
                         FROM   po_line_locations PLL
                         WHERE  PLL.po_header_id = PH.po_header_id
                         AND    PLL.last_update_date > p_last_activity_date)
            AND     NOT EXISTS
                        (SELECT NULL
                         FROM   po_distributions PD
                         WHERE  PD.po_header_id = PH.po_header_id
                         AND    PD.last_update_date > p_last_activity_date)
            AND     NOT EXISTS
                        (SELECT NULL
                         FROM   rcv_transactions RT
                         WHERE  RT.po_header_id = PH.po_header_id
                         AND    RT.last_update_date > p_last_activity_date)
            AND     PO_AP_PURGE_GRP.validate_purge(PH.po_header_id) = 'T';
Line: 1904

              message   => 'inserted ' || SQL%ROWCOUNT || ' POs to purge'
                           || ' list. purge_cat = ' || p_purge_category
            );
Line: 1922

        INSERT INTO po_purge_req_list
        (   requisition_header_id,
            purge_name,
            double_check_flag
        )
        SELECT  PRH.requisition_header_id,
                p_purge_name,
                'Y'
        FROM    po_requisition_headers PRH
        WHERE   PRH.last_update_date <= p_last_activity_date
        AND     (PRH.closed_code = 'FINALLY CLOSED'
                 OR PRH.authorization_status = 'CANCELLED')
        AND     NOT EXISTS
                    (SELECT NULL
                     FROM   po_requisition_lines PRL
                     WHERE  PRL.requisition_header_id =
                            PRH.requisition_header_id
                     AND    NVL(PRL.modified_by_agent_flag, 'N') = 'N'
                     AND    (PRL.last_update_date > p_last_activity_date
                             OR
                             PRL.source_type_code = 'INVENTORY'
                             OR
                             EXISTS (
                                SELECT  NULL
                                FROM    po_req_distributions PRD
                                WHERE   PRD.requisition_line_id =
                                        PRL.requisition_line_id
                                AND     PRD.last_update_date >
                                        p_last_activity_date)));
Line: 1957

              message   => 'inserted ' || SQL%ROWCOUNT || ' REQs to purge list'
            );
Line: 2336

        UPDATE  po_purge_req_list PPRL
        SET     PPRL.double_check_flag = 'N'
        WHERE   PPRL.double_check_flag = 'Y'
        AND     EXISTS
                    (SELECT NULL
                     FROM   chv_item_orders CIO
                     WHERE  CIO.document_header_id = PPRL.requisition_header_id
                     AND    CIO.supply_document_type = 'REQUISITION');
Line: 2350

              message   => 'Check CHV. Updated rowcount = ' || SQL%ROWCOUNT
            );
Line: 2360

        UPDATE  po_purge_req_list PPRL
        SET     PPRL.double_check_flag = 'N'
        WHERE   PPRL.double_check_flag = 'Y'
        AND     EXISTS
                    (SELECT NULL
                     FROM   po_req_distributions RD,
                            po_requisition_lines RL
                     WHERE  RL.requisition_header_id =
                            PPRL.requisition_header_id
                     AND    RD.requisition_line_id =
                            RL.requisition_line_id
                     AND    RD.project_id IS NOT NULL
                     AND    RL.destination_type_code = 'EXPENSE');
Line: 2384

                           'Updated rowcount = ' || SQL%ROWCOUNT
            );
Line: 2394

        UPDATE  po_purge_req_list PPRL
        SET     PPRL.double_check_flag = 'N'
        WHERE   PPRL.double_check_flag = 'Y'
        AND     EXISTS
                    (SELECT NULL
                     FROM   po_req_distributions RD,
                            po_requisition_lines RL
                     WHERE  RL.requisition_header_id =
                            PPRL.requisition_header_id
                     AND    RD.requisition_line_id =
                            RL.requisition_line_id
                     AND    RD.project_id IS NOT NULL
                     AND    RL.destination_type_code IN ('INVENTORY',
                                                         'SHOP FLOOR'));
Line: 2418

                           'Updated rowcount = ' || SQL%ROWCOUNT
            );
Line: 2519

        UPDATE  po_purge_po_list PPL
        SET     PPL.double_check_flag = 'N'
        WHERE   PPL.double_check_flag = 'Y'
        AND     EXISTS (
                    SELECT  NULL
                    FROM    mtl_material_transactions MMT
                    WHERE   MMT.transaction_source_type_id = 1
                    AND     MMT.transaction_source_id = PPL.po_header_id);
Line: 2538

                           'Updated rowcount = ' || SQL%ROWCOUNT
            );
Line: 2548

        UPDATE po_purge_po_list PPL
        SET     PPL.double_check_flag = 'N'
        WHERE   PPL.double_check_flag = 'Y'
        AND     EXISTS (
                    SELECT  NULL
                    FROM    wip_transactions WT
                    WHERE   WT.po_header_id = PPL.po_header_id);
Line: 2566

                           'Updated rowcount = ' || SQL%ROWCOUNT
            );
Line: 2576

        UPDATE po_purge_po_list PPL
        SET     PPL.double_check_flag = 'N'
        WHERE   PPL.double_check_flag = 'Y'
        AND     EXISTS (
                    SELECT  NULL
                    FROM    mrp_schedule_consumptions MSC
                    WHERE   MSC.disposition_type IN (2,6)
                    AND     MSC.disposition_id = PPL.po_header_id);
Line: 2595

                           'Updated rowcount = ' || SQL%ROWCOUNT
            );
Line: 2605

        UPDATE  po_purge_po_list PPL
        SET     PPL.double_check_flag = 'N'
        WHERE   PPL.double_check_flag = 'Y'
        AND     EXISTS(
                    SELECT  NULL
                    FROM    chv_item_orders CIO
                    WHERE   CIO.document_header_id = PPL.po_header_id
                    AND     CIO.supply_document_type = 'RELEASE');
Line: 2619

              message   => 'Check CHV. Updated rowcount = ' || SQL%ROWCOUNT
            );
Line: 2629

        UPDATE  po_purge_po_list PPL
        SET     PPL.double_check_flag = 'N'
        WHERE   PPL.double_check_flag = 'Y'
        AND     EXISTS (
                    SELECT  NULL
                    FROM    po_distributions PD
                    WHERE   PPL.po_header_id = PD.po_header_id
                    AND     PD.project_id IS NOT NULL
                    AND     PD.destination_type_code = 'EXPENSE');
Line: 2649

                           'Updated rowcount = ' || SQL%ROWCOUNT
            );
Line: 2659

        UPDATE  po_purge_po_list PPL
        SET     PPL.double_check_flag = 'N'
        WHERE   PPL.double_check_flag = 'Y'
        AND     EXISTS (
                    SELECT  NULL
                    FROM    po_distributions PD
                    WHERE   PPL.po_header_id = PD.po_header_id
                    AND     PD.project_id IS NOT NULL
                    AND     PD.destination_type_code IN ('INVENTORY',
                                                         'SHOP FLOOR'));
Line: 2679

                           'Updated rowcount = ' || SQL%ROWCOUNT
            );
Line: 2797

        UPDATE  po_purge_po_list PPL
        SET     PPL.double_check_flag = 'N'
        WHERE   PPL.double_check_flag = 'Y'
        AND     (EXISTS (    -- rm po if req not in purge list
                    SELECT NULL
                    FROM   po_line_locations_all PLL,
                           po_requisition_lines_all RL
                    WHERE  PLL.po_header_id = PPL.po_header_id
                    AND    PLL.line_location_id = RL.line_location_id
                    AND    NOT EXISTS (
                                    SELECT NULL
                                    FROM   po_purge_req_list PRL
                                    WHERE  PRL.requisition_header_id =
                                           RL.requisition_header_id
                                    AND    PRL.double_check_flag = 'Y'))
                OR
                 EXISTS (   -- rm po if contract not in purge list
                    SELECT NULL
                    FROM   po_lines_all POL
                    WHERE  POL.po_header_id = PPL.po_header_id
                    AND    POL.contract_id IS NOT NULL
                    AND    NOT EXISTS (
                                    SELECT NULL
                                    FROM   po_purge_po_list PPL1
                                    WHERE  PPL1.double_check_flag = 'Y'
                                    AND    PPL1.po_header_id =
                                           POL.contract_id))
                OR
                 EXISTS (   -- rm po if ga not in purge list
                    SELECT  NULL
                    FROM    po_lines_all POL,
                            po_headers_all POH
                    WHERE   PPL.po_header_id = POL.po_header_id
                    AND     POL.from_header_id = POH.po_header_id
                    AND     POH.type_lookup_code = 'BLANKET'
                    AND     POH.global_agreement_flag = 'Y'
                    AND     NOT EXISTS (
                                    SELECT  NULL
                                    FROM    po_purge_po_list PPL1
                                    WHERE   PPL1.double_check_flag = 'Y'
                                    AND     POH.po_header_id =
                                            PPL1.po_Header_id))
                OR
                 EXISTS (   -- rm contract if po not in purge list
                    SELECT NULL
                    FROM   po_lines_all POL
                    WHERE  PPL.po_header_id = POL.contract_id
                    AND    NOT EXISTS (
                                    SELECT NULL
                                    FROM   po_purge_po_list PPL1
                                    WHERE  PPL1.double_check_flag = 'Y'
                                    AND    POL.po_header_id =
                                           PPL1.po_header_id))
                OR
                 EXISTS (   -- rm ga if po not in purge list
                    SELECT  NULL
                    FROM    po_headers_all POH,
                            po_lines_all POL
                    WHERE   POH.po_header_id = PPL.po_header_id
                    AND     POH.type_lookup_code = 'BLANKET'
                    AND     POH.global_agreement_flag = 'Y'
                    AND     POL.from_header_id = POH.po_header_id
                    AND     NOT EXISTS (
                                    SELECT  NULL
                                    FROM    po_purge_po_list PPL1
                                    WHERE   PPL1.double_check_flag = 'Y'
                                    AND     POL.po_header_id =
                                            PPL1.po_header_id)));
Line: 2874

        UPDATE  po_purge_req_list PPRL
        SET     PPRL.double_check_flag = 'N'
        WHERE   PPRL.double_check_flag = 'Y'
        AND     EXISTS (
                    SELECT NULL
                    FROM   po_requisition_lines_all RL,
                           po_line_locations_all PLL
                    WHERE  RL.requisition_header_id =
                           PPRL.requisition_header_id
                    AND    RL.line_location_id = PLL.line_location_id
                    AND    NOT EXISTS (
                                    SELECT NULL
                                    FROM   po_purge_po_list PPL
                                    WHERE  PPL.double_check_flag = 'Y'
                                    AND    PPL.po_header_id =
                                           PLL.po_header_id));
Line: 2897

              message   => 'Updated po_count = ' || l_po_count ||
                           ', Updated req_count = ' || l_req_count
            );
Line: 3001

    UPDATE  po_purge_po_list PPL
    SET     PPL.double_check_flag = 'N'
    WHERE   PPL.double_check_flag = 'Y'
    AND     EXISTS (
                SELECT  NULL
                FROM    po_distributions PD,
                        ap_invoice_distributions AD
                WHERE   PD.po_header_id = PPL.po_header_id
                AND     AD.po_distribution_id = PD.po_distribution_id
                AND     NOT EXISTS (
                                SELECT  NULL
                                FROM    ap_purge_invoice_list APL
                                WHERE   APL.invoice_id = AD.invoice_id));
Line: 3022

          message   => 'Updated po rowcount = ' || l_po_count
        );
Line: 3107

    DELETE FROM po_purge_req_list
    WHERE  double_check_flag = 'N';
Line: 3115

          message   => 'Deleted ' || SQL%ROWCOUNT || ' reqs from purge list'
        );
Line: 3126

        DELETE FROM po_purge_po_list
        WHERE  double_check_flag = 'N';
Line: 3134

              message   => 'Deleted ' || SQL%ROWCOUNT || ' pos from purge list'
            );
Line: 3220

    UPDATE  po_purge_req_list PPRL
    SET     double_check_flag = 'N'
    WHERE   double_check_flag = 'Y'
    AND     NOT EXISTS (
                SELECT  NULL
                FROM    po_requisition_headers RH
                WHERE   RH.requisition_header_id  =
                        PPRL.requisition_header_id
                AND     RH.last_update_date <= p_last_activity_date
                AND     (RH.closed_code = 'FINALLY CLOSED'
                        OR RH.authorization_status = 'CANCELLED')
                AND     NOT EXISTS (
                            SELECT  NULL
                            FROM    po_requisition_lines RL
                            WHERE   RL.requisition_header_id =
                                    RH.requisition_header_id
                            AND     NVL(RL.modified_by_agent_flag,'N') = 'N'
                            AND     (RL.last_update_date > p_last_activity_date
                                     OR
                                     RL.line_location_id IS NOT NULL
                                     OR
                                     RL.source_type_code = 'INVENTORY'
                                     OR
                                     EXISTS (
                                        SELECT  NULL
                                        FROM    po_price_differentials PPD
                                        WHERE   PPD.entity_type = 'REQ LINE'
                                        AND     PPD.entity_id =
                                                RL.requisition_line_id
                                        AND     PPD.last_update_date >
                                                p_last_activity_date)
                                     OR
                                     EXISTS (
                                        SELECT  NULL
                                        FROM    po_req_distributions RD
                                        WHERE   RD.requisition_line_id =
                                                RL.requisition_line_id
                                        AND     RD.last_update_date >
                                                p_last_activity_date))));
Line: 3363

        UPDATE  po_purge_po_list PPL
        SET     double_check_flag = 'N'
        WHERE   double_check_flag = 'Y'
        AND     NOT EXISTS (
                    SELECT  NULL
                    FROM    po_headers PH
                    WHERE   PH.po_header_id = PPL.po_header_id
                    AND     PH.type_lookup_code IN ('STANDARD', 'BLANKET',
                                                    'PLANNED', 'CONTRACT')
                    AND     (PH.cancel_flag = 'Y'
                             OR PH.closed_code = 'FINALLY CLOSED')
                    AND     PH.last_update_date <= p_last_activity_date
                    AND     NOT EXISTS
                            (SELECT NULL
                             FROM   po_releases PR
                             WHERE  PR.po_header_id = PPL.po_header_id
                             AND    PR.last_update_date > p_last_activity_date)
                    AND     NOT EXISTS
                            (SELECT NULL
                             FROM   po_lines PL
                             WHERE  PL.po_header_id = PPL.po_header_id
                             AND    (PL.last_update_date > p_last_activity_date
                                     OR
                                     EXISTS
                                     (SELECT NULL
                                      FROM   po_price_differentials PPD
                                      WHERE  PPD.entity_type IN ('PO LINE',
                                                                'BLANKET LINE')
                                      AND    PPD.entity_id = PL.po_line_id
                                      AND    PPD.last_update_date >
                                             p_last_activity_date)))
                    AND     NOT EXISTS
                            (SELECT NULL
                             FROM   po_line_locations PLL
                             WHERE  PLL.po_header_id = PPL.po_header_id
                             AND    (PLL.last_update_date >p_last_activity_date
                                     OR
                                     EXISTS
                                     (SELECT NULL
                                      FROM   po_price_differentials PPD
                                      WHERE  PPD.entity_type = 'PRICE BREAK'
                                      AND    PPD.entity_id =
                                             PLL.line_location_id
                                      AND    PPD.last_update_date >
                                             p_last_activity_date)))
                    AND     NOT EXISTS
                            (SELECT NULL
                             FROM   po_distributions PD
                             WHERE  PD.po_header_id = PPL.po_header_id
                             AND    (PD.last_update_date > p_last_activity_date
                                     OR
                                     EXISTS
                                     (SELECT NULL
                                      FROM   ap_invoice_distributions AD
                                      WHERE  AD.po_distribution_id =
                                             PD.po_distribution_id))));
Line: 3432

        UPDATE  po_purge_po_list PPL
        SET     double_check_flag = 'N'
        WHERE   double_check_flag = 'Y'
        AND     NOT EXISTS (
                    SELECT  NULL
                    FROM    po_headers PH
                    WHERE   PH.po_header_id = PPL.po_header_id
                    AND     PH.type_lookup_code IN ('STANDARD', 'BLANKET',
                                                    'PLANNED', 'CONTRACT')
                    AND     (PH.cancel_flag = 'Y'
                             OR PH.closed_code = 'FINALLY CLOSED')
                    AND     PH.last_update_date <= p_last_activity_date
                    AND     NOT EXISTS
                            (SELECT NULL
                             FROM   po_releases PR
                             WHERE  PR.po_header_id = PH.po_header_id
                             AND    PR.last_update_date > p_last_activity_date)
                    AND     NOT EXISTS
                            (SELECT NULL
                             FROM   po_lines PL
                             WHERE  PL.po_header_id = PH.po_header_id
                             AND    (PL.last_update_date > p_last_activity_date
                                     OR
                                     EXISTS
                                     (SELECT NULL
                                      FROM   po_price_differentials PPD
                                      WHERE  PPD.entity_type IN ('PO LINE',
                                                                 'BLANKET LINE')
                                      AND    PPD.entity_id = PL.po_line_id
                                      AND    PPD.last_update_date >
                                             p_last_activity_date)))
                    AND     NOT EXISTS
                            (SELECT NULL
                             FROM   po_line_locations PLL
                             WHERE  PLL.po_header_id = PH.po_header_id
                             AND    (PLL.last_update_date > p_last_activity_date
                                     OR
                                     EXISTS
                                     (SELECT NULL
                                      FROM   po_price_differentials PPD
                                      WHERE  PPD.entity_type = 'PRICE BREAK'
                                      AND    PPD.entity_id =
                                             PLL.line_location_id
                                      AND    PPD.last_update_date >
                                             p_last_activity_date)))
                    AND     NOT EXISTS
                            (SELECT NULL
                             FROM   po_distributions PD
                             WHERE  PD.po_header_id = PH.po_header_id
                             AND    PD.last_update_date >
                                    p_last_activity_date));
Line: 3507

    UPDATE po_purge_req_list PPRL
    SET     double_check_flag = 'N'
    WHERE   double_check_flag = 'Y'
    AND     NOT EXISTS (
                SELECT  NULL
                FROM    po_requisition_headers RH
                WHERE   RH.requisition_header_id  =
                        PPRL.requisition_header_id
                AND     RH.last_update_date <= p_last_activity_date
                AND     (RH.closed_code = 'FINALLY CLOSED'
                        OR RH.authorization_status = 'CANCELLED')
                AND     NOT EXISTS (
                            SELECT  NULL
                            FROM    po_requisition_lines RL
                            WHERE   RL.requisition_header_id =
                                    RH.requisition_header_id
                            AND     NVL(RL.modified_by_agent_flag,'N') = 'N'
                            AND     (RL.last_update_date > p_last_activity_date
                                     OR
                                     RL.source_type_code = 'INVENTORY'
                                     OR
                                     EXISTS (
                                        SELECT  NULL
                                        FROM    po_price_differentials PPD
                                        WHERE   PPD.entity_type = 'REQ LINE'
                                        AND     PPD.entity_id =
                                                RL.requisition_line_id
                                        AND     PPD.last_update_date >
                                                p_last_activity_date)
                                     OR
                                     EXISTS (
                                        SELECT  NULL
                                        FROM    po_req_distributions RD
                                        WHERE   RD.requisition_line_id =
                                                RL.requisition_line_id
                                        AND     RD.last_update_date >
                                                p_last_activity_date))));
Line: 3650

        SELECT  NVL ( MIN (PPRL.requisition_header_id), -1 ),
                NVL ( MAX (PPRL.requisition_header_id), -1 )
        INTO    x_lower_limit,
                x_upper_limit
        FROM    po_purge_req_list PPRL
        WHERE   PPRL.double_check_flag = 'Y';
Line: 3663

        SELECT  NVL ( MIN (PPL.po_header_id), -1 ),
                NVL ( MAX (PPL.po_header_id), -1 )
        INTO    x_lower_limit,
                x_upper_limit
        FROM    po_purge_po_list PPL
        WHERE   PPL.double_check_flag = 'Y';
Line: 3748

l_range_inserted    VARCHAR2(1);
Line: 3797

            SELECT  'Y'
            INTO    l_range_inserted
            FROM    dual
            WHERE   EXISTS (
                        SELECT  NULL
                        FROM    po_requisition_headers PRH,
                                po_history_requisitions PHR
                        WHERE   PRH.segment1 = PHR.segment1
                        AND     PRH.type_lookup_code = PHR.type_lookup_code
                        AND     PHR.purge_name = p_purge_name
                        AND     PRH.requisition_header_id BETWEEN l_range_low
                                                          AND     l_range_high);
Line: 3813

            l_range_inserted := 'N';
Line: 3822

              message   => 'range inserted = ' || l_range_inserted
            );
Line: 3827

        IF (l_range_inserted = 'N') THEN
            l_progress := '030';
Line: 3836

            INSERT INTO po_history_requisitions
            ( segment1,
              type_lookup_code,
              creation_date,
              requisition_total,
              preparer_name,
              purge_name,
              org_id  -- bug5446437
            )
            SELECT  RH.segment1,
                    RH.type_lookup_code,
                    RH.creation_date,
                    SUM( DECODE (RL.amount,
                                 NULL, RL.quantity * RL.unit_price,
                                 RL.amount)),
                    PAPF.full_name,
                    p_purge_name,
                    RH.org_id -- bug5446437
            FROM    po_purge_req_list PRL,
                    per_all_people_f PAPF,
                    po_requisition_headers RH,
                    po_requisition_lines RL
            WHERE   PRL.requisition_header_id = RH.requisition_header_id
            AND     RH.requisition_header_id = RL.requisition_header_id
            AND     RH.preparer_id = PAPF.person_id
            AND     TRUNC(SYSDATE) BETWEEN PAPF.effective_start_date
                                   AND     PAPF.effective_end_date
            AND     PRL.double_check_flag = 'Y'
            AND     PRL.requisition_header_id BETWEEN l_range_low
                                              AND     l_range_high
            GROUP BY    RH.segment1,
                        RH.type_lookup_code,
                        RH.creation_date,
                        PAPF.full_name,
                        RH.org_id; -- bug5446437
Line: 3873

        END IF; -- l_range_inserted = 'N'
Line: 3951

l_range_inserted    VARCHAR2(1);
Line: 4000

            SELECT  'Y'
            INTO    l_range_inserted
            FROM    dual
            WHERE   EXISTS (
                        SELECT  NULL
                        FROM    po_headers PH,
                                po_history_pos PHP
                        WHERE   PH.segment1 = PHP.segment1
                        AND     PH.type_lookup_code = PHP.type_lookup_code
                        AND     PHP.purge_name = p_purge_name
                        AND     PH.po_header_id BETWEEN l_range_low
                                                AND     l_range_high);
Line: 4016

            l_range_inserted := 'N';
Line: 4025

              message   => 'range inserted = ' || l_range_inserted
            );
Line: 4030

        IF (l_range_inserted = 'N') THEN  -- current batch is not inserted
            l_progress := '030';
Line: 4039

            INSERT INTO po_history_pos
            ( segment1,
              type_lookup_code,
              vendor_id,
              vendor_site_code,
              po_total,
              currency_code,
              agent_name,
              creation_date,
              purge_name,
              org_id -- bug5446437
            )
            SELECT  PH.segment1,
                    PH.type_lookup_code,
                    PH.vendor_id,
                    VDS.vendor_site_code,
                    NVL (ROUND (
                            SUM (
                                DECODE (
                                    PLL.quantity,
                                    NULL,
                                    PLL.amount - NVL(PLL.amount_cancelled, 0),
                                    (PLL.quantity - NVL(PLL.quantity_cancelled,
                                                        0)) *
                                      PLL.price_override)),
                            2),
                         0),
                    PH.currency_code,
                    PAPF.full_name,
                    PH.creation_date,
                    p_purge_name,
                    PH.org_id -- bug5446437
            FROM    per_all_people_f PAPF,
                    po_vendor_sites VDS,
                    po_headers PH,
                    po_line_locations PLL,
                    po_purge_po_list PPL
            WHERE   PPL.po_header_id BETWEEN l_range_low AND l_range_high
            AND     PPL.double_check_flag = 'Y'
            AND     PPL.po_header_id = PH.po_header_id
            AND     NVL(PH.global_agreement_flag, 'N') = 'N'
            AND     PH.type_lookup_code IN ('STANDARD', 'PLANNED', 'BLANKET')
            AND     PH.po_header_id = PLL.po_header_id(+)
            AND     PLL.shipment_type (+) <> 'PRICE BREAK'
            AND     PH.agent_id = PAPF.person_id
            AND     TRUNC(SYSDATE) BETWEEN PAPF.effective_start_date
                                   AND     PAPF.effective_end_date
            AND     PH.vendor_site_id = VDS.vendor_site_id
            GROUP BY  PH.segment1,
                      PH.type_lookup_code,
                      PH.vendor_id,
                      VDS.vendor_site_code,
                      PH.currency_code,
                      PAPF.full_name,
                      PH.creation_date,
                      PH.org_id; -- bug5446437
Line: 4102

                  message   => 'Rows inserted for std/planned po/local bpa:' ||
                               SQL%ROWCOUNT
                );
Line: 4115

            INSERT INTO po_history_pos
            ( segment1,
              type_lookup_code,
              vendor_id,
              vendor_site_code,
              po_total,
              currency_code,
              agent_name,
              creation_date,
              purge_name,
              org_id  -- bug5446437
            )
            SELECT  PH.segment1,
                    PH.type_lookup_code,
                    PH.vendor_id,
                    VDS.vendor_site_code,
                    NVL (ROUND (
                            SUM (
                                DECODE (
                                    PLL.quantity,
                                    NULL,
                                    PLL.amount - NVL(PLL.amount_cancelled, 0),
                                    (PLL.quantity - NVL(PLL.quantity_cancelled,
                                                        0)) *
                                      PLL.price_override)),
                            2),
                         0),
                    PH.currency_code,
                    PAPF.full_name,
                    PH.creation_date,
                    p_purge_name,
                    PH.org_id -- bug5446437
            FROM    per_all_people_f PAPF,
                    po_vendor_sites VDS,
                    po_headers PH,
                    po_line_locations_all PLL,
                    po_purge_po_list PPL
            WHERE   PPL.po_header_id BETWEEN l_range_low AND l_range_high
            AND     PPL.double_check_flag = 'Y'
            AND     PPL.po_header_id = PH.po_header_id
            AND     PH.global_agreement_flag = 'Y'
            AND     PH.type_lookup_code = 'BLANKET'
            AND     PH.po_header_id = PLL.from_header_id(+)
            AND     PH.agent_id = PAPF.person_id
            AND     TRUNC(SYSDATE) BETWEEN PAPF.effective_start_date
                                   AND     PAPF.effective_end_date
            AND     PH.vendor_site_id = VDS.vendor_site_id
            GROUP BY  PH.segment1,
                      PH.type_lookup_code,
                      PH.vendor_id,
                      VDS.vendor_site_code,
                      PH.currency_code,
                      PAPF.full_name,
                      PH.creation_date,
                      PH.org_id; -- bug5446437
Line: 4176

                  message   => 'Rows inserted for gbpa:' || SQL%ROWCOUNT
                );
Line: 4188

            INSERT INTO po_history_pos
            ( segment1,
              type_lookup_code,
              vendor_id,
              vendor_site_code,
              po_total,
              currency_code,
              agent_name,
              creation_date,
              purge_name,
              org_id -- bug5446437
            )
            SELECT  PH.segment1,
                    PH.type_lookup_code,
                    PH.vendor_id,
                    VDS.vendor_site_code,
                    NVL (ROUND (
                            SUM (
                                DECODE (
                                    PLL.quantity,
                                    NULL,
                                    PLL.amount - NVL(PLL.amount_cancelled, 0),
                                    (PLL.quantity - NVL(PLL.quantity_cancelled,
                                                        0)) *
                                      PLL.price_override)),
                            2),
                         0),
                    PH.currency_code,
                    PAPF.full_name,
                    PH.creation_date,
                    p_purge_name,
                    PH.org_id -- bug5446437
            FROM   per_all_people_f PAPF,
                    po_vendor_sites VDS,
                    po_headers PH,
                    po_lines_all POL,
                    po_line_locations_all PLL,
                    po_purge_po_list PPL
            WHERE  PPL.po_header_id BETWEEN l_range_low AND l_range_high
            AND    PPL.double_check_flag = 'Y'
            AND    PPL.po_header_id = PH.po_header_id
            AND    PH.type_lookup_code = 'CONTRACT'
            AND    PH.po_header_id = POL.contract_id (+)
            AND    POL.po_line_id = PLL.po_line_id (+)
            AND    PH.agent_id = PAPF.person_id
            AND    TRUNC(SYSDATE) BETWEEN PAPF.effective_start_date
                                   AND     PAPF.effective_end_date
            AND    PH.vendor_site_id = VDS.vendor_site_id
            GROUP BY PH.segment1,
                      PH.type_lookup_code,
                      PH.vendor_id,
                      VDS.vendor_site_code,
                      PH.currency_code,
                      PAPF.full_name,
                      PH.creation_date,
                      PH.org_id; -- bug5446437
Line: 4250

                  message   => 'Rows inserted for contracts:' || SQL%ROWCOUNT
                );
Line: 4262

            INSERT INTO po_history_pos
            ( segment1,
              type_lookup_code,
              vendor_id,
              vendor_site_code,
              release_num,
              po_total,
              currency_code,
              agent_name,
              creation_date,
              purge_name,
              org_id -- bug5446437
            )
            SELECT  PH.segment1,
                    PH.type_lookup_code,
                    PH.vendor_id,
                    VDS.vendor_site_code,
                    PREL.release_num,
                    NVL (ROUND (
                            SUM (
                                DECODE (
                                    PLL.quantity,
                                    NULL,
                                    PLL.amount - NVL(PLL.amount_cancelled, 0),
                                    (PLL.quantity - NVL(PLL.quantity_cancelled,
                                                        0)) *
                                      PLL.price_override)),
                            2),
                         0),
                    PH.currency_code,
                    PAPF.full_name,
                    PH.creation_date,
                    p_purge_name,
                    PH.org_id -- bug5446437
            FROM    po_vendor_sites VDS,
                    per_all_people_f PAPF,
                    po_releases PREL,
                    po_headers PH,
                    po_line_locations PLL,
                    po_purge_po_list PPL
            WHERE   PPL.po_header_id = PH.po_header_id
            AND     PH.po_header_id = PREL.po_header_id
            AND     PREL.po_release_id = PLL.po_release_id
            AND     PLL.shipment_type IN ('SCHEDULED', 'BLANKET')
            AND     PH.vendor_site_id = VDS.vendor_site_id
            AND     PH.agent_id = PAPF.person_id
            AND     TRUNC(SYSDATE) BETWEEN PAPF.effective_start_date
                                   AND     PAPF.effective_end_date
            AND     PPL.double_check_flag = 'Y'
            AND     PPL.po_header_id BETWEEN l_range_low
                                     AND     l_range_high
            GROUP BY  PH.segment1,
                      PH.type_lookup_code,
                      PH.vendor_id,
                      VDS.vendor_site_code,
                      PREL.release_num,
                      PH.currency_code,
                      PAPF.full_name,
                      PH.creation_date,
                      PH.org_id; -- bug5446437
Line: 4328

                  message   => 'Rows inserted for releases: ' || SQL%ROWCOUNT
                );
Line: 4334

        END IF;  -- l_range_inserted = 'N'
Line: 4395

PROCEDURE delete_reqs
( x_return_status       OUT NOCOPY  VARCHAR2,
  p_range_size          IN          NUMBER,
  p_req_lower_limit     IN          NUMBER,
  p_req_upper_limit     IN          NUMBER
) IS

TYPE num_tbltyp IS TABLE OF NUMBER;
Line: 4406

l_api_name      VARCHAR2(50) := 'delete_reqs';
Line: 4441

    SELECT  PPRL2.req_header_id
    BULK COLLECT INTO l_ids_tbl
    FROM    (SELECT PPRL.requisition_header_id req_header_id,
                    MOD(ROWNUM, p_range_size) mod_result
             FROM   po_purge_req_list PPRL
             WHERE  PPRL.double_check_flag = 'Y'
             ORDER BY PPRL.requisition_header_id) PPRL2
    WHERE   PPRL2.mod_result = 0;
Line: 4477

        PO_AP_PURGE_UTIL_PVT.delete_req_related_records
        ( x_return_status   => l_return_status,
          p_range_low       => l_range_low,
          p_range_high      => l_range_high
        );
Line: 4490

        DELETE
        FROM    po_requisition_headers RH
        WHERE   EXISTS (
                    SELECT  NULL
                    FROM    po_purge_req_list PPRL
                    WHERE   PPRL.requisition_header_id =
                            RH.requisition_header_id
                    AND     PPRL.double_check_flag = 'Y'
                    AND     PPRL.requisition_header_id BETWEEN l_range_low
                                                       AND     l_range_high);
Line: 4506

              message   => 'Deleted ' || SQL%ROWCOUNT || ' rec from RH'
            );
Line: 4514

        DELETE
        FROM    po_req_distributions RD
        WHERE   EXISTS (
                    SELECT  NULL
                    FROM    po_purge_req_list PPRL,
                            po_requisition_lines RL
                    WHERE   PPRL.requisition_header_id =
                            RL.requisition_header_id
                    AND     RL.requisition_line_id =
                            RD.requisition_line_id
                    AND     PPRL.double_check_flag = 'Y'
                    AND     PPRL.requisition_header_id BETWEEN l_range_low
                                                       AND     l_range_high);
Line: 4533

              message   => 'Deleted ' || SQL%ROWCOUNT || ' rec from RD'
            );
Line: 4541

        DELETE
        FROM    po_requisition_lines RL
        WHERE   EXISTS (
                    SELECT  NULL
                    FROM    po_purge_req_list PPRL
                    WHERE   PPRL.requisition_header_id =
                            RL.requisition_header_id
                    AND     PPRL.double_check_flag = 'Y'
                    AND     PPRL.requisition_header_id BETWEEN l_range_low
                                                       AND     l_range_high);
Line: 4557

              message   => 'Deleted ' || SQL%ROWCOUNT || ' rec from RL'
            );
Line: 4564

        DELETE
        FROM    po_action_history PA
        WHERE   PA.object_type_code = 'REQUISITION'
        AND     EXISTS (
                    SELECT  NULL
                    FROM    po_purge_req_list PPRL
                    WHERE   PPRL.requisition_header_id = PA.object_id
                    AND     PPRL.double_check_flag = 'Y'
                    AND     PPRL.requisition_header_id BETWEEN l_range_low
                                                       AND     l_range_high);
Line: 4580

              message   => 'Deleted ' || SQL%ROWCOUNT || ' rec frm act_history'
            );
Line: 4615

END delete_reqs;
Line: 4645

PROCEDURE delete_pos
( x_return_status       OUT NOCOPY  VARCHAR2,
  p_range_size          IN          NUMBER,
  p_po_lower_limit      IN          NUMBER,
  p_po_upper_limit      IN          NUMBER
) IS

TYPE num_tbltyp IS TABLE OF NUMBER;
Line: 4663

l_api_name      VARCHAR2(50) := 'delete_pos';
Line: 4700

    SELECT  PPL2.po_header_id
    BULK COLLECT INTO l_ids_tbl
    FROM    (SELECT PPL.po_header_id po_header_id,
                    MOD(ROWNUM, p_range_size) mod_result
             FROM   po_purge_po_list PPL
             WHERE  PPL.double_check_flag = 'Y'
             ORDER BY PPL.po_header_id) PPL2
    WHERE   PPL2.mod_result = 0;
Line: 4736

        PO_AP_PURGE_UTIL_PVT.delete_po_related_records
        ( x_return_status   => l_return_status,
          p_range_low       => l_range_low,
          p_range_high      => l_range_high
        );
Line: 4749

        DELETE
        FROM    po_headers PH
        WHERE   EXISTS (
                    SELECT  NULL
                    FROM    po_purge_po_list PPL
                    WHERE   PPL.po_header_id = PH.po_header_id
                    AND     PPL.double_check_flag = 'Y'
                    AND     PPL.po_header_id BETWEEN l_range_low
                                             AND     l_range_high)
        --
        RETURNING po_header_id, type_lookup_code
        BULK COLLECT INTO l_po_header_id_tbl, l_type_lookup_code_tbl;
Line: 4768

              message   => 'Deleted ' || SQL%ROWCOUNT || ' rec from PH'
            );
Line: 4776

        DELETE
        FROM    po_headers_archive PHA
        WHERE   EXISTS (
                    SELECT  NULL
                    FROM    po_purge_po_list PPL
                    WHERE   PPL.po_header_id = PHA.po_header_id
                    AND     PPL.double_check_flag = 'Y'
                    AND     PPL.po_header_id BETWEEN l_range_low
                                             AND     l_range_high);
Line: 4791

              message   => 'Deleted ' || SQL%ROWCOUNT || ' rec from PHA'
            );
Line: 4799

        DELETE
        FROM    po_lines PL
        WHERE   EXISTS (
                    SELECT  NULL
                    FROM    po_purge_po_list PPL
                    WHERE   PPL.po_header_id = PL.po_header_id
                    AND     PPL.double_check_flag = 'Y'
                    AND     PPL.po_header_id BETWEEN l_range_low
                                             AND     l_range_high);
Line: 4814

              message   => 'Deleted ' || SQL%ROWCOUNT || ' rec from PL'
            );
Line: 4823

          DELETE
          FROM    PO_ATTRIBUTE_VALUES POATR
          WHERE   EXISTS (
                      SELECT  NULL
                      FROM    po_purge_po_list PPL,
                              po_lines_all POL
                      WHERE   PPL.po_header_id = POL.po_header_id
                      AND     POATR.po_line_id = POL.po_line_id
                      AND     PPL.double_check_flag = 'Y'
                      AND     PPL.po_header_id BETWEEN l_range_low
                                               AND     l_range_high);
Line: 4840

                message   => 'Deleted ' || SQL%ROWCOUNT || ' rec from POATR'
              );
Line: 4848

          DELETE
          FROM    PO_ATTRIBUTE_VALUES_TLP POTLP
          WHERE   EXISTS (
                      SELECT  NULL
                      FROM    po_purge_po_list PPL,
                              po_lines_all POL
                      WHERE   PPL.po_header_id = POL.po_header_id
                      AND     POTLP.po_line_id = POL.po_line_id
                      AND     PPL.double_check_flag = 'Y'
                      AND     PPL.po_header_id BETWEEN l_range_low
                                               AND     l_range_high);
Line: 4865

                message   => 'Deleted ' || SQL%ROWCOUNT || ' rec from POTLP'
              );
Line: 4874

        DELETE
        FROM    po_lines_archive PLA
        WHERE   EXISTS (
                    SELECT  NULL
                    FROM    po_purge_po_list PPL
                    WHERE   PPL.po_header_id = PLA.po_header_id
                    AND     PPL.double_check_flag = 'Y'
                    AND     PPL.po_header_id BETWEEN l_range_low
                                             AND     l_range_high);
Line: 4889

              message   => 'Deleted ' || SQL%ROWCOUNT || ' rec from PLA'
            );
Line: 4898

          DELETE
          FROM    PO_ATTR_VALUES_ARCHIVE POATRA
          WHERE   EXISTS (
                      SELECT  NULL
                      FROM    po_purge_po_list PPL,
                              po_lines_all POL
                      WHERE   PPL.po_header_id = POL.po_header_id
                      AND     POATRA.po_line_id = POL.po_line_id
                      AND     PPL.double_check_flag = 'Y'
                      AND     PPL.po_header_id BETWEEN l_range_low
                                               AND     l_range_high);
Line: 4915

                message   => 'Deleted ' || SQL%ROWCOUNT || ' rec from POATRA'
              );
Line: 4923

          DELETE
          FROM    PO_ATTR_VALUES_TLP_ARCHIVE POTLPA
          WHERE   EXISTS (
                      SELECT  NULL
                      FROM    po_purge_po_list PPL,
                              po_lines_all POL
                      WHERE   PPL.po_header_id = POL.po_header_id
                      AND     POTLPA.po_line_id = POL.po_line_id
                      AND     PPL.double_check_flag = 'Y'
                      AND     PPL.po_header_id BETWEEN l_range_low
                                               AND     l_range_high);
Line: 4940

                message   => 'Deleted ' || SQL%ROWCOUNT || ' rec from POTLPA'
              );
Line: 4949

        DELETE
        FROM    po_line_locations PLL
        WHERE   EXISTS (
                    SELECT  NULL
                    FROM    po_purge_po_list PPL
                    WHERE   PPL.po_header_id = PLL.po_header_id
                    AND     PPL.double_check_flag = 'Y'
                    AND     PPL.po_header_id BETWEEN l_range_low
                                             AND     l_range_high);
Line: 4964

              message   => 'Deleted ' || SQL%ROWCOUNT || ' rec from PLL'
            );
Line: 4972

        DELETE
        FROM    po_line_locations_archive PLLA
        WHERE   EXISTS (
                    SELECT  NULL
                    FROM    po_purge_po_list PPL
                    WHERE   PPL.po_header_id = PLLA.po_header_id
                    AND     PPL.double_check_flag = 'Y'
                    AND     PPL.po_header_id BETWEEN l_range_low
                                             AND     l_range_high);
Line: 4987

              message   => 'Deleted ' || SQL%ROWCOUNT || ' rec from PLLA'
            );
Line: 4995

        DELETE
        FROM    po_distributions PD
        WHERE   EXISTS (
                    SELECT  NULL
                    FROM    po_purge_po_list PPL
                    WHERE   PPL.po_header_id = PD.po_header_id
                    AND     PPL.double_check_flag = 'Y'
                    AND     PPL.po_header_id BETWEEN l_range_low
                                             AND     l_range_high);
Line: 5010

              message   => 'Deleted ' || SQL%ROWCOUNT || ' rec from PD'
            );
Line: 5018

        DELETE
        FROM    po_distributions_archive PDA
        WHERE   EXISTS (
                    SELECT  NULL
                    FROM    po_purge_po_list PPL
                    WHERE   PPL.po_header_id = PDA.po_header_id
                    AND     PPL.double_check_flag = 'Y'
                    AND     PPL.po_header_id BETWEEN l_range_low
                                             AND     l_range_high);
Line: 5033

              message   => 'Deleted ' || SQL%ROWCOUNT || ' rec from PDA'
            );
Line: 5041

        DELETE
        FROM    po_releases PR
        WHERE   EXISTS (
                    SELECT  NULL
                    FROM    po_purge_po_list PPL
                    WHERE   PPL.po_header_id = PR.po_header_id
                    AND     PPL.double_check_flag = 'Y'
                    AND     PPL.po_header_id BETWEEN l_range_low
                                             AND     l_range_high)
        --
        RETURNING po_release_id
        BULK COLLECT INTO l_po_release_id_tbl;
Line: 5061

              message   => 'Deleted ' || SQL%ROWCOUNT || ' rec from PR'
            );
Line: 5069

        DELETE
        FROM    po_releases_archive PRA
        WHERE   EXISTS (
                    SELECT  NULL
                    FROM    po_purge_po_list PPL
                    WHERE   PPL.po_header_id = PRA.po_header_id
                    AND     PPL.double_check_flag = 'Y'
                    AND     PPL.po_header_id BETWEEN l_range_low
                                             AND     l_range_high);
Line: 5084

              message   => 'Deleted ' || SQL%ROWCOUNT || ' rec from PRA'
            );
Line: 5092

        DELETE
        FROM    po_acceptances PA
        WHERE   EXISTS (
                    SELECT  NULL
                    FROM    po_purge_po_list PPL
                    WHERE   PPL.po_header_id = PA.po_header_id
                    AND     PPL.double_check_flag = 'Y'
                    AND     PPL.po_header_id BETWEEN l_range_low
                                             AND     l_range_high);
Line: 5107

              message   => 'Deleted ' || SQL%ROWCOUNT || ' rec from po_accept'
            );
Line: 5115

        DELETE
        FROM    po_action_history PAH
        WHERE   PAH.object_type_code = 'PO'
        AND     EXISTS (
                    SELECT  NULL
                    FROM    po_purge_po_list PPL
                    WHERE   PPL.po_header_id = PAH.object_id
                    AND     PPL.double_check_flag = 'Y'
                    AND     PPL.po_header_id BETWEEN l_range_low
                                             AND     l_range_high);
Line: 5131

              message   => 'Deleted ' || SQL%ROWCOUNT || ' rec frm act_history'
            );
Line: 5140

        UPDATE  po_requisition_lines_all PRL
        SET     PRL.blanket_po_header_id = NULL,
                PRL.blanket_po_line_num = NULL,
                PRL.last_update_date = SYSDATE,
                PRL.last_updated_by = FND_GLOBAL.user_id,
                PRL.last_update_login = FND_GLOBAL.login_id
        WHERE   PRL.blanket_po_header_id IS NOT NULL
        AND     PRL.blanket_po_header_id IN (
                        SELECT  po_header_id
                        FROM    po_purge_po_list PPL
                        WHERE   PPL.double_check_flag = 'Y'
                        AND     PPL.po_header_id BETWEEN l_range_low
                                                 AND     l_range_high);
Line: 5165

          insert into zx_purge_transactions_gt(
            application_id,
            entity_code,
            event_class_code,
            trx_id
          )
          select
            fnd_global.resp_appl_id(),
            PO_CONSTANTS_SV.PO_ENTITY_CODE,
            PO_CONSTANTS_SV.PO_EVENT_CLASS_CODE,
            l_po_header_id_tbl(i)
          from dual
          where l_type_lookup_code_tbl(i) IN ('STANDARD', 'PLANNED');
Line: 5180

          insert into zx_purge_transactions_gt(
            application_id,
            entity_code,
            event_class_code,
            trx_id
          )
          select
            fnd_global.resp_appl_id(),
            PO_CONSTANTS_SV.REL_ENTITY_CODE,
            PO_CONSTANTS_SV.REL_EVENT_CLASS_CODE,
            l_po_release_id_tbl(i)
          from dual;
Line: 5338

END delete_pos;