1: PACKAGE BODY MSC_UNDO AS
2: /* $Header: MSCUNDOB.pls 120.1 2005/06/07 18:15:40 appldev $ */
3:
4: procedure UNDO (undoId undoIdTblType,
5: x_return_status OUT NOCOPY VARCHAR2,
30: sr_instance_id,
31: table_changed,
32: action,
33: last_update_date
34: from msc_undo_summary
35: where undo_id = v_undo_id;
36:
37: cursor c_dtl(v_plan_id number, v_undo_id number) is
38: select column_changed,
38: select column_changed,
39: old_value,
40: new_value,
41: column_type
42: from msc_undo_details
43: where plan_id = v_plan_id
44: and undo_id = v_undo_id;
45: cursor c_supp (v_plan_id number, v_undo_id number) is
46: select undo_id,transaction_id, sr_instance_id
43: where plan_id = v_plan_id
44: and undo_id = v_undo_id;
45: cursor c_supp (v_plan_id number, v_undo_id number) is
46: select undo_id,transaction_id, sr_instance_id
47: from msc_undo_summary
48: where plan_id = v_plan_id
49: and ( undo_id = v_undo_id
50: or parent_id = v_undo_id )
51: and table_changed = 3
86: Begin
87: -- if (l_table_changed in ( 3,4) ) then
88: -- cholpon
89: if (l_table_changed in ( 3,4, 8 ) ) then
90: Delete from msc_undo_details
91: where plan_id = l_plan_id
92: and (undo_id = l_undo_id
93: or undo_id in ( select undo_id
94: from msc_undo_summary
90: Delete from msc_undo_details
91: where plan_id = l_plan_id
92: and (undo_id = l_undo_id
93: or undo_id in ( select undo_id
94: from msc_undo_summary
95: where plan_id = l_plan_id
96: and parent_id = l_undo_id));
97:
98: Delete from msc_undo_summary
94: from msc_undo_summary
95: where plan_id = l_plan_id
96: and parent_id = l_undo_id));
97:
98: Delete from msc_undo_summary
99: where plan_id = l_plan_id
100: and (undo_id = l_undo_id
101: or parent_id = l_undo_id);
102: else
99: where plan_id = l_plan_id
100: and (undo_id = l_undo_id
101: or parent_id = l_undo_id);
102: else
103: Delete from msc_undo_summary
104: where plan_id = l_plan_id
105: and undo_id = l_undo_id;
106:
107: Delete from msc_undo_summary
103: Delete from msc_undo_summary
104: where plan_id = l_plan_id
105: and undo_id = l_undo_id;
106:
107: Delete from msc_undo_summary
108: where plan_id = l_plan_id
109: and undo_id = l_undo_id;
110: end if;
111: Exception
110: end if;
111: Exception
112: When others then
113: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
114: FND_MSG_PUB.add_exc_msg('MSC_UNDO', 'UNDO');
115: FND_MSG_PUB.count_and_get(p_count=>x_msg_count,
116: p_data=>x_msg_data);
117: End ;
118: elsif ( l_action = updated ) then
159: --end undo update table
160: Begin
161: if (l_table_changed in (3,4) ) then
162:
163: Delete from msc_undo_details
164: where plan_id = l_plan_id
165: and (undo_id = l_undo_id
166: or undo_id in ( select undo_id
167: from msc_undo_summary
163: Delete from msc_undo_details
164: where plan_id = l_plan_id
165: and (undo_id = l_undo_id
166: or undo_id in ( select undo_id
167: from msc_undo_summary
168: where plan_id = l_plan_id
169: and parent_id = l_undo_id));
170:
171: Delete from msc_undo_summary
167: from msc_undo_summary
168: where plan_id = l_plan_id
169: and parent_id = l_undo_id));
170:
171: Delete from msc_undo_summary
172: where plan_id = l_plan_id
173: and (undo_id = l_undo_id
174: or parent_id = l_undo_id);
175: else
172: where plan_id = l_plan_id
173: and (undo_id = l_undo_id
174: or parent_id = l_undo_id);
175: else
176: Delete from msc_undo_details
177: where plan_id = l_plan_id
178: and undo_id = l_undo_id;
179:
180: Delete from msc_undo_summary
176: Delete from msc_undo_details
177: where plan_id = l_plan_id
178: and undo_id = l_undo_id;
179:
180: Delete from msc_undo_summary
181: where plan_id = l_plan_id
182: and undo_id = l_undo_id;
183:
184: end if;
186:
187: Exception
188: When others then
189: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
190: FND_MSG_PUB.add_exc_msg('MSC_UNDO', 'UNDO');
191: FND_MSG_PUB.count_and_get(p_count=>x_msg_count,
192: p_data=>x_msg_data);
193: End ;
194:
193: End ;
194:
195: elsif (l_action in (3)) then
196: Begin
197: Delete from msc_undo_summary
198: where plan_id = l_plan_id
199: and undo_id = l_undo_id;
200: Exception
201: When others then
199: and undo_id = l_undo_id;
200: Exception
201: When others then
202: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
203: FND_MSG_PUB.add_exc_msg('MSC_UNDO', 'UNDO');
204: FND_MSG_PUB.count_and_get(p_count=>x_msg_count,
205: p_data=>x_msg_data);
206: End ;
207: end if;
216: p_data=>x_msg_data);
217: EXCEPTION
218: WHEN OTHERS THEN
219: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
220: FND_MSG_PUB.add_exc_msg('MSC_UNDO', 'UNDO');
221: FND_MSG_PUB.count_and_get(p_count=>x_msg_count,
222: p_data=>x_msg_data);
223: end UNDO;
224:
227: transaction_id NUMBER,
228: plan_id NUMBER,
229: sr_instance_id NUMBER,
230: parent_id NUMBER,
231: changed_values MSC_UNDO.ChangeRGType,
232: x_return_status OUT NOCOPY VARCHAR2,
233: x_msg_count OUT NOCOPY NUMBER,
234: x_msg_data OUT NOCOPY VARCHAR2,
235: undo_id NUMBER DEFAULT NULL) IS
256: end if;
257:
258: if ( action not in (inserted, updated) ) then
259: x_return_status := FND_API.G_RET_STS_ERROR;
260: FND_MSG_PUB.add_exc_msg('MSC_UNDO',
261: 'DEVELOPER ERROR : Invalid action passed to STORE_UNDO');
262: FND_MSG_PUB.count_and_get(p_count=>x_msg_count,
263: p_data=>x_msg_data);
264: Return ;
270: return;
271: end if;
272: BEGIN
273: if ( table_changed in (1,2,5,6,7) ) then
274: select MSC_UNDO_SUMMARY_S.nextval
275: into v_undo_id
276: from dual;
277: else
278: v_undo_id := undo_id;
276: from dual;
277: else
278: v_undo_id := undo_id;
279: end if;
280: --Insert a record into MSC_UNDO_SUMMARY
281: INSERT INTO MSC_UNDO_SUMMARY (
282: undo_id,
283: plan_id,
284: sr_instance_id,
277: else
278: v_undo_id := undo_id;
279: end if;
280: --Insert a record into MSC_UNDO_SUMMARY
281: INSERT INTO MSC_UNDO_SUMMARY (
282: undo_id,
283: plan_id,
284: sr_instance_id,
285: created_by,
308: parent_id);
309: EXCEPTION
310: WHEN OTHERS THEN
311: ROLLBACK;
312: fnd_msg_pub.add_Exc_msg('MSC_UNDO', 'STORE_UNDO');
313: fnd_msg_pub.count_and_get(p_count=>x_msg_Count, p_data=>x_msg_data);
314: END ;
315: end if;
316: if ( action = updated ) then
323: l_old_value := changed_values(i).Old_Value ;
324: l_new_value := changed_values(i).New_Value ;
325:
326: BEGIN
327: INSERT INTO MSC_UNDO_DETAILS (
328: UNDO_ID,
329: PLAN_ID,
330: COLUMN_CHANGED,
331: COLUMN_CHANGED_TEXT,
356:
357: EXCEPTION
358: WHEN OTHERS THEN
359: --ROLLBACK;
360: fnd_msg_pub.add_Exc_msg('MSC_UNDO', 'STORE_UNDO');
361: fnd_msg_pub.count_and_get(p_count=>x_msg_Count, p_data=>x_msg_data);
362: END ;
363: END LOOP;
364: end if;
388: (bookmark, start_online, replan_start, replan_stop, stop_online) ) THEN
389: x_return_status := FND_API.G_RET_STS_ERROR;
390: x_msg_count := 1;
391: x_msg_data := 'DEVELOPER ERROR : '
392: ||' Invalid Action passed to MSC_UNDO.add_bookmark';
393: FND_MSG_PUB.count_and_get(p_count =>x_msg_count,
394: p_data=>x_msg_data );
395: ELSE
396: SELECT MSC_UNDO_SUMMARY_S.nextval
392: ||' Invalid Action passed to MSC_UNDO.add_bookmark';
393: FND_MSG_PUB.count_and_get(p_count =>x_msg_count,
394: p_data=>x_msg_data );
395: ELSE
396: SELECT MSC_UNDO_SUMMARY_S.nextval
397: INTO v_undo_id
398: from dual;
399:
400: x_return_status := FND_API.G_RET_STS_SUCCESS;
398: from dual;
399:
400: x_return_status := FND_API.G_RET_STS_SUCCESS;
401:
402: --Insert a record into MSC_UNDO_SUMMARY
403: INSERT INTO MSC_UNDO_SUMMARY (
404: undo_id,
405: plan_id,
406: sr_instance_id,
399:
400: x_return_status := FND_API.G_RET_STS_SUCCESS;
401:
402: --Insert a record into MSC_UNDO_SUMMARY
403: INSERT INTO MSC_UNDO_SUMMARY (
404: undo_id,
405: plan_id,
406: sr_instance_id,
407: created_by,
433: EXCEPTION
434: WHEN OTHERS THEN
435: ROLLBACK;
436: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
437: FND_MSG_PUB.add_exc_msg('MSC_UNDO', 'Add_Bookmark');
438: FND_MSG_PUB.count_and_get(p_count=>x_msg_count,
439: p_data => x_msg_data);
440:
441: end ADD_BOOKMARK;
457: a.transaction_id,
458: b.old_value,
459: a.action,
460: b.column_changed
461: from msc_undo_summary a,
462: msc_undo_details b
463: where a.undo_id = b.undo_id (+)
464: and (a.undo_id = l_undo_id
465: or a.parent_id = l_undo_id);
458: b.old_value,
459: a.action,
460: b.column_changed
461: from msc_undo_summary a,
462: msc_undo_details b
463: where a.undo_id = b.undo_id (+)
464: and (a.undo_id = l_undo_id
465: or a.parent_id = l_undo_id);
466:
532: --Msc_supplier_capacities
533: /*
534: Delete from msc_supplier_capacities
535: where transaction_id in (select transaction_id
536: from msc_undo_summary
537: where plan_id = p_plan_id
538: and (undo_id = p_undo_id or parent_id = p_undo_id))
539: and plan_id = p_plan_id ;
540: */
543: status = 0,
544: applied = 2
545: where plan_id = p_plan_id
546: and transaction_id in (select transaction_id
547: from msc_undo_summary
548: where plan_id = p_plan_id
549: and (undo_id = p_undo_id or parent_id = p_undo_id));
550: elsif ( p_table_changed in ( 4, 8) ) then
551: --Msc_net_resource_Avail
635: EXCEPTION
636: WHEN OTHERS THEN
637: ROLLBACK;
638: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
639: FND_MSG_PUB.add_exc_msg('MSC_UNDO', 'INSERT_TABLE');
640: FND_MSG_PUB.count_and_get(p_count=>x_msg_count,
641: p_data => x_msg_data);
642: END insert_table ;
643:
680: a.transaction_id,
681: b.old_value,
682: a.action,
683: b.column_changed
684: from msc_undo_summary a,
685: msc_undo_details b
686: where a.undo_id = b.undo_id (+)
687: and (a.undo_id = l_undo_id
688: or a.parent_id = l_undo_id);
681: b.old_value,
682: a.action,
683: b.column_changed
684: from msc_undo_summary a,
685: msc_undo_details b
686: where a.undo_id = b.undo_id (+)
687: and (a.undo_id = l_undo_id
688: or a.parent_id = l_undo_id);
689: l_column_name varchar2(30);
851: EXCEPTION
852: WHEN OTHERS THEN
853: --ROLLBACK;
854: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
855: FND_MSG_PUB.add_exc_msg('MSC_UNDO', 'UPDATE_TABLE'
856: ||' '||sql_string);
857: FND_MSG_PUB.count_and_get(p_count=>x_msg_count,
858: p_data => x_msg_data);
859: END update_table;
866: cursor c_mst (l_undo_id NUMBER) is
867: select plan_id, sr_instance_id, transaction_id, table_changed, action,
868: last_updated_by, last_update_date, identifier1_name, identifier2_name,
869: identifier3_name
870: from msc_undo_summary_v
871: where undo_id = l_undo_id;
872:
873: cursor c_noundo_same1 (v_plan_id number,
874: v_sr_instance_id number,
875: v_table_changed number,
876: v_user number,
877: v_date date) is
878: select count(undo_id)
879: from msc_undo_summary
880: where plan_id = v_plan_id
881: and sr_instance_id = v_sr_instance_id
882: and table_changed = v_table_changed
883: and last_updated_by = v_user
891: v_table_changed number,
892: v_user number,
893: v_date date) is
894: select count(undo_id)
895: from msc_undo_summary
896: where plan_id = v_plan_id
897: and sr_instance_id = v_sr_instance_id
898: and transaction_id = v_transaction_id
899: and table_changed = v_table_changed
905: cursor c_noundo_diff1 (v_plan_id number, v_sr_instance_id number,
906: v_table_changed number, v_user number,
907: v_date date) is
908: select count(undo_id)
909: from msc_undo_summary
910: where plan_id = v_plan_id
911: and sr_instance_id = v_sr_instance_id
912: and table_changed = v_table_changed
913: and last_updated_by <> v_user
918: cursor c_noundo_diff2 (v_plan_id number, v_sr_instance_id number,
919: v_transaction_id number, v_table_changed number,
920: v_user number, v_date date) is
921: select count(undo_id)
922: from msc_undo_summary
923: where plan_id = v_plan_id
924: and sr_instance_id = v_sr_instance_id
925: and transaction_id = v_transaction_id
926: and table_changed = v_table_changed
938: and plan_id = v_plan_id ;
939:
940: cursor c_olprun (v_plan_id number) is
941: select undo_id
942: from msc_undo_summary
943: where plan_id = v_plan_id
944: and action = 4;
945:
946: v_temp number;
980: l_token := l_identifier1_name||' '||l_identifier2_name||' '||
981: l_identifier3_name;
982: if (fnd_global.user_id <> l_last_updated_by ) then
983: x_return_status := FND_API.G_RET_STS_ERROR;
984: FND_MESSAGE.SET_NAME('MSC', 'MSC_UNDO_OTHER_USERS');
985: FND_MESSAGE.SET_TOKEN('RECORD',l_token);
986: FND_MSG_PUB.ADD;
987: FND_MSG_PUB.count_and_get(p_count=>x_msg_count,
988: p_data => x_msg_data);
997: close c_noundo_diff1 ;
998:
999: if (l_count <> 0 ) then
1000: x_return_status := FND_API.G_RET_STS_ERROR;
1001: FND_MESSAGE.set_name('MSC', 'MSC_UNDO_REC_CHG_DIFF_USER');
1002: FND_MESSAGE.SET_TOKEN('RECORD',l_token);
1003: FND_MSG_PUB.ADD;
1004: FND_MSG_PUB.count_and_get(p_count=>x_msg_count,
1005: p_data => x_msg_data);
1013: close c_noundo_diff2 ;
1014:
1015: if (l_count <> 0 ) then
1016: x_return_status := FND_API.G_RET_STS_ERROR;
1017: FND_MESSAGE.set_name('MSC', 'MSC_UNDO_REC_CHG_DIFF_USER');
1018: FND_MESSAGE.SET_TOKEN('RECORD',l_token);
1019: FND_MSG_PUB.ADD;
1020: FND_MSG_PUB.count_and_get(p_count=>x_msg_count,
1021: p_data => x_msg_data);
1031: close c_noundo_same1 ;
1032:
1033: if (l_count <> 0 ) then
1034: x_return_status := FND_API.G_RET_STS_ERROR;
1035: FND_MESSAGE.set_name('MSC', 'MSC_UNDO_REC_CHG_SAME_USER');
1036: FND_MESSAGE.SET_TOKEN('RECORD',l_token);
1037: FND_MSG_PUB.ADD;
1038: FND_MSG_PUB.count_and_get(p_count=>x_msg_count,
1039: p_data => x_msg_data);
1047: close c_noundo_same2 ;
1048:
1049: if (l_count <> 0 ) then
1050: x_return_status := FND_API.G_RET_STS_ERROR;
1051: FND_MESSAGE.set_name('MSC', 'MSC_UNDO_REC_CHG_SAME_USER');
1052: FND_MESSAGE.SET_TOKEN('RECORD',l_token);
1053: FND_MSG_PUB.ADD;
1054: FND_MSG_PUB.count_and_get(p_count=>x_msg_count,
1055: p_data => x_msg_data);
1065: fetch c_nofirm into l_count;
1066: if (l_olprun_undo_id > v_undo_id ) then
1067: if (l_count <> 1) then
1068: x_return_status := FND_API.G_RET_STS_ERROR;
1069: FND_MESSAGE.set_name('MSC', 'MSC_UNDO_UNFIRM');
1070: FND_MESSAGE.SET_TOKEN('RECORD',l_token);
1071: FND_MSG_PUB.ADD;
1072: FND_MSG_PUB.count_and_get(p_count=>x_msg_count,
1073: p_data => x_msg_data);
1076: end if;
1077: end if;
1078: return v_undo_id;
1079: end undo_validate ;
1080: END MSC_UNDO;