1: PACKAGE BODY PO_NOTIFICATION_CTRL_DRAFT_PKG AS
2: /* $Header: PO_NOTIFICATION_CTRL_DRAFT_PKG.plb 120.5 2006/09/28 23:04:57 bao noship $ */
3:
4: d_pkg_name CONSTANT varchar2(50) :=
5: PO_LOG.get_package_base('PO_NOTIFICATION_CTRL_DRAFT_PKG');
6:
7: -----------------------------------------------------------------------
8: --Start of Comments
9: --Name: delete_rows
40:
41: BEGIN
42:
43: d_position := 0;
44: IF (PO_LOG.d_proc) THEN
45: PO_LOG.proc_begin(d_module);
46: END IF;
47:
48: DELETE FROM po_notification_ctrl_draft
41: BEGIN
42:
43: d_position := 0;
44: IF (PO_LOG.d_proc) THEN
45: PO_LOG.proc_begin(d_module);
46: END IF;
47:
48: DELETE FROM po_notification_ctrl_draft
49: WHERE draft_id = p_draft_id
104: l_duplicate_flag_tbl PO_TBL_VARCHAR1 := PO_TBL_VARCHAR1();
105:
106: BEGIN
107: d_position := 0;
108: IF (PO_LOG.d_proc) THEN
109: PO_LOG.proc_begin(d_module);
110: END IF;
111:
112: x_record_already_exist_tbl :=
105:
106: BEGIN
107: d_position := 0;
108: IF (PO_LOG.d_proc) THEN
109: PO_LOG.proc_begin(d_module);
110: END IF;
111:
112: x_record_already_exist_tbl :=
113: PO_NOTIFICATION_CTRL_DRAFT_PVT.draft_changes_exist
141: END LOOP;
142: -- bug5471513 END
143:
144: d_position := 10;
145: IF (PO_LOG.d_stmt) THEN
146: PO_LOG.stmt(d_module, d_position, 'transfer records from txn to dft');
147: END IF;
148:
149: FORALL i IN 1..p_notification_id_tbl.COUNT
142: -- bug5471513 END
143:
144: d_position := 10;
145: IF (PO_LOG.d_stmt) THEN
146: PO_LOG.stmt(d_module, d_position, 'transfer records from txn to dft');
147: END IF;
148:
149: FORALL i IN 1..p_notification_id_tbl.COUNT
150: INSERT INTO po_notification_ctrl_draft
226: AND x_record_already_exist_tbl(i) = FND_API.G_FALSE
227: AND l_duplicate_flag_tbl(i) = FND_API.G_FALSE;
228:
229: d_position := 20;
230: IF (PO_LOG.d_stmt) THEN
231: PO_LOG.stmt(d_module, d_position, 'transfer count = ' || SQL%ROWCOUNT);
232: END IF;
233:
234: FORALL i IN 1..p_notification_id_tbl.COUNT
227: AND l_duplicate_flag_tbl(i) = FND_API.G_FALSE;
228:
229: d_position := 20;
230: IF (PO_LOG.d_stmt) THEN
231: PO_LOG.stmt(d_module, d_position, 'transfer count = ' || SQL%ROWCOUNT);
232: END IF;
233:
234: FORALL i IN 1..p_notification_id_tbl.COUNT
235: UPDATE po_notification_ctrl_draft
240: AND x_record_already_exist_tbl(i) = FND_API.G_TRUE;
241:
242: d_position := 30;
243:
244: IF (PO_LOG.d_stmt) THEN
245: PO_LOG.stmt(d_module, d_position, 'update draft records that are already' ||
246: ' in draft table. Count = ' || SQL%ROWCOUNT);
247: END IF;
248:
241:
242: d_position := 30;
243:
244: IF (PO_LOG.d_stmt) THEN
245: PO_LOG.stmt(d_module, d_position, 'update draft records that are already' ||
246: ' in draft table. Count = ' || SQL%ROWCOUNT);
247: END IF;
248:
249: d_position := 40;
247: END IF;
248:
249: d_position := 40;
250:
251: IF (PO_LOG.d_proc) THEN
252: PO_LOG.proc_end(d_module);
253: END IF;
254:
255: EXCEPTION
248:
249: d_position := 40;
250:
251: IF (PO_LOG.d_proc) THEN
252: PO_LOG.proc_end(d_module);
253: END IF;
254:
255: EXCEPTION
256: WHEN OTHERS THEN
302: l_record_already_exist_tbl PO_TBL_VARCHAR1;
303:
304: BEGIN
305: d_position := 0;
306: IF (PO_LOG.d_proc) THEN
307: PO_LOG.proc_begin(d_module);
308: PO_LOG.proc_begin(d_module, 'p_notification_id', p_notification_id);
309: END IF;
310:
303:
304: BEGIN
305: d_position := 0;
306: IF (PO_LOG.d_proc) THEN
307: PO_LOG.proc_begin(d_module);
308: PO_LOG.proc_begin(d_module, 'p_notification_id', p_notification_id);
309: END IF;
310:
311: sync_draft_from_txn
304: BEGIN
305: d_position := 0;
306: IF (PO_LOG.d_proc) THEN
307: PO_LOG.proc_begin(d_module);
308: PO_LOG.proc_begin(d_module, 'p_notification_id', p_notification_id);
309: END IF;
310:
311: sync_draft_from_txn
312: ( p_notification_id_tbl => PO_TBL_NUMBER(p_notification_id),
317:
318: x_record_already_exist := l_record_already_exist_tbl(1);
319:
320: d_position := 10;
321: IF (PO_LOG.d_proc) THEN
322: PO_LOG.proc_end(d_module);
323: PO_LOG.proc_end(d_module, 'x_record_already_exist', x_record_already_exist);
324: END IF;
325:
318: x_record_already_exist := l_record_already_exist_tbl(1);
319:
320: d_position := 10;
321: IF (PO_LOG.d_proc) THEN
322: PO_LOG.proc_end(d_module);
323: PO_LOG.proc_end(d_module, 'x_record_already_exist', x_record_already_exist);
324: END IF;
325:
326: EXCEPTION
319:
320: d_position := 10;
321: IF (PO_LOG.d_proc) THEN
322: PO_LOG.proc_end(d_module);
323: PO_LOG.proc_end(d_module, 'x_record_already_exist', x_record_already_exist);
324: END IF;
325:
326: EXCEPTION
327: WHEN OTHERS THEN
367:
368: BEGIN
369:
370: d_position := 0;
371: IF (PO_LOG.d_proc) THEN
372: PO_LOG.proc_begin(d_module);
373: END IF;
374:
375: -- Since putting DELETE within MERGE statement is causing database
368: BEGIN
369:
370: d_position := 0;
371: IF (PO_LOG.d_proc) THEN
372: PO_LOG.proc_begin(d_module);
373: END IF;
374:
375: -- Since putting DELETE within MERGE statement is causing database
376: -- to thrown internal error, for now we just separate the DELETE statement.
579: l_dummy NUMBER;
580:
581: BEGIN
582: d_position := 0;
583: IF (PO_LOG.d_proc) THEN
584: PO_LOG.proc_begin(d_module);
585: END IF;
586:
587: SELECT 1
580:
581: BEGIN
582: d_position := 0;
583: IF (PO_LOG.d_proc) THEN
584: PO_LOG.proc_begin(d_module);
585: END IF;
586:
587: SELECT 1
588: INTO l_dummy
590: WHERE notification_id = p_notification_id
591: AND draft_id = p_draft_id
592: FOR UPDATE NOWAIT;
593:
594: IF (PO_LOG.d_proc) THEN
595: PO_LOG.proc_end(d_module);
596: END IF;
597:
598: EXCEPTION
591: AND draft_id = p_draft_id
592: FOR UPDATE NOWAIT;
593:
594: IF (PO_LOG.d_proc) THEN
595: PO_LOG.proc_end(d_module);
596: END IF;
597:
598: EXCEPTION
599: WHEN NO_DATA_FOUND THEN
623: l_dummy NUMBER;
624:
625: BEGIN
626: d_position := 0;
627: IF (PO_LOG.d_proc) THEN
628: PO_LOG.proc_begin(d_module);
629: END IF;
630:
631: SELECT 1
624:
625: BEGIN
626: d_position := 0;
627: IF (PO_LOG.d_proc) THEN
628: PO_LOG.proc_begin(d_module);
629: END IF;
630:
631: SELECT 1
632: INTO l_dummy
633: FROM po_notification_controls
634: WHERE notification_id = p_notification_id
635: FOR UPDATE NOWAIT;
636:
637: IF (PO_LOG.d_proc) THEN
638: PO_LOG.proc_end(d_module);
639: END IF;
640:
641: EXCEPTION
634: WHERE notification_id = p_notification_id
635: FOR UPDATE NOWAIT;
636:
637: IF (PO_LOG.d_proc) THEN
638: PO_LOG.proc_end(d_module);
639: END IF;
640:
641: EXCEPTION
642: WHEN NO_DATA_FOUND THEN