DBA Data[Home] [Help]

APPS.GMD_SPREADSHEET_UPDATE SQL Statements

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

Line: 14

  PROCEDURE lock_formula_hdr (p_formula_id IN NUMBER, p_last_update_date IN DATE, X_return_status OUT NOCOPY VARCHAR2) IS
    CURSOR Cur_lock_header IS
      SELECT last_update_date
      FROM   fm_form_mst
      WHERE  formula_id = P_formula_id
      FOR UPDATE OF LAST_UPDATE_DATE NOWAIT;
Line: 20

    X_last_update_date  DATE;
Line: 24

    FETCH Cur_lock_header INTO X_last_update_date;
Line: 26

    IF X_last_update_date <> P_last_update_date THEN
      FND_MESSAGE.SET_NAME('GMD', 'GMD_RECORD_CHANGED');
Line: 44

      fnd_msg_pub.add_exc_msg ('GMD_SPREADSHEET_UPDATE', 'Lock_Formula_Hdr');
Line: 57

  PROCEDURE lock_formula_dtl (P_formulaline_id IN NUMBER, P_last_update_date IN DATE,
                            X_return_status OUT NOCOPY VARCHAR2) IS
    CURSOR Cur_lock_details IS
      SELECT last_update_date
      FROM   fm_matl_dtl
      WHERE  formulaline_id = P_formulaline_id
      FOR UPDATE OF LAST_UPDATE_DATE NOWAIT;
Line: 64

    X_last_update_date  DATE;
Line: 68

    FETCH Cur_lock_details INTO X_last_update_date;
Line: 70

    IF X_last_update_date <> P_last_update_date THEN
      FND_MESSAGE.SET_NAME('GMD', 'GMD_RECORD_CHANGED');
Line: 88

      fnd_msg_pub.add_exc_msg ('GMD_SPREADSHEET_UPDATE', 'Lock_Formula_Dtl');
Line: 103

      SELECT last_update_date
      FROM   gmd_material_header_gtmp
      WHERE  formula_id = P_formula_id;
Line: 108

      SELECT formulaline_id, last_update_date
       FROM  gmd_material_details_gtmp
       WHERE line_type <> 3
       ORDER BY line_type, line_no;
Line: 112

    l_last_update_date	DATE;
Line: 119

    FETCH Cur_get_hdr INTO  l_last_update_date;
Line: 122

                    ,P_last_update_date => l_last_update_date
                    ,X_return_status => l_return_status);
Line: 130

                         ,P_last_update_date => l_rec.last_update_date
                         ,X_return_status => l_return_status);
Line: 142

      fnd_msg_pub.add_exc_msg ('GMD_SPREADSHEET_UPDATE', 'Lock_formula_Record');
Line: 156

  PROCEDURE lock_batch_hdr (P_batch_id IN NUMBER, P_last_update_date IN DATE, X_return_status OUT NOCOPY VARCHAR2) IS
    CURSOR Cur_lock_header IS
      SELECT last_update_date
      FROM   gme_batch_header
      WHERE  batch_id = P_batch_id
      FOR UPDATE OF LAST_UPDATE_DATE NOWAIT;
Line: 162

    X_last_update_date  DATE;
Line: 166

    FETCH Cur_lock_header INTO X_last_update_date;
Line: 168

    IF X_last_update_date <> P_last_update_date THEN
      FND_MESSAGE.SET_NAME('GME', 'GME_RECORD_CHANGED');
Line: 186

      fnd_msg_pub.add_exc_msg ('GMD_SPREADSHEET_UPDATE', 'Lock_Batch_Hdr');
Line: 199

  PROCEDURE lock_batch_dtl (P_material_detail_id IN NUMBER, P_last_update_date IN DATE,
                            X_return_status OUT NOCOPY VARCHAR2) IS
    CURSOR Cur_lock_details IS
      SELECT last_update_date
      FROM   gme_material_details
      WHERE  material_detail_id = P_material_detail_id
      FOR UPDATE OF LAST_UPDATE_DATE NOWAIT;
Line: 206

    X_last_update_date  DATE;
Line: 210

    FETCH Cur_lock_details INTO X_last_update_date;
Line: 213

    IF X_last_update_date <> P_last_update_date THEN
      FND_MESSAGE.SET_NAME('GME', 'GME_RECORD_CHANGED');
Line: 231

      fnd_msg_pub.add_exc_msg ('GMD_SPREADSHEET_UPDATE', 'Lock_Batch_Dtl');
Line: 247

      SELECT last_update_date
      FROM   gmd_material_header_gtmp
      WHERE  batch_id = P_batch_id;
Line: 252

      SELECT material_detail_id, last_update_date
       FROM  gmd_material_details_gtmp
       WHERE line_type <> 3
       ORDER BY line_type, line_no;
Line: 256

    l_last_update_date	DATE;
Line: 263

    FETCH Cur_get_hdr INTO  l_last_update_date;
Line: 266

                  ,P_last_update_date => l_last_update_date
                  ,X_return_status => l_return_status);
Line: 274

                       ,P_last_update_date => l_rec.last_update_date
                       ,X_return_status => l_return_status);
Line: 286

      fnd_msg_pub.add_exc_msg ('GMD_SPREADSHEET_UPDATE', 'Lock_Batch_Record');
Line: 294

  #	update_batch
  # SYNOPSIS
  #	proc   update_batch
  # DESCRIPTION
  #      This procedure is used to update the batch.
  # HISTORY
  #      22-AUG-06 Kapil M Bug# 3927768
  #      Changed the IF condition to update lot for the items.
  #      19-SEP-06 Kapil M Bug# 3927768
  #      Modified in deletion, updation and creation go product_pending_lots
  ###############################################################*/

  PROCEDURE update_batch (P_batch_id IN NUMBER, X_return_status OUT NOCOPY VARCHAR2) IS

    CURSOR Cur_get_batch IS
      SELECT *
      FROM   gme_batch_header
      WHERE  batch_id = P_batch_id;
Line: 314

      SELECT material_detail_id
      FROM   gme_material_details e
      WHERE  batch_id = P_batch_id
      AND    line_type <> 1
      AND    NOT EXISTS (SELECT 1
                         FROM   gmd_material_details_gtmp g
                         WHERE  line_type <> 3
                         AND    g.material_detail_id = e.material_detail_id);
Line: 324

      SELECT *
      FROM   gmd_material_details_gtmp
      WHERE  line_type <> 3
      ORDER BY line_type, line_no;
Line: 330

      SELECT  1
      FROM    gme_material_details
      WHERE   batch_id = P_batch_id
              AND material_detail_id = V_material_detail_id;
Line: 338

      SELECT *
      FROM   gmd_material_details_gtmp
      WHERE  line_type = 3
      AND    material_detail_id = V_material_detail_id;
Line: 345

      SELECT quantity
      FROM   gme_pending_product_lots
      WHERE  batch_id = P_batch_id
             AND pending_product_lot_id = p_lot_id;
Line: 352

      SELECT material_detail_id, pending_product_lot_id
      FROM   gme_pending_product_lots e
      WHERE  batch_id = P_batch_id
      AND    material_detail_id = V_material_detail_id
      AND    NOT EXISTS (SELECT 1
                         FROM   gmd_material_details_gtmp g
                         WHERE  parent_line_id = V_material_detail_id
                         AND    g.trans_id = e.pending_product_lot_id
                         AND    line_type = 3);
Line: 363

      SELECT pending_product_lot_id
      FROM   gme_pending_product_lots
      WHERE  batch_id = P_batch_id
      AND    material_detail_id = V_material_detail_id;
Line: 369

      SELECT material_detail_id,text_code,orginal_text_code
      FROM   gmd_material_details_gtmp
      WHERE  text_code <> NVL(orginal_text_code,0);
Line: 406

    update_alloc_err	EXCEPTION;
Line: 407

    insert_line_err	EXCEPTION;
Line: 408

    update_line_err	EXCEPTION;
Line: 409

    delete_line_err	EXCEPTION;
Line: 414

    SAVEPOINT  update_batch;
Line: 439

    /* First let us delete all the lines which existed in the batch */
    /* but was deleted from the spreadsheet                         */
    FOR l_del_matl_rec IN Cur_get_del_material LOOP
      l_material_detail.material_detail_id := l_del_matl_rec.material_detail_id;
Line: 444

      gme_material_detail_pvt.delete_material_line (p_batch_header_rec    => l_batch_row
 						   ,p_material_detail_rec => l_material_detail
                                                   ,p_batch_step_rec      => l_batch_step
                                                   ,x_transacted          => l_transacted
                                                   ,x_return_status       => l_return_status);
Line: 450

        RAISE delete_line_err;
Line: 462

        /* This implies that this is a new line we need to first insert the material line */
        l_material_detail.batch_id 		:= p_batch_id;
Line: 482

        gmd_debug.put_line(' Inserting line for batch:'||l_material_detail.batch_id||' Item:'||l_material_detail.inventory_item_id);
Line: 483

        gme_material_detail_pvt.insert_material_line (p_batch_header_rec    => l_batch_row
 						     ,p_material_detail_rec => l_material_detail
                                                     ,p_batch_step_rec      => l_batch_step
                                                     ,p_trans_id            => NULL
                                                     ,x_transacted          => l_transacted
                                                     ,x_return_status       => l_return_status
                                                     ,x_material_detail_rec => l_material_out);
Line: 491

          gmd_debug.put_line(' Insert material line error: Item:'||l_material_detail.inventory_item_id);
Line: 492

          RAISE insert_line_err;
Line: 495

          UPDATE gmd_material_details_gtmp
          SET material_detail_id = l_matl_rec.material_detail_id,
              parent_line_id = l_matl_rec.material_detail_id
          WHERE parent_line_id = l_matl_rec.parent_line_id;
Line: 509

          gme_material_detail_pvt.update_material_line (p_batch_header_rec    => l_batch_row
 						       ,p_material_detail_rec => X_material
 						       ,p_stored_material_detail_rec => NULL
                                                       ,p_batch_step_rec      => l_batch_step
                                                       ,p_scale_phantom       => fnd_api.g_false
                                                       ,p_trans_id            => NULL
                                                       ,x_transacted          => l_transacted
                                                       ,x_return_status       => l_return_status
                                                       ,x_material_detail_rec => l_material_out);
Line: 519

            gmd_debug.put_line(' Insert material line error: Material id:'||l_material_detail.material_detail_id);
Line: 520

            RAISE update_line_err;
Line: 526

      IF (l_batch_row.update_inventory_ind = 'Y') THEN
        update_allocation (P_plant_Id	 	=> l_batch_row.organization_id
                          ,P_batch_id 		=> l_batch_row.batch_id
                          ,P_material_detail_id	=> l_matl_rec.material_detail_id
                          ,P_line_type		=> l_matl_rec.line_type
                          ,X_return_status	=> l_return_status);
Line: 533

          RAISE update_alloc_err;
Line: 543

          gme_api_pub.delete_pending_product_lot (p_api_version              => 2.0,
                                                  x_message_count            => l_message_count,
                                                  x_message_list             => l_message_list,
                                                  x_return_status 	     => l_return_status,
                                                  p_batch_header_rec         => l_batch_rec,
                                                  p_org_code 		     => NULL,
                                                  p_material_detail_rec      => l_material_rec,
                                                  p_pending_product_lots_rec => l_pending_in_rec);
Line: 552

             gmd_debug.put_line(' Insert pending lot error: Material id:'||l_matl_rec.material_detail_id ||
                                'lot_number: '||l_pending_in_rec.lot_number);
Line: 554

             RAISE update_line_err;
Line: 570

          l_pending_in_rec.last_updated_by := l_labrec.last_updated_by;
Line: 571

          l_pending_in_rec.last_update_date := l_labrec.last_update_date;
Line: 572

         /* Let us check the lab batch lot is already existing if yes update the line */
        -- Bug# 3927768 Kapil M
        -- Records fetched based on the pending_lot_id
         OPEN Cur_get_lab_material(l_labrec.trans_id);
Line: 582

           gme_api_pub.update_pending_product_lot (p_api_version              => 2.0,
                                                   x_message_count            => l_message_count,
                                                   x_message_list             => l_message_list,
                                                   x_return_status 	      => l_return_status,
                                                   p_batch_header_rec         => l_batch_rec,
                                                   p_org_code 		      => NULL,
                                                   p_material_detail_rec      => l_material_rec,
                                                   p_pending_product_lots_rec => l_pending_in_rec,
                                                   x_pending_product_lots_rec => l_pending_out_rec);
Line: 592

                gmd_debug.put_line(' Insert pending lot error: Material id:'||l_matl_rec.material_detail_id ||
                                     'lot_number: '||l_pending_in_rec.lot_number);
Line: 594

                RAISE update_line_err;
Line: 598

           /* Let us check the lab batch lot is already existing if not insert the new line */
           l_pending_in_rec.pending_product_lot_id := NULL;
Line: 611

            gmd_debug.put_line(' Insert pending lot error: Material id:'||l_matl_rec.material_detail_id ||
                               'lot_number: '||l_pending_in_rec.lot_number);
Line: 613

            RAISE update_line_err;
Line: 627

          UPDATE gme_material_details
          SET    text_code = l_text_code
          WHERE  material_detail_id = l_rec.material_detail_id;
Line: 634

        GMA_EDITTEXT_PKG.Delete_Text(l_rec.orginal_text_code,'GME_TEXT_TABLE_TL');
Line: 638

    update gmd_material_details_gtmp a
    set last_update_date = (select last_update_date
                            FROM gme_material_details
                            WHERE material_detail_id = a.material_detail_id);
Line: 644

      ROLLBACK TO SAVEPOINT update_batch;
Line: 646

    WHEN error_load_batch OR update_alloc_err OR insert_line_err OR update_line_err
         OR delete_line_err OR lock_batch_err THEN
      ROLLBACK TO SAVEPOINT update_batch;
Line: 651

      ROLLBACK TO SAVEPOINT update_batch;
Line: 652

      fnd_msg_pub.add_exc_msg (gmd_spreadsheet_update.g_pkg_name, 'Update_Batch');
Line: 654

  END update_batch;
Line: 658

  #	update_allocation
  # SYNOPSIS
  #	proc   update_allocation
  # DESCRIPTION
  #      This procedure is used to update the allocations for the batch.
  ###############################################################*/

  PROCEDURE update_allocation (P_plant_id		IN	NUMBER,
  			       P_batch_id		IN	NUMBER,
                               P_material_detail_id 	IN 	NUMBER,
                               P_line_type		IN	NUMBER,
                               X_return_status OUT NOCOPY VARCHAR2) IS

    CURSOR  Cur_get_del_lines (V_material_detail_id NUMBER) IS
      SELECT *
      FROM   mtl_reservations e
      WHERE  demand_source_header_id = P_batch_id
      AND    demand_source_line_id = V_material_detail_id
      AND    demand_source_type_id = gme_common_pvt.g_txn_source_type
      AND    NOT EXISTS (SELECT 1
                         FROM   gmd_material_details_gtmp g
                         WHERE  parent_line_id = V_material_detail_id
                         AND    line_type = 3
                         AND    g.reservation_id =  e.reservation_id);
Line: 684

      SELECT *
       FROM  gmd_material_details_gtmp
       WHERE parent_line_id = V_material_detail_id
       AND   line_type = 3
       AND   transaction_id IS NULL
       ORDER BY line_no desc;
Line: 692

      SELECT revision,inventory_item_id
       FROM  gmd_material_details_gtmp
       WHERE material_detail_id = V_material_detail_id;
Line: 697

      SELECT revision_qty_control_code
       FROM  mtl_system_items_b
       WHERE inventory_item_id = V_item_id
             AND organization_id = P_plant_id;
Line: 703

      SELECT revision
       FROM  mtl_item_revisions
       WHERE inventory_item_id = V_item_id
             AND organization_id = P_plant_id
       ORDER BY CREATION_DATE DESC;
Line: 710

      SELECT reservation_quantity
      FROM   mtl_reservations
      WHERE  reservation_id = V_reservation_id;
Line: 715

      SELECT material_requirement_date
      FROM   gme_material_details
      WHERE  material_detail_id = P_material_detail_id;
Line: 720

      SELECT qty,transaction_id,lot_number
      FROM   gmd_material_details_gtmp
      WHERE  material_detail_id = P_material_detail_id
      AND    lot_number IS NOT NULL;
Line: 726

      SELECT transaction_quantity
      FROM   mtl_transaction_lot_numbers
      WHERE  transaction_id = V_transaction_id
      AND    lot_number = V_lot_number;
Line: 741

    update_alloc_err	EXCEPTION;
Line: 742

    insert_alloc_err	EXCEPTION;
Line: 743

    delete_alloc_err	EXCEPTION;
Line: 744

    trans_update	EXCEPTION;
Line: 757

        RAISE trans_update;
Line: 761

    /* First let us delete all the reservations which existed in the batch */
    /* but was deleted from the spreadsheet.                               */
    IF P_line_type <> 1 THEN
      FOR l_del_rec IN Cur_get_del_lines (P_material_detail_id) LOOP
        gmd_debug.put_line(' Material:'||P_material_detail_id||' trans:'||l_del_rec.reservation_id||' reserv qty:'||l_del_rec.reservation_quantity||' Lot:'||l_del_rec.lot_number);
Line: 766

        gme_reservations_pvt.delete_reservation(p_reservation_id => l_del_rec.reservation_id
                                                ,x_return_status => l_return_status);
Line: 769

          gmd_debug.put_line('Delete allocation error:'||l_del_rec.reservation_id);
Line: 770

          RAISE delete_alloc_err;
Line: 775

    /* Then let us update/insert the reservation lines associated with the material line */
    FOR l_rec IN Cur_get_lines (P_material_detail_id) LOOP
      OPEN Cur_req_date;
Line: 813

      /* Let us update the existing reservations */
      IF l_rec.reservation_id IS NOT NULL THEN
        OPEN Cur_get_qty (l_rec.reservation_id);
Line: 819

          gme_reservations_pvt.update_reservation (p_reservation_id => l_rec.reservation_id
                                                  ,p_revision       => l_revision
                                                  ,p_subinventory   => l_rec.subinventory_code
                                                  ,p_locator_id     => l_rec.locator_id
                                                  ,p_lot_number     => l_rec.lot_number
                                                  ,p_new_qty        => l_rec.qty
                                                  ,p_new_sec_qty    => ABS(l_rec.secondary_qty)
                                                  ,p_new_uom        => l_rec.detail_uom
                                                  ,p_new_date       => SYSDATE
                                                  ,x_return_status  => l_return_status);
Line: 830

            gmd_debug.put_line('Update allocation error:'||l_rec.reservation_id);
Line: 831

            RAISE update_alloc_err;
Line: 845

          gmd_debug.put_line(' Insert alloc fail'||l_return_status);
Line: 846

          RAISE insert_alloc_err;
Line: 852

    WHEN update_alloc_err OR insert_alloc_err OR delete_alloc_err THEN
      X_return_status := l_return_status;
Line: 854

    WHEN trans_update THEN
      gmd_api_grp.log_message('GMD_QTY_NO_UPDATE');
Line: 858

      fnd_msg_pub.add_exc_msg (gmd_spreadsheet_update.g_pkg_name, 'Update_Allocation');
Line: 860

  END update_allocation;