DBA Data[Home] [Help]

PACKAGE BODY: APPS.CSI_TXN_HISTORY_PURGE_PVT

Source


1 PACKAGE BODY CSI_TXN_HISTORY_PURGE_PVT AS
2 /* $Header: csivthpb.pls 120.2 2005/06/17 17:38:20 appldev  $ */
3 
4 -- --------------------------------------------------------
5 -- Define global variables
6 -- --------------------------------------------------------
7 
8 G_PKG_NAME CONSTANT VARCHAR2(30)  := 'CSI_TXN_HISTORY_PURGE_PVT';
9 G_FILE_NAME CONSTANT VARCHAR2(12) := 'csivthpb.pls';
10 --
11 --
12 -- Procedure to debug the discrepancies
13 --
14 Procedure Debug(
15   p_message       IN VARCHAR2)
16 IS
17 Begin
18    fnd_file.put_line(fnd_file.log, p_message);
19 End Debug;
20 --
21 --
22 -- Truncate the discrepancy table before each run
23 --
24 Procedure truncate_table(
25   p_table_name    IN VARCHAR2)
26 IS
27   l_num_of_rows      NUMBER;
28   l_truncate_handle  PLS_INTEGER := dbms_sql.open_cursor;
29   l_statement        VARCHAR2(200);
30 Begin
31   l_statement := 'truncate table '||p_table_name;
32   dbms_sql.parse(l_truncate_handle, l_statement, dbms_sql.native);
33   l_num_of_rows := dbms_sql.execute(l_truncate_handle);
34   dbms_sql.close_cursor(l_truncate_handle);
35 Exception
36   When Others Then
37     Null;
38 End truncate_table;
39 --
40 --
41 -- This is the main archive program which internally calls each of the entity
42 -- archive programs concurrently. It accepts a date timestamp as an parameter.
43 --
44 Procedure Archive ( errbuf           OUT NOCOPY  VARCHAR2,
45                     retcode          OUT NOCOPY  NUMBER,
46                     purge_to_date    IN          VARCHAR2)
47 
48   IS
49 
50     l_message         VARCHAR2(2000);
51     from_trans        NUMBER;
52     to_trans          NUMBER;
53     l_request_id      NUMBER;
54     l_errbuf          VARCHAR2(2000);
55     l_recs_archived   NUMBER;
56     l_date            DATE;
57     t_date            DATE;
58     l_exists          VARCHAR2(1);
59 
60 Begin
61 
62   Debug('Start of the Install Base History Archive Process... ');
63 
64   -- Get the min and max transactions_ids for the date timestamp passed
65      Begin
66        Select Min(transaction_id),
67               Max(transaction_id)
68        Into   from_trans,
69               to_trans
70        From   CSI_TRANSACTIONS
71        Where  creation_date < to_date(purge_to_date, 'YYYY/MM/DD HH24:MI:SS');
72      Exception
73        When Others Then
74           Null;
75      End;
76             Debug('');
77             Debug('Concurrent program parameters...');
78             Debug('');
79             Debug('+-----------------------------------------------------------------------------------------------+');
80             Debug(substr('Transaction History Purge date in the format YYYY/MM/DD HH24:MI:SS ='||purge_to_date,1,255));
81             Debug('+-----------------------------------------------------------------------------------------------+');
82             Debug('');
83             Debug('');
84             Debug('Value of from_trans='||TO_CHAR(from_trans));
85             Debug('Value of to_trans='||TO_CHAR(to_trans));
86 
87      --
88      -- srramakr Fix for Bug # 3435413. No need to call Child processes if there are no
89      -- Transactions to be Purged.
90      IF from_trans IS NULL OR
91         to_trans IS NULL THEN
92         Debug('No History Transaction available for Purge for the Given Date...');
93         Return;
94      END IF;
95      --
96      -- Check if there are any instances residing in CSI_II_FORWARD_SYNC_TEMP table with a lesser time stamp.
97      Begin
98         select 'x'
99         into l_exists
100         from CSI_II_FORWARD_SYNC_TEMP
101         where date_time_stamp <= to_date(purge_to_date, 'YYYY/MM/DD HH24:MI:SS')
102         and   process_flag <> 'P'
103         and   rownum < 2;
104         Debug('One or more instances reside in CSI_II_FORWARD_SYNC_TEMP table with a date_time_stamp lesser than the given Pruge Date. Cannot continue with the purge.');
105         Return;
106      Exception
107         when no_data_found then
108            null;
109      End;
110      --
111    -- srramakr Bug 4366231. The following routine joins each entity history table with CSI_TRANSACTIONS
112    -- to get the count of records purged and archieved. This causes lot of performance issue. Giving such
113    -- count is unnecessary. The user can always check against the archive table. Hence commenting it.
114   /*   csi_txn_history_purge_pvt.Record_count(From_trans   =>  From_trans,
115                                             To_trans     =>  To_trans,
116                                             Purge_to_date => purge_to_date,
117                                             Recs_count   =>  l_recs_archived ); */
118      --
119      -- This following program is used to archive the Instance history. It accepts from  transactions
120      -- as the input parameters.
121      --
122       l_request_id := fnd_request.submit_request (
123                                            application    => 'CSI',
124                                            program        => 'CSIINSARCH',
125                                            start_time     =>  Null,
126                                            sub_request    =>  False,
127                                            argument1      =>  From_Trans,
128                                            argument2      =>  To_Trans,
129                                            argument3      =>  Purge_to_Date );
130             Debug('');
131             Debug('Calling Install Base Instance History Archive and Purge Process...');
132             Debug('Request ID: '||l_request_id||' has been submitted');
133 
134               If l_request_id = 0
135               Then
136                  fnd_message.retrieve(l_errbuf);
137                  Debug('Call to Installed Base Instance History Archive and Purge process has errored');
138                  Debug('Error message   :'||substr(l_errbuf,1,75));
139                  Debug(' :'||substr(l_errbuf,76,150));
140                  Debug(' :'||substr(l_errbuf,151,225));
141                  Debug(' :'||substr(l_errbuf,226,300));
142               Else
143                  Debug('Installed Base Instance History Archive and Purge process has completed successfully');
144                  Debug('');
145                  Commit;
146               End If;
147       --
148       -- This following program is used to archive the Instance history. It accepts from  transactions
149       -- as the input parameters.
150       --
151       l_request_id := fnd_request.submit_request (
152                                            application    => 'CSI',
153                                            program        => 'CSIPTYARCH',
154                                            start_time     =>  Null,
155                                            sub_request    =>  False,
156                                            argument1      =>  From_Trans,
157                                            argument2      =>  To_Trans,
158                                            argument3      =>  Purge_to_Date );
159 
160             Debug('');
161             Debug('Calling Installed Base Party History Archive and Purge process...');
162             Debug('Request ID: '||l_request_id||' has been submitted');
163 
164               If l_request_id = 0
165               Then
166                  fnd_message.retrieve(l_errbuf);
167                  Debug('Call to Installed Base Party History Archive and Purge process has errored');
168                  Debug('Error message   :'||substr(l_errbuf,1,75));
169                  Debug(' :'||substr(l_errbuf,76,150));
170                  Debug(' :'||substr(l_errbuf,151,225));
171                  Debug(' :'||substr(l_errbuf,226,300));
172               Else
173                  Debug('Installed Base Instance Party History Archive and Purge process has completed successfully');
174                  Debug('');
175                  Commit;
176               End If;
177       --
178       -- This following program is used to archive the Instance history. It accepts from  transactions
179       -- as the input parameters.
180       --
181       l_request_id := fnd_request.submit_request (
182                                            application    => 'CSI',
183                                            program        => 'CSIACTARCH',
184                                            start_time     =>  Null,
185                                            sub_request    =>  False,
186                                            argument1      =>  From_Trans,
187                                            argument2      =>  To_Trans,
188                                            argument3      =>  Purge_to_Date );
189 
190             Debug('');
191             Debug('Calling Installed Base Account History Archive and Purge process...');
192             Debug('Request ID: '||l_request_id||' has been submitted');
193 
194               If l_request_id = 0
195               Then
196                  fnd_message.retrieve(l_errbuf);
197                  Debug('Call to Installed Base Account History Archive and Purge process has errored');
198                  Debug('Error message   :'||substr(l_errbuf,1,75));
199                  Debug(' :'||substr(l_errbuf,76,150));
200                  Debug(' :'||substr(l_errbuf,151,225));
201                  Debug(' :'||substr(l_errbuf,226,300));
202               Else
203                  Debug('Installed Base Account History Archive and Purge process has completed successfully');
204                  Debug('');
205                  Commit;
206               End If;
207       --
208       -- This following program is used to archive the Instance history. It accepts from  transactions
209       -- as the input parameters.
210       --
211       l_request_id := fnd_request.submit_request (
212                                            application    => 'CSI',
213                                            program        => 'CSIOUARCH',
214                                            start_time     =>  Null,
215                                            sub_request    =>  False,
216                                            argument1      =>  From_Trans,
217                                            argument2      =>  To_Trans,
218                                            argument3      =>  Purge_to_Date );
219 
220             Debug('');
221             Debug('Calling Installed Base Operating Units History Archive and Purge process...');
222             Debug('Request ID: '||l_request_id||' has been submitted');
223 
224               If l_request_id = 0
225               Then
226                  fnd_message.retrieve(l_errbuf);
227                  Debug('Call to Installed Base Operating Units History Archive and Purge process has errored');
228                  Debug('Error message   :'||substr(l_errbuf,1,75));
229                  Debug(' :'||substr(l_errbuf,76,150));
230                  Debug(' :'||substr(l_errbuf,151,225));
231                  Debug(' :'||substr(l_errbuf,226,300));
232               Else
233                  Debug('Installed Base Operating Units History Archive and Purge process has completed successfully');
234                  Debug('');
235                  Commit;
236               End If;
237       --
238       -- This following program is used to archive the Instance history. It accepts from  transactions
239       -- as the input parameters.
240       --
241       l_request_id := fnd_request.submit_request (
242                                            application    => 'CSI',
243                                            program        => 'CSIPRIARCH',
244                                            start_time     =>  Null,
245                                            sub_request    =>  False,
246                                            argument1      =>  From_Trans,
247                                            argument2      =>  To_Trans,
248                                            argument3      =>  Purge_to_Date );
249 
250             Debug('');
251             Debug('Calling Installed Base Pricing History Archive and Purge process...');
252             Debug('Request ID: '||l_request_id||' has been submitted');
253 
254               If l_request_id = 0
255               Then
256                  fnd_message.retrieve(l_errbuf);
257                  Debug('Call to Installed Base Pricing History Archive and Purge process has errored');
258                  Debug('Error message   :'||substr(l_errbuf,1,75));
259                  Debug(' :'||substr(l_errbuf,76,150));
260                  Debug(' :'||substr(l_errbuf,151,225));
261                  Debug(' :'||substr(l_errbuf,226,300));
262               Else
263                  Debug('Installed Base Pricing History Archive and Purge process has completed successfully');
264                  Debug('');
265                  Commit;
266               End If;
267       --
268       -- This following program is used to archive the Instance history. It accepts from  transactions
269       -- as the input parameters.
270       --
271       l_request_id := fnd_request.submit_request (
272                                            application    => 'CSI',
273                                            program        => 'CSIEXTARCH',
274                                            start_time     =>  Null,
275                                            sub_request    =>  False,
276                                            argument1      =>  From_Trans,
277                                            argument2      =>  To_Trans,
278                                            argument3      =>  Purge_to_Date );
279 
280             Debug('');
281             Debug('Calling Installed Base Extended Attribs History Archive and Purge process...');
282             Debug('Request ID: '||l_request_id||' has been submitted');
283 
284               If l_request_id = 0
285               Then
286                  fnd_message.retrieve(l_errbuf);
287                  Debug('Call to Installed Base Extended Attribs History Archive and Purge process has errored');
288                  Debug('Error message   :'||substr(l_errbuf,1,75));
289                  Debug(' :'||substr(l_errbuf,76,150));
290                  Debug(' :'||substr(l_errbuf,151,225));
291                  Debug(' :'||substr(l_errbuf,226,300));
292               Else
293                  Debug('Installed Base Extended Attribs History Archive and Purge process has completed successfully');
294                  Debug('');
295                  Commit;
296               End If;
297       --
298       -- This following program is used to archive the Instance history. It accepts from  transactions
299       -- as the input parameters.
300       --
301       l_request_id := fnd_request.submit_request (
302                                            application    => 'CSI',
303                                            program        => 'CSIASTARCH',
307                                            argument2      =>  To_Trans,
304                                            start_time     =>  Null,
305                                            sub_request    =>  False,
306                                            argument1      =>  From_Trans,
308                                            argument3      =>  Purge_to_Date );
309 
310             Debug('');
311             Debug('Calling Installed Base Assets History Archive and Purge process...');
312             Debug('Request ID: '||l_request_id||' has been submitted');
313 
314               If l_request_id = 0
315               Then
316                  fnd_message.retrieve(l_errbuf);
317                  Debug('Call to Installed Base Assets History Archive and Purge process has errored');
318                  Debug('Error message   :'||substr(l_errbuf,1,75));
319                  Debug(' :'||substr(l_errbuf,76,150));
320                  Debug(' :'||substr(l_errbuf,151,225));
321                  Debug(' :'||substr(l_errbuf,226,300));
322               Else
323                  Debug('Installed Base Assets History Archive and Purge process has completed successfully');
324                  Debug('');
325                  Commit;
326               End If;
327       --
328       -- This following program is used to archive the Instance history. It accepts from  transactions
329       -- as the input parameters.
330       --
331       l_request_id := fnd_request.submit_request (
332                                            application    => 'CSI',
333                                            program        => 'CSIVERARCH',
334                                            start_time     =>  Null,
335                                            sub_request    =>  False,
336                                            argument1      =>  From_Trans,
337                                            argument2      =>  To_Trans,
338                                            argument3      =>  Purge_to_Date );
339 
340             Debug('');
341             Debug('Calling Installed Base Version Label History Archive and Purge process...');
342             Debug('Request ID: '||l_request_id||' has been submitted');
343 
344               If l_request_id = 0
345               Then
346                  fnd_message.retrieve(l_errbuf);
347                  Debug('Call to Installed Base Version Label History Archive and Purge process has errored');
348                  Debug('Error message   :'||substr(l_errbuf,1,75));
349                  Debug(' :'||substr(l_errbuf,76,150));
350                  Debug(' :'||substr(l_errbuf,151,225));
351                  Debug(' :'||substr(l_errbuf,226,300));
352               Else
353                  Debug('Installed Base Version Label History Archive and Purge process has completed successfully');
354                  Debug('');
355                  Commit;
356               End If;
357       --
358       -- This following program is used to archive the Instance history. It accepts from  transactions
359       -- as the input parameters.
360       --
361       l_request_id := fnd_request.submit_request (
362                                            application    => 'CSI',
363                                            program        => 'CSIRELARCH',
364                                            start_time     =>  Null,
365                                            sub_request    =>  False,
366                                            argument1      =>  From_Trans,
367                                            argument2      =>  To_Trans,
368                                            argument3      =>  Purge_to_Date );
369 
370             Debug('');
371             Debug('Calling Installed Base Instance Relationships History Archive and Purge process...');
372             Debug('Request ID: '||l_request_id||' has been submitted');
373 
374               If l_request_id = 0
375               Then
376                  fnd_message.retrieve(l_errbuf);
377                  Debug('Call to Installed Base Instance Relationships History Archive and Purge process has errored');
378                  Debug('Error message   :'||substr(l_errbuf,1,75));
379                  Debug(' :'||substr(l_errbuf,76,150));
380                  Debug(' :'||substr(l_errbuf,151,225));
381                  Debug(' :'||substr(l_errbuf,226,300));
382               Else
383                  Debug('Installed Base Instance Relationships History Archive and Purge process has completed successfully');
384                  Debug('');
385                  Commit;
386               End If;
387       --
388       -- This following program is used to archive the Instance history. It accepts from  transactions
389       -- as the input parameters.
390       --
391       l_request_id := fnd_request.submit_request (
392                                            application    => 'CSI',
393                                            program        => 'CSISYSARCH',
394                                            start_time     =>  Null,
395                                            sub_request    =>  False,
396                                            argument1      =>  From_Trans,
397                                            argument2      =>  To_Trans,
398                                            argument3      =>  Purge_to_Date );
399 
400             Debug('');
401             Debug('Calling Installed Base Systems History Archive and Purge process...');
402             Debug('Request ID: '||l_request_id||' has been submitted');
403 
404               If l_request_id = 0
405               Then
406                  fnd_message.retrieve(l_errbuf);
407                  Debug('Call to Installed Base Systems History Archive and Purge process has errored');
411                  Debug(' :'||substr(l_errbuf,226,300));
408                  Debug('Error message   :'||substr(l_errbuf,1,75));
409                  Debug(' :'||substr(l_errbuf,76,150));
410                  Debug(' :'||substr(l_errbuf,151,225));
412               Else
413                  Debug('Installed Base Systems History Archive and Purge process has completed successfully');
414                  Debug('');
415                  Commit;
416               End If;
417               -- convert the incoming date format.
418               t_date := to_date(purge_to_date, 'YYYY/MM/DD HH24:MI:SS');
419 
420               -- Update the csi object_dictionary table with the archived and purged date
421               Begin
422                  Update CSI_OBJECT_DICTIONARY
423                  Set    last_archive_date = t_date;
424               End;
425               Commit;
426               --
427               Debug('');
428            --   Debug('Total Number of Records Archived = '||l_recs_archived);
429            --   Debug('');
430            --   Debug('Total Number of Records Purged from history tables = '||l_recs_archived);
431            --   Debug('');
432               Debug('');
433 
434     Debug('End of Installed Base History Archive and purge process...');
435 
436 Exception
437   When Others Then
438     Debug('Failed in the Installed Base History Archive Process');
439 End;
440 --
441 -- This program is used to archive the Instance history. It accepts from  transactions
442 -- as the input parameters.
443 --
444 Procedure Instance_Archive( errbuf       OUT NOCOPY VARCHAR2,
445                             retcode      OUT NOCOPY NUMBER,
446                             from_trans   IN  NUMBER,
447                             to_trans     IN  NUMBER,
448                             purge_to_date IN VARCHAR2 )
449 Is
450 
451     l_archive_id      NUMBER;
452     l_ctr             NUMBER := 0;
453     l_cnt             NUMBER;
454     l_table_id        NUMBER;
455     l_user_id         NUMBER := FND_GLOBAL.USER_ID;
456     l_login_id        NUMBER := FND_GLOBAL.CONC_LOGIN_ID;
457     v_batch           NUMBER := 15000;
458     v_start           NUMBER;
459     v_end             NUMBER;
460 
461     Type NumList IS Table Of Number Index By Binary_Integer;
462     l_archive_id_tbl   NumList;
463 
464     Cursor inst_hist_csr (p_from_trans IN NUMBER,
465                           p_to_trans   IN NUMBER) IS
466     Select csh.*
467     From   CSI_ITEM_INSTANCES_H csh,
468            CSI_TRANSACTIONS csit
469     Where  csit.transaction_id between From_trans and To_trans
470     And    csit.creation_date < to_date(purge_to_date, 'YYYY/MM/DD HH24:MI:SS')
471     And    csh.transaction_id = csit.transaction_id;
472 
473     l_inst_hist_csr          inst_hist_csr%RowType;
474     l_inst_hist_rec_tab      csi_txn_history_purge_pvt.instance_history_rec_tab;
475 
476 
477  Begin
478     --
479     Begin
480       Select object_id
481       Into   l_table_id
482       From   csi_object_dictionary
483       Where  object_name = 'CSI_ITEM_INSTANCES_H';
484     Exception
485       When no_data_found Then
486         l_table_id := 1;
487       When others Then
488         l_table_id := 1;
489     End;
490     --
491     Begin
492       Select fnd_profile.value('CSI_TXN_HISTORY_PURGE_BATCH_SIZE')
493       Into   v_batch
494       From   dual;
495     Exception
496       When no_data_found Then
497         v_batch := 15000;
498     End;
499     --
500     v_start := from_trans;
501     v_end   := from_trans + v_batch;
502     --
503     If v_end > to_trans Then
504        v_end := to_trans;
505     End If;
506     --
507  Loop
508     Begin
509       SAVEPOINT Instance_Archive;
510       l_ctr := 0;
511       --
512       l_inst_hist_rec_tab.instance_id.DELETE;
513       l_inst_hist_rec_tab.old_instance_number.DELETE;
514       l_inst_hist_rec_tab.new_instance_number.DELETE;
515       l_inst_hist_rec_tab.old_external_reference.DELETE;
516       l_inst_hist_rec_tab.new_external_reference.DELETE;
517       l_inst_hist_rec_tab.old_inventory_item_id.DELETE;
518       l_inst_hist_rec_tab.new_inventory_item_id.DELETE;
519       l_inst_hist_rec_tab.old_inventory_revision.DELETE;
520       l_inst_hist_rec_tab.new_inventory_revision.DELETE;
521       l_inst_hist_rec_tab.old_inv_master_org_id.DELETE;
522       l_inst_hist_rec_tab.new_inv_master_org_id.DELETE;
523       l_inst_hist_rec_tab.old_serial_number.DELETE;
524       l_inst_hist_rec_tab.new_serial_number.DELETE;
525       l_inst_hist_rec_tab.old_mfg_serial_number_flag.DELETE;
526       l_inst_hist_rec_tab.new_mfg_serial_number_flag.DELETE;
527       l_inst_hist_rec_tab.old_lot_number.DELETE;
528       l_inst_hist_rec_tab.new_lot_number.DELETE;
529       l_inst_hist_rec_tab.old_quantity.DELETE;
530       l_inst_hist_rec_tab.new_quantity.DELETE;
531       l_inst_hist_rec_tab.old_unit_of_measure.DELETE;
532       l_inst_hist_rec_tab.new_unit_of_measure.DELETE;
533       l_inst_hist_rec_tab.old_accounting_class_code.DELETE;
534       l_inst_hist_rec_tab.new_accounting_class_code.DELETE;
535       l_inst_hist_rec_tab.old_instance_condition_id.DELETE;
536       l_inst_hist_rec_tab.new_instance_condition_id.DELETE;
537       l_inst_hist_rec_tab.old_instance_status_id.DELETE;
538       l_inst_hist_rec_tab.new_instance_status_id.DELETE;
542       l_inst_hist_rec_tab.new_merchant_view_flag.DELETE;
539       l_inst_hist_rec_tab.old_customer_view_flag.DELETE;
540       l_inst_hist_rec_tab.new_customer_view_flag.DELETE;
541       l_inst_hist_rec_tab.old_merchant_view_flag.DELETE;
543       l_inst_hist_rec_tab.old_sellable_flag.DELETE;
544       l_inst_hist_rec_tab.new_sellable_flag.DELETE;
545       l_inst_hist_rec_tab.old_system_id.DELETE;
546       l_inst_hist_rec_tab.new_system_id.DELETE;
547       l_inst_hist_rec_tab.old_instance_type_code.DELETE;
548       l_inst_hist_rec_tab.new_instance_type_code.DELETE;
549       l_inst_hist_rec_tab.old_active_start_date.DELETE;
550       l_inst_hist_rec_tab.new_active_start_date.DELETE;
551       l_inst_hist_rec_tab.old_active_end_date.DELETE;
552       l_inst_hist_rec_tab.new_active_end_date.DELETE;
553       l_inst_hist_rec_tab.old_location_type_code.DELETE;
554       l_inst_hist_rec_tab.new_location_type_code.DELETE;
555       l_inst_hist_rec_tab.old_location_id.DELETE;
556       l_inst_hist_rec_tab.new_location_id.DELETE;
557       l_inst_hist_rec_tab.old_inv_organization_id.DELETE;
558       l_inst_hist_rec_tab.new_inv_organization_id.DELETE;
559       l_inst_hist_rec_tab.old_inv_subinventory_name.DELETE;
560       l_inst_hist_rec_tab.new_inv_subinventory_name.DELETE;
561       l_inst_hist_rec_tab.old_inv_locator_id.DELETE;
562       l_inst_hist_rec_tab.new_inv_locator_id.DELETE;
563       l_inst_hist_rec_tab.old_pa_project_id.DELETE;
564       l_inst_hist_rec_tab.new_pa_project_id.DELETE;
565       l_inst_hist_rec_tab.old_pa_project_task_id.DELETE;
566       l_inst_hist_rec_tab.new_pa_project_task_id.DELETE;
567       l_inst_hist_rec_tab.old_in_transit_order_line_id.DELETE;
568       l_inst_hist_rec_tab.new_in_transit_order_line_id.DELETE;
569       l_inst_hist_rec_tab.old_wip_job_id.DELETE;
570       l_inst_hist_rec_tab.new_wip_job_id.DELETE;
571       l_inst_hist_rec_tab.old_po_order_line_id.DELETE;
572       l_inst_hist_rec_tab.new_po_order_line_id.DELETE;
573       l_inst_hist_rec_tab.old_install_date.DELETE;
574       l_inst_hist_rec_tab.new_install_date.DELETE;
575       l_inst_hist_rec_tab.old_return_by_date.DELETE;
576       l_inst_hist_rec_tab.new_return_by_date.DELETE;
577       l_inst_hist_rec_tab.old_actual_return_date.DELETE;
578       l_inst_hist_rec_tab.new_actual_return_date.DELETE;
579       l_inst_hist_rec_tab.old_completeness_flag.DELETE;
580       l_inst_hist_rec_tab.new_completeness_flag.DELETE;
581       l_inst_hist_rec_tab.old_inst_context.DELETE;
582       l_inst_hist_rec_tab.new_inst_context.DELETE;
583       l_inst_hist_rec_tab.old_inst_attribute1.DELETE;
584       l_inst_hist_rec_tab.new_inst_attribute1.DELETE;
585       l_inst_hist_rec_tab.old_inst_attribute2.DELETE;
586       l_inst_hist_rec_tab.new_inst_attribute2.DELETE;
587       l_inst_hist_rec_tab.old_inst_attribute3.DELETE;
588       l_inst_hist_rec_tab.new_inst_attribute3.DELETE;
589       l_inst_hist_rec_tab.old_inst_attribute4.DELETE;
590       l_inst_hist_rec_tab.new_inst_attribute4.DELETE;
591       l_inst_hist_rec_tab.old_inst_attribute5.DELETE;
592       l_inst_hist_rec_tab.new_inst_attribute5.DELETE;
593       l_inst_hist_rec_tab.old_inst_attribute6.DELETE;
594       l_inst_hist_rec_tab.new_inst_attribute6.DELETE;
595       l_inst_hist_rec_tab.old_inst_attribute7.DELETE;
596       l_inst_hist_rec_tab.new_inst_attribute7.DELETE;
597       l_inst_hist_rec_tab.old_inst_attribute8.DELETE;
598       l_inst_hist_rec_tab.new_inst_attribute8.DELETE;
599       l_inst_hist_rec_tab.old_inst_attribute9.DELETE;
600       l_inst_hist_rec_tab.new_inst_attribute9.DELETE;
601       l_inst_hist_rec_tab.old_inst_attribute10.DELETE;
602       l_inst_hist_rec_tab.new_inst_attribute10.DELETE;
603       l_inst_hist_rec_tab.old_inst_attribute11.DELETE;
604       l_inst_hist_rec_tab.new_inst_attribute11.DELETE;
605       l_inst_hist_rec_tab.old_inst_attribute12.DELETE;
606       l_inst_hist_rec_tab.new_inst_attribute12.DELETE;
607       l_inst_hist_rec_tab.old_inst_attribute13.DELETE;
608       l_inst_hist_rec_tab.new_inst_attribute13.DELETE;
609       l_inst_hist_rec_tab.old_inst_attribute14.DELETE;
610       l_inst_hist_rec_tab.new_inst_attribute14.DELETE;
611       l_inst_hist_rec_tab.old_inst_attribute15.DELETE;
612       l_inst_hist_rec_tab.new_inst_attribute15.DELETE;
613       l_inst_hist_rec_tab.old_install_location_type_code.DELETE;
614       l_inst_hist_rec_tab.new_install_location_type_code.DELETE;
615       l_inst_hist_rec_tab.old_install_location_id.DELETE;
616       l_inst_hist_rec_tab.new_install_location_id.DELETE;
617       l_inst_hist_rec_tab.old_instance_usage_code.DELETE;
618       l_inst_hist_rec_tab.new_instance_usage_code.DELETE;
619       l_inst_hist_rec_tab.old_config_inst_rev_num.DELETE;
620       l_inst_hist_rec_tab.new_config_inst_rev_num.DELETE;
621       l_inst_hist_rec_tab.old_config_valid_status.DELETE;
622       l_inst_hist_rec_tab.new_config_valid_status.DELETE;
623       l_inst_hist_rec_tab.old_instance_description.DELETE;
624       l_inst_hist_rec_tab.new_instance_description.DELETE;
625       l_inst_hist_rec_tab.instance_history_id.DELETE;
626       l_inst_hist_rec_tab.transaction_id.DELETE;
627       l_inst_hist_rec_tab.old_last_vld_organization_id.DELETE;
628       l_inst_hist_rec_tab.new_last_vld_organization_id.DELETE;
629       l_inst_hist_rec_tab.old_last_oe_agreement_id.DELETE;
630       l_inst_hist_rec_tab.new_last_oe_agreement_id.DELETE;
631       l_inst_hist_rec_tab.inst_full_dump_flag.DELETE;
632       l_inst_hist_rec_tab.inst_created_by.DELETE;
633       l_inst_hist_rec_tab.inst_creation_date.DELETE;
634       l_inst_hist_rec_tab.inst_last_updated_by.DELETE;
635       l_inst_hist_rec_tab.inst_last_update_date.DELETE;
636       l_inst_hist_rec_tab.inst_last_update_login.DELETE;
637       l_inst_hist_rec_tab.inst_object_version_number.DELETE;
641       l_inst_hist_rec_tab.old_network_asset_flag.DELETE;
638       l_inst_hist_rec_tab.inst_security_group_id.DELETE;
639       l_inst_hist_rec_tab.inst_migrated_flag.DELETE;
640       -- Added for eam
642       l_inst_hist_rec_tab.new_network_asset_flag.DELETE;
643       l_inst_hist_rec_tab.old_maintainable_flag.DELETE;
644       l_inst_hist_rec_tab.new_maintainable_flag.DELETE;
645       l_inst_hist_rec_tab.old_pn_location_id.DELETE;
646       l_inst_hist_rec_tab.new_pn_location_id.DELETE;
647       l_inst_hist_rec_tab.old_asset_criticality_code.DELETE;
648       l_inst_hist_rec_tab.new_asset_criticality_code.DELETE;
649       l_inst_hist_rec_tab.old_category_id.DELETE;
650       l_inst_hist_rec_tab.new_category_id.DELETE;
651       l_inst_hist_rec_tab.old_equipment_gen_object_id.DELETE;
652       l_inst_hist_rec_tab.new_equipment_gen_object_id.DELETE;
653       l_inst_hist_rec_tab.old_instantiation_flag.DELETE;
654       l_inst_hist_rec_tab.new_instantiation_flag.DELETE;
655       l_inst_hist_rec_tab.old_linear_location_id.DELETE;
656       l_inst_hist_rec_tab.new_linear_location_id.DELETE;
657       l_inst_hist_rec_tab.old_operational_log_flag.DELETE;
658       l_inst_hist_rec_tab.new_operational_log_flag.DELETE;
659       l_inst_hist_rec_tab.old_checkin_status.DELETE;
660       l_inst_hist_rec_tab.new_checkin_status.DELETE;
661       l_inst_hist_rec_tab.old_supplier_warranty_exp_date.DELETE;
662       l_inst_hist_rec_tab.new_supplier_warranty_exp_date.DELETE;
663       l_inst_hist_rec_tab.old_inst_attribute16.DELETE;
664       l_inst_hist_rec_tab.new_inst_attribute16.DELETE;
665       l_inst_hist_rec_tab.old_inst_attribute17.DELETE;
666       l_inst_hist_rec_tab.new_inst_attribute17.DELETE;
667       l_inst_hist_rec_tab.old_inst_attribute18.DELETE;
668       l_inst_hist_rec_tab.new_inst_attribute18.DELETE;
669       l_inst_hist_rec_tab.old_inst_attribute19.DELETE;
670       l_inst_hist_rec_tab.new_inst_attribute19.DELETE;
671       l_inst_hist_rec_tab.old_inst_attribute20.DELETE;
672       l_inst_hist_rec_tab.new_inst_attribute20.DELETE;
673       l_inst_hist_rec_tab.old_inst_attribute21.DELETE;
674       l_inst_hist_rec_tab.new_inst_attribute21.DELETE;
675       l_inst_hist_rec_tab.old_inst_attribute22.DELETE;
676       l_inst_hist_rec_tab.new_inst_attribute22.DELETE;
677       l_inst_hist_rec_tab.old_inst_attribute23.DELETE;
678       l_inst_hist_rec_tab.new_inst_attribute23.DELETE;
679       l_inst_hist_rec_tab.old_inst_attribute24.DELETE;
680       l_inst_hist_rec_tab.new_inst_attribute24.DELETE;
681       l_inst_hist_rec_tab.old_inst_attribute25.DELETE;
682       l_inst_hist_rec_tab.new_inst_attribute25.DELETE;
683       l_inst_hist_rec_tab.old_inst_attribute26.DELETE;
684       l_inst_hist_rec_tab.new_inst_attribute26.DELETE;
685       l_inst_hist_rec_tab.old_inst_attribute27.DELETE;
686       l_inst_hist_rec_tab.new_inst_attribute27.DELETE;
687       l_inst_hist_rec_tab.old_inst_attribute28.DELETE;
688       l_inst_hist_rec_tab.new_inst_attribute28.DELETE;
689       l_inst_hist_rec_tab.old_inst_attribute29.DELETE;
690       l_inst_hist_rec_tab.new_inst_attribute29.DELETE;
691       l_inst_hist_rec_tab.old_inst_attribute30.DELETE;
692       l_inst_hist_rec_tab.new_inst_attribute30.DELETE;
693       -- End addition for eam
694       --
695   For i in inst_hist_csr(v_start,v_end)
696   Loop
697 
698       l_ctr := l_ctr + 1;
699 
700       Select csi_history_archive_s.Nextval
701       Into l_archive_id_tbl(l_ctr)
702       From dual;
703 
704       l_inst_hist_rec_tab.instance_id(l_ctr)	                :=  i.instance_id;
705       l_inst_hist_rec_tab.old_instance_number(l_ctr)	        :=  i.old_instance_number;
706       l_inst_hist_rec_tab.new_instance_number(l_ctr)            :=  i.new_instance_number;
707       l_inst_hist_rec_tab.old_external_reference(l_ctr)	        :=  i.old_external_reference;
708       l_inst_hist_rec_tab.new_external_reference(l_ctr)	        :=  i.new_external_reference;
709       l_inst_hist_rec_tab.old_inventory_item_id(l_ctr)	        :=  i.old_inventory_item_id;
710       l_inst_hist_rec_tab.new_inventory_item_id(l_ctr)	        :=  i.new_inventory_item_id;
711       l_inst_hist_rec_tab.old_inventory_revision(l_ctr)	        :=  i.old_inventory_revision;
712       l_inst_hist_rec_tab.new_inventory_revision(l_ctr)	        :=  i.new_inventory_revision;
713       l_inst_hist_rec_tab.old_inv_master_org_id(l_ctr)	        :=  i.old_inv_master_organization_id;
714       l_inst_hist_rec_tab.new_inv_master_org_id(l_ctr)	        :=  i.new_inv_master_organization_id;
715       l_inst_hist_rec_tab.old_serial_number(l_ctr)	            :=  i.old_serial_number;
716       l_inst_hist_rec_tab.new_serial_number(l_ctr)	            :=  i.new_serial_number;
717       l_inst_hist_rec_tab.old_mfg_serial_number_flag(l_ctr)     :=  i.old_mfg_serial_number_flag;
718       l_inst_hist_rec_tab.new_mfg_serial_number_flag(l_ctr)     :=  i.new_mfg_serial_number_flag;
719       l_inst_hist_rec_tab.old_lot_number(l_ctr)	                :=  i.old_lot_number;
720       l_inst_hist_rec_tab.new_lot_number(l_ctr)	                :=  i.new_lot_number;
721       l_inst_hist_rec_tab.old_quantity(l_ctr)	                :=  i.old_quantity;
722       l_inst_hist_rec_tab.new_quantity(l_ctr)	                :=  i.new_quantity;
723       l_inst_hist_rec_tab.old_unit_of_measure(l_ctr)	        :=  i.old_unit_of_measure;
724       l_inst_hist_rec_tab.new_unit_of_measure(l_ctr)	        :=  i.new_unit_of_measure;
725       l_inst_hist_rec_tab.old_accounting_class_code(l_ctr)      :=  i.old_accounting_class_code;
726       l_inst_hist_rec_tab.new_accounting_class_code(l_ctr)      :=  i.new_accounting_class_code;
727       l_inst_hist_rec_tab.old_instance_condition_id(l_ctr)      :=  i.old_instance_condition_id;
728       l_inst_hist_rec_tab.new_instance_condition_id(l_ctr)      :=  i.new_instance_condition_id;
729       l_inst_hist_rec_tab.old_instance_status_id(l_ctr)	        :=  i.old_instance_status_id;
730       l_inst_hist_rec_tab.new_instance_status_id(l_ctr)	        :=  i.new_instance_status_id;
731       l_inst_hist_rec_tab.old_customer_view_flag(l_ctr)	        :=  i.old_customer_view_flag;
732       l_inst_hist_rec_tab.new_customer_view_flag(l_ctr)	        :=  i.new_customer_view_flag;
733       l_inst_hist_rec_tab.old_merchant_view_flag(l_ctr)	        :=  i.old_merchant_view_flag;
734       l_inst_hist_rec_tab.new_merchant_view_flag(l_ctr)	        :=  i.new_merchant_view_flag;
735       l_inst_hist_rec_tab.old_sellable_flag(l_ctr)	            :=  i.old_sellable_flag;
736       l_inst_hist_rec_tab.new_sellable_flag(l_ctr)	            :=  i.new_sellable_flag;
737       l_inst_hist_rec_tab.old_system_id(l_ctr)	                :=  i.old_system_id;
738       l_inst_hist_rec_tab.new_system_id(l_ctr)	                :=  i.new_system_id;
739       l_inst_hist_rec_tab.old_instance_type_code(l_ctr)	        :=  i.old_instance_type_code;
740       l_inst_hist_rec_tab.new_instance_type_code(l_ctr)	        :=  i.new_instance_type_code;
741       l_inst_hist_rec_tab.old_active_start_date(l_ctr)	        :=  i.old_active_start_date;
742       l_inst_hist_rec_tab.new_active_start_date(l_ctr)	        :=  i.new_active_start_date;
743       l_inst_hist_rec_tab.old_active_end_date(l_ctr)	        :=  i.old_active_end_date;
744       l_inst_hist_rec_tab.new_active_end_date(l_ctr)	        :=  i.new_active_end_date;
745       l_inst_hist_rec_tab.old_location_type_code(l_ctr)	        :=  i.old_location_type_code;
746       l_inst_hist_rec_tab.new_location_type_code(l_ctr)	        :=  i.new_location_type_code;
747       l_inst_hist_rec_tab.old_location_id(l_ctr)	            :=  i.old_location_id;
748       l_inst_hist_rec_tab.new_location_id(l_ctr)	            :=  i.new_location_id;
749       l_inst_hist_rec_tab.old_inv_organization_id(l_ctr)        :=  i.old_inv_organization_id;
750       l_inst_hist_rec_tab.new_inv_organization_id(l_ctr)        :=  i.new_inv_organization_id;
751       l_inst_hist_rec_tab.old_inv_subinventory_name(l_ctr)      :=  i.old_inv_subinventory_name;
752       l_inst_hist_rec_tab.new_inv_subinventory_name(l_ctr)      :=  i.new_inv_subinventory_name;
753       l_inst_hist_rec_tab.old_inv_locator_id(l_ctr)	            :=  i.old_inv_locator_id;
754       l_inst_hist_rec_tab.new_inv_locator_id(l_ctr)	            :=  i.new_inv_locator_id;
755       l_inst_hist_rec_tab.old_pa_project_id(l_ctr)	            :=  i.old_pa_project_id;
756       l_inst_hist_rec_tab.new_pa_project_id(l_ctr)	            :=  i.new_pa_project_id;
757       l_inst_hist_rec_tab.old_pa_project_task_id(l_ctr)	        :=  i.old_pa_project_task_id;
758       l_inst_hist_rec_tab.new_pa_project_task_id(l_ctr)	        :=  i.new_pa_project_task_id;
759       l_inst_hist_rec_tab.old_in_transit_order_line_id(l_ctr)   :=  i.old_in_transit_order_line_id;
763       l_inst_hist_rec_tab.old_po_order_line_id(l_ctr)           :=  i.old_po_order_line_id;
760       l_inst_hist_rec_tab.new_in_transit_order_line_id(l_ctr)   :=  i.new_in_transit_order_line_id;
761       l_inst_hist_rec_tab.old_wip_job_id(l_ctr)	                :=  i.old_wip_job_id;
762       l_inst_hist_rec_tab.new_wip_job_id(l_ctr)	                :=  i.new_wip_job_id;
764       l_inst_hist_rec_tab.new_po_order_line_id(l_ctr)           :=  i.new_po_order_line_id;
765       l_inst_hist_rec_tab.old_install_date(l_ctr)	            :=  i.old_install_date;
766       l_inst_hist_rec_tab.new_install_date(l_ctr)	            :=  i.new_install_date;
767       l_inst_hist_rec_tab.old_return_by_date(l_ctr)	            :=  i.old_return_by_date;
768       l_inst_hist_rec_tab.new_return_by_date(l_ctr)	            :=  i.new_return_by_date;
769       l_inst_hist_rec_tab.old_actual_return_date(l_ctr)	        :=  i.old_actual_return_date;
770       l_inst_hist_rec_tab.new_actual_return_date(l_ctr)	        :=  i.new_actual_return_date;
771       l_inst_hist_rec_tab.old_completeness_flag(l_ctr)	        :=  i.old_completeness_flag;
772       l_inst_hist_rec_tab.new_completeness_flag(l_ctr)	        :=  i.new_completeness_flag;
773       l_inst_hist_rec_tab.old_inst_context(l_ctr)	            :=  i.old_context;
774       l_inst_hist_rec_tab.new_inst_context(l_ctr)	            :=  i.new_context;
775       l_inst_hist_rec_tab.old_inst_attribute1(l_ctr)	        :=  i.old_attribute1;
776       l_inst_hist_rec_tab.new_inst_attribute1(l_ctr)	        :=  i.new_attribute1;
777       l_inst_hist_rec_tab.old_inst_attribute2(l_ctr)	        :=  i.old_attribute2;
778       l_inst_hist_rec_tab.new_inst_attribute2(l_ctr)	        :=  i.new_attribute2;
779       l_inst_hist_rec_tab.old_inst_attribute3(l_ctr)	        :=  i.old_attribute3;
780       l_inst_hist_rec_tab.new_inst_attribute3(l_ctr)	        :=  i.new_attribute3;
781       l_inst_hist_rec_tab.old_inst_attribute4(l_ctr)	        :=  i.old_attribute4;
782       l_inst_hist_rec_tab.new_inst_attribute4(l_ctr)	        :=  i.new_attribute4;
783       l_inst_hist_rec_tab.old_inst_attribute5(l_ctr)	        :=  i.old_attribute5;
784       l_inst_hist_rec_tab.new_inst_attribute5(l_ctr)	        :=  i.new_attribute5;
785       l_inst_hist_rec_tab.old_inst_attribute6(l_ctr)	        :=  i.old_attribute6;
786       l_inst_hist_rec_tab.new_inst_attribute6(l_ctr)	        :=  i.new_attribute6;
787       l_inst_hist_rec_tab.old_inst_attribute7(l_ctr)	        :=  i.old_attribute7;
788       l_inst_hist_rec_tab.new_inst_attribute7(l_ctr)	        :=  i.new_attribute7;
789       l_inst_hist_rec_tab.old_inst_attribute8(l_ctr)	        :=  i.old_attribute8;
790       l_inst_hist_rec_tab.new_inst_attribute8(l_ctr)	        :=  i.new_attribute8;
791       l_inst_hist_rec_tab.old_inst_attribute9(l_ctr)	        :=  i.old_attribute9;
792       l_inst_hist_rec_tab.new_inst_attribute9(l_ctr)	        :=  i.new_attribute9;
793       l_inst_hist_rec_tab.old_inst_attribute10(l_ctr)	        :=  i.old_attribute10;
794       l_inst_hist_rec_tab.new_inst_attribute10(l_ctr)	        :=  i.new_attribute10;
795       l_inst_hist_rec_tab.old_inst_attribute11(l_ctr)      	    :=  i.old_attribute11;
796       l_inst_hist_rec_tab.new_inst_attribute11(l_ctr)	        :=  i.new_attribute11;
797       l_inst_hist_rec_tab.old_inst_attribute12(l_ctr)	        :=  i.old_attribute12;
798       l_inst_hist_rec_tab.new_inst_attribute12(l_ctr)	        :=  i.new_attribute12;
799       l_inst_hist_rec_tab.old_inst_attribute13(l_ctr)	        :=  i.old_attribute13;
800       l_inst_hist_rec_tab.new_inst_attribute13(l_ctr)	        :=  i.new_attribute13;
801       l_inst_hist_rec_tab.old_inst_attribute14(l_ctr)	        :=  i.old_attribute14;
802       l_inst_hist_rec_tab.new_inst_attribute14(l_ctr)	        :=  i.new_attribute14;
803       l_inst_hist_rec_tab.old_inst_attribute15(l_ctr)	        :=  i.old_attribute15;
804       l_inst_hist_rec_tab.new_inst_attribute15(l_ctr)	        :=  i.new_attribute15;
805       l_inst_hist_rec_tab.old_install_location_type_code(l_ctr) :=  i.old_inst_loc_type_code;
806       l_inst_hist_rec_tab.new_install_location_type_code(l_ctr) :=  i.new_inst_loc_type_code;
807       l_inst_hist_rec_tab.old_install_location_id(l_ctr)        :=  i.old_inst_loc_id;
808       l_inst_hist_rec_tab.new_install_location_id(l_ctr)        :=  i.new_inst_loc_id;
809       l_inst_hist_rec_tab.old_instance_usage_code(l_ctr)        :=  i.old_inst_usage_code;
810       l_inst_hist_rec_tab.new_instance_usage_code(l_ctr)        :=  i.new_inst_usage_code;
811       l_inst_hist_rec_tab.old_config_inst_rev_num(l_ctr)        :=  i.old_config_inst_rev_num;
812       l_inst_hist_rec_tab.new_config_inst_rev_num(l_ctr)        :=  i.new_config_inst_rev_num;
813       l_inst_hist_rec_tab.old_config_valid_status(l_ctr)        :=  i.old_config_valid_status;
814       l_inst_hist_rec_tab.new_config_valid_status(l_ctr)        :=  i.new_config_valid_status;
815       l_inst_hist_rec_tab.old_instance_description(l_ctr)       :=  i.old_instance_description;
816       l_inst_hist_rec_tab.new_instance_description(l_ctr)       :=  i.new_instance_description;
817       l_inst_hist_rec_tab.instance_history_id(l_ctr)	        :=  i.instance_history_id;
818       l_inst_hist_rec_tab.transaction_id(l_ctr)	                :=  i.transaction_id;
819       l_inst_hist_rec_tab.old_last_vld_organization_id(l_ctr)   :=  i.old_last_vld_organization_id;
820       l_inst_hist_rec_tab.new_last_vld_organization_id(l_ctr)   :=  i.new_last_vld_organization_id;
821       l_inst_hist_rec_tab.old_last_oe_agreement_id(l_ctr)       :=  i.old_oe_agreement_id;
822       l_inst_hist_rec_tab.new_last_oe_agreement_id(l_ctr)       :=  i.new_oe_agreement_id;
823       l_inst_hist_rec_tab.inst_full_dump_flag(l_ctr)            :=  i.full_dump_flag;
824       l_inst_hist_rec_tab.inst_created_by(l_ctr)                :=  i.created_by;
825       l_inst_hist_rec_tab.inst_creation_date(l_ctr)             :=  i.creation_date;
826       l_inst_hist_rec_tab.inst_last_updated_by(l_ctr)           :=  i.last_updated_by;
827       l_inst_hist_rec_tab.inst_last_update_date(l_ctr)          :=  i.last_update_date;
831       l_inst_hist_rec_tab.inst_migrated_flag(l_ctr)             :=  i.migrated_flag;
828       l_inst_hist_rec_tab.inst_last_update_login(l_ctr)         :=  i.last_update_login;
829       l_inst_hist_rec_tab.inst_object_version_number(l_ctr)     :=  i.object_version_number;
830       l_inst_hist_rec_tab.inst_security_group_id(l_ctr)         :=  i.security_group_id;
832       -- Added for eam
833       l_inst_hist_rec_tab.old_network_asset_flag(l_ctr)         :=  i.old_network_asset_flag ;
834       l_inst_hist_rec_tab.new_network_asset_flag(l_ctr)         :=  i.new_network_asset_flag ;
835       l_inst_hist_rec_tab.old_maintainable_flag(l_ctr)          :=  i.old_maintainable_flag ;
836       l_inst_hist_rec_tab.new_maintainable_flag(l_ctr)          :=  i.new_maintainable_flag ;
837       l_inst_hist_rec_tab.old_pn_location_id(l_ctr)             :=  i.old_pn_location_id ;
838       l_inst_hist_rec_tab.new_pn_location_id(l_ctr)             :=  i.new_pn_location_id ;
839       l_inst_hist_rec_tab.old_asset_criticality_code(l_ctr)     :=  i.old_asset_criticality_code ;
840       l_inst_hist_rec_tab.new_asset_criticality_code(l_ctr)     :=  i.new_asset_criticality_code ;
841       l_inst_hist_rec_tab.old_category_id(l_ctr)                :=  i.old_category_id ;
842       l_inst_hist_rec_tab.new_category_id(l_ctr)                :=  i.new_category_id ;
843       l_inst_hist_rec_tab.old_equipment_gen_object_id(l_ctr)    :=  i.old_equipment_gen_object_id ;
844       l_inst_hist_rec_tab.new_equipment_gen_object_id(l_ctr)    :=  i.new_equipment_gen_object_id ;
845       l_inst_hist_rec_tab.old_instantiation_flag(l_ctr)         :=  i.old_instantiation_flag ;
846       l_inst_hist_rec_tab.new_instantiation_flag(l_ctr)         :=  i.new_instantiation_flag ;
847       l_inst_hist_rec_tab.old_linear_location_id(l_ctr)         :=  i.old_linear_location_id ;
848       l_inst_hist_rec_tab.new_linear_location_id(l_ctr)         :=  i.new_linear_location_id ;
849       l_inst_hist_rec_tab.old_operational_log_flag(l_ctr)       :=  i.old_operational_log_flag ;
850       l_inst_hist_rec_tab.new_operational_log_flag(l_ctr)       :=  i.new_operational_log_flag ;
851       l_inst_hist_rec_tab.old_checkin_status(l_ctr)             :=  i.old_checkin_status ;
852       l_inst_hist_rec_tab.new_checkin_status(l_ctr)             :=  i.new_checkin_status ;
853       l_inst_hist_rec_tab.old_supplier_warranty_exp_date(l_ctr) :=  i.old_supplier_warranty_exp_date ;
854       l_inst_hist_rec_tab.new_supplier_warranty_exp_date(l_ctr) :=  i.new_supplier_warranty_exp_date ;
855       l_inst_hist_rec_tab.old_inst_attribute16(l_ctr)           :=  i.old_attribute16;
856       l_inst_hist_rec_tab.new_inst_attribute16(l_ctr)           :=  i.new_attribute16;
857       l_inst_hist_rec_tab.old_inst_attribute17(l_ctr)           :=  i.old_attribute17;
858       l_inst_hist_rec_tab.new_inst_attribute17(l_ctr)           :=  i.new_attribute17;
859       l_inst_hist_rec_tab.old_inst_attribute18(l_ctr)           :=  i.old_attribute18;
860       l_inst_hist_rec_tab.new_inst_attribute18(l_ctr)           :=  i.new_attribute18;
861       l_inst_hist_rec_tab.old_inst_attribute19(l_ctr)           :=  i.old_attribute19;
862       l_inst_hist_rec_tab.new_inst_attribute19(l_ctr)           :=  i.new_attribute19;
863       l_inst_hist_rec_tab.old_inst_attribute20(l_ctr)           :=  i.old_attribute20;
864       l_inst_hist_rec_tab.new_inst_attribute20(l_ctr)           :=  i.new_attribute20;
865       l_inst_hist_rec_tab.old_inst_attribute21(l_ctr)           :=  i.old_attribute21;
866       l_inst_hist_rec_tab.new_inst_attribute21(l_ctr)           :=  i.new_attribute21;
867       l_inst_hist_rec_tab.old_inst_attribute22(l_ctr)           :=  i.old_attribute22;
868       l_inst_hist_rec_tab.new_inst_attribute22(l_ctr)           :=  i.new_attribute22;
869       l_inst_hist_rec_tab.old_inst_attribute23(l_ctr)           :=  i.old_attribute23;
870       l_inst_hist_rec_tab.new_inst_attribute23(l_ctr)           :=  i.new_attribute23;
871       l_inst_hist_rec_tab.old_inst_attribute24(l_ctr)           :=  i.old_attribute24;
872       l_inst_hist_rec_tab.new_inst_attribute24(l_ctr)           :=  i.new_attribute24;
873       l_inst_hist_rec_tab.old_inst_attribute25(l_ctr)           :=  i.old_attribute25;
874       l_inst_hist_rec_tab.new_inst_attribute25(l_ctr)           :=  i.new_attribute25;
875       l_inst_hist_rec_tab.old_inst_attribute26(l_ctr)           :=  i.old_attribute26;
876       l_inst_hist_rec_tab.new_inst_attribute26(l_ctr)           :=  i.new_attribute26;
877       l_inst_hist_rec_tab.old_inst_attribute27(l_ctr)           :=  i.old_attribute27;
878       l_inst_hist_rec_tab.new_inst_attribute27(l_ctr)           :=  i.new_attribute27;
879       l_inst_hist_rec_tab.old_inst_attribute28(l_ctr)           :=  i.old_attribute28;
880       l_inst_hist_rec_tab.new_inst_attribute28(l_ctr)           :=  i.new_attribute28;
881       l_inst_hist_rec_tab.old_inst_attribute29(l_ctr)           :=  i.old_attribute29;
882       l_inst_hist_rec_tab.new_inst_attribute29(l_ctr)           :=  i.new_attribute29;
883       l_inst_hist_rec_tab.old_inst_attribute30(l_ctr)           :=  i.old_attribute30;
884       l_inst_hist_rec_tab.new_inst_attribute30(l_ctr)           :=  i.new_attribute30;
885       -- End addition for eam
886 
887    End Loop;
888 
889       l_cnt := l_inst_hist_rec_tab.instance_history_id.count;
890       Debug('');
891       Debug('');
892       Debug('Number of Instance history records archived:'||to_char(l_cnt));
893       Debug('');
894       Debug('');
895 --      Debug('Seq val is '||to_char(l_archive_id_tbl(l_cnt)));
896 --      Debug('Srl count is '||to_char(l_inst_hist_rec_tab.new_serial_number.count));
897 --      Debug('Install Date count is '||to_char(l_inst_hist_rec_tab.new_install_date.count));
898    --
899    If l_cnt > 0 Then
900 
901    -- Archive the Instance History Data for the Transaction range
902       FORALL i IN 1 .. l_cnt
903 
904          Insert Into CSI_HISTORY_ARCHIVE
905          (
906            HISTORY_ARCHIVE_ID
907           ,OBJECT_ID
908           ,ENTITY_HISTORY_ID
912           ,COL_NUM_02
909           ,TRANSACTION_ID
910           ,ENTITY_ID
911           ,COL_NUM_01
913           ,COL_NUM_03
914           ,COL_NUM_04
915           ,COL_NUM_05
916           ,COL_NUM_06
917           ,COL_NUM_07
918           ,COL_NUM_08
919           ,COL_NUM_09
920           ,COL_NUM_10
921           ,COL_NUM_11
922           ,COL_NUM_12
923           ,COL_NUM_13
924           ,COL_NUM_14
925           ,COL_NUM_15
926           ,COL_NUM_16
927           ,COL_NUM_17
928           ,COL_NUM_18
929           ,COL_NUM_19
930           ,COL_NUM_20
931           ,COL_NUM_21
932           ,COL_NUM_22
933           ,COL_NUM_23
934           ,COL_NUM_24
935           ,COL_NUM_25
936           ,COL_NUM_26
937           ,COL_NUM_27
938           ,COL_NUM_28
939           ,COL_NUM_29
940           ,COL_NUM_30
941           ,COL_NUM_31
942           ,COL_NUM_32
943           ,COL_NUM_33
944           ,COL_NUM_34
945           ,COL_NUM_35
946           ,COL_NUM_36
947           ,COL_NUM_37 -- entity creation_by
948           ,COL_NUM_38 -- entity last_updated_by
949           ,COL_NUM_39 -- entity last_update_login
950           ,COL_NUM_40 -- entity object_version_number
951           ,COL_NUM_41 -- entity security_group_id
952 
953           ,COL_NUM_42 -- entity old_pn_location_id
954           ,COL_NUM_43 -- entity new_pn_location_id
955           ,COL_NUM_44 -- entity old_category_id
956           ,COL_NUM_45 -- entity new_category_id
957           ,COL_NUM_46 -- entity old_equipment_gen_object_id
958           ,COL_NUM_47 -- entity new_equipment_gen_object_id
959           ,COL_NUM_48 -- entity old_linear_location_id
960           ,COL_NUM_49 -- entity new_linear_location_id
961           ,COL_NUM_50 -- entity old_checkin_status
962           ,COL_NUM_51 -- entity new_checkin_status
963 
964           ,COL_CHAR_01
965           ,COL_CHAR_02
966           ,COL_CHAR_03
967           ,COL_CHAR_04
968           ,COL_CHAR_05
969           ,COL_CHAR_06
970           ,COL_CHAR_07
971           ,COL_CHAR_08
972           ,COL_CHAR_09
973           ,COL_CHAR_10
974           ,COL_CHAR_11
975           ,COL_CHAR_12
976           ,COL_CHAR_13
977           ,COL_CHAR_14
978           ,COL_CHAR_15
979           ,COL_CHAR_16
980           ,COL_CHAR_17
981           ,COL_CHAR_18
982           ,COL_CHAR_19
983           ,COL_CHAR_20
984           ,COL_CHAR_21
985           ,COL_CHAR_22
986           ,COL_CHAR_23
987           ,COL_CHAR_24
988           ,COL_CHAR_25
989           ,COL_CHAR_26
990           ,COL_CHAR_27
991           ,COL_CHAR_28
992           ,COL_CHAR_29
993           ,COL_CHAR_30
994           ,COL_CHAR_31 -- entity old_context
995           ,COL_CHAR_32 -- entity new_context
996           ,COL_CHAR_33 -- entity old_attribute1
997           ,COL_CHAR_34 -- entity new_attribute1
998           ,COL_CHAR_35 -- entity old_attribute2
999           ,COL_CHAR_36 -- entity new_attribute2
1000           ,COL_CHAR_37 -- entity old_attribute3
1001           ,COL_CHAR_38 -- entity new_attribute3
1002           ,COL_CHAR_39 -- entity old_attribute4
1003           ,COL_CHAR_40 -- entity new_attribute4
1004           ,COL_CHAR_41 -- entity old_attribute5
1005           ,COL_CHAR_42 -- entity new_attribute5
1006           ,COL_CHAR_43 -- entity old_attribute6
1007           ,COL_CHAR_44 -- entity new_attribute6
1008           ,COL_CHAR_45 -- entity old_attribute7
1009           ,COL_CHAR_46 -- entity new_attribute7
1010           ,COL_CHAR_47 -- entity old_attribute8
1011           ,COL_CHAR_48 -- entity new_attribute8
1012           ,COL_CHAR_49 -- entity old_attribute9
1013           ,COL_CHAR_50 -- entity new_attribute9
1014           ,COL_CHAR_51 -- entity old_attribute10
1015           ,COL_CHAR_52 -- entity new_attribute10
1016           ,COL_CHAR_53 -- entity old_attribute11
1017           ,COL_CHAR_54 -- entity new_attribute11
1018           ,COL_CHAR_55 -- entity old_attribute12
1019           ,COL_CHAR_56 -- entity new_attribute12
1020           ,COL_CHAR_57 -- entity old_attribute13
1021           ,COL_CHAR_58 -- entity new_attribute13
1022           ,COL_CHAR_59 -- entity old_attribute14
1023           ,COL_CHAR_60 -- entity new_attribute14
1024           ,COL_CHAR_61 -- entity old_attribute15
1025           ,COL_CHAR_62 -- entity new_attribute15
1026           ,COL_CHAR_63
1027           ,COL_CHAR_64
1028           ,COL_CHAR_65
1029           ,COL_CHAR_66
1030           ,COL_CHAR_67
1031           ,COL_CHAR_68
1032           ,COL_CHAR_69
1033           ,COL_CHAR_70
1034           ,COL_CHAR_71 -- entity full_dump_flag
1035           ,COL_CHAR_72 -- entity migrated_flag
1036 
1037           ,COL_CHAR_73 -- entity old_attribute16
1038           ,COL_CHAR_74 -- entity new_attribute16
1039           ,COL_CHAR_75 -- entity old_attribute17
1040           ,COL_CHAR_76 -- entity new_attribute17
1041           ,COL_CHAR_77 -- entity old_attribute18
1042           ,COL_CHAR_78 -- entity new_attribute18
1043           ,COL_CHAR_79 -- entity old_attribute19
1044           ,COL_CHAR_80 -- entity new_attribute19
1045           ,COL_CHAR_81 -- entity old_attribute20
1046           ,COL_CHAR_82 -- entity new_attribute20
1047           ,COL_CHAR_83 -- entity old_attribute21
1048           ,COL_CHAR_84 -- entity new_attribute21
1049           ,COL_CHAR_85 -- entity old_attribute22
1053           ,COL_CHAR_89 -- entity old_attribute24
1050           ,COL_CHAR_86 -- entity new_attribute22
1051           ,COL_CHAR_87 -- entity old_attribute23
1052           ,COL_CHAR_88 -- entity new_attribute23
1054           ,COL_CHAR_90 -- entity new_attribute24
1055           ,COL_CHAR_91 -- entity old_attribute25
1056           ,COL_CHAR_92 -- entity new_attribute25
1057           ,COL_CHAR_93 -- entity old_attribute26
1058           ,COL_CHAR_94 -- entity new_attribute26
1059           ,COL_CHAR_95 -- entity old_attribute27
1060           ,COL_CHAR_96 -- entity new_attribute27
1061           ,COL_CHAR_97 -- entity old_attribute28
1062           ,COL_CHAR_98 -- entity new_attribute28
1063           ,COL_CHAR_99 -- entity old_attribute29
1064           ,COL_CHAR_100 -- entity new_attribute29
1065           ,COL_CHAR_101 -- entity old_attribute30
1066           ,COL_CHAR_102 -- entity new_attribute30
1067 
1068           ,COL_CHAR_103 -- entity old_network_asset_flag
1069           ,COL_CHAR_104 -- entity new_network_asset_flag
1070           ,COL_CHAR_105 -- entity old_maintainable_flag
1071           ,COL_CHAR_106 -- entity new_maintainable_flag
1072           ,COL_CHAR_107 -- entity old_asset_criticality_code
1073           ,COL_CHAR_108 -- entity new_asset_criticality_code
1074           ,COL_CHAR_109 -- entity old_instantiation_flag
1075           ,COL_CHAR_110 -- entity new_instantiation_flag
1076           ,COL_CHAR_111 -- entity old_operational_log_flag
1077           ,COL_CHAR_112 -- entity new_operational_log_flag
1078 
1079           ,COL_DATE_01  -- entity old_active_start_date
1080           ,COL_DATE_02  -- entity new_active_start_date
1081           ,COL_DATE_03  -- entity old_active_end_date
1082           ,COL_DATE_04  -- entity new_active_end_date
1083           ,COL_DATE_05
1084           ,COL_DATE_06
1085           ,COL_DATE_07
1086           ,COL_DATE_08
1087           ,COL_DATE_09
1088           ,COL_DATE_10
1089           ,COL_DATE_11 -- entity creation_date
1090           ,COL_DATE_12 -- entity last_update_date
1091 
1092           ,COL_DATE_13 -- entity old_supplier_warranty_exp_date
1093           ,COL_DATE_14 -- entity new_supplier_warranty_exp_date
1094 
1095           ,CONTEXT
1096           ,ATTRIBUTE1
1097           ,ATTRIBUTE2
1098           ,ATTRIBUTE3
1099           ,ATTRIBUTE4
1100           ,ATTRIBUTE5
1101           ,ATTRIBUTE6
1102           ,ATTRIBUTE7
1103           ,ATTRIBUTE8
1104           ,ATTRIBUTE9
1105           ,ATTRIBUTE10
1106           ,ATTRIBUTE11
1107           ,ATTRIBUTE12
1108           ,ATTRIBUTE13
1109           ,ATTRIBUTE14
1110           ,ATTRIBUTE15
1111           ,CREATED_BY
1112           ,CREATION_DATE
1113           ,LAST_UPDATED_BY
1114           ,LAST_UPDATE_DATE
1115           ,LAST_UPDATE_LOGIN
1116           ,OBJECT_VERSION_NUMBER
1117           ,SECURITY_GROUP_ID
1118           )
1119 		  Values
1120           (
1121           l_archive_id_tbl(i),
1122           l_table_id,
1123 	 	  l_inst_hist_rec_tab.instance_history_id(i),
1124 		  l_inst_hist_rec_tab.transaction_id(i),
1125 		  l_inst_hist_rec_tab.instance_id(i),
1126 		  l_inst_hist_rec_tab.old_inventory_item_id(i),
1127 		  l_inst_hist_rec_tab.new_inventory_item_id(i),
1128 		  l_inst_hist_rec_tab.old_inv_master_org_id(i),
1129 		  l_inst_hist_rec_tab.new_inv_master_org_id(i),
1130 		  l_inst_hist_rec_tab.old_quantity(i),
1131 		  l_inst_hist_rec_tab.new_quantity(i),
1132 		  l_inst_hist_rec_tab.old_instance_condition_id(i),
1133 		  l_inst_hist_rec_tab.new_instance_condition_id(i),
1134 		  l_inst_hist_rec_tab.old_instance_status_id(i),
1135 		  l_inst_hist_rec_tab.new_instance_status_id(i),
1136 		  l_inst_hist_rec_tab.old_system_id(i),
1137 		  l_inst_hist_rec_tab.new_system_id(i),
1138 		  l_inst_hist_rec_tab.old_location_id(i),
1139 		  l_inst_hist_rec_tab.new_location_id(i),
1140 		  l_inst_hist_rec_tab.old_inv_organization_id(i),
1141 		  l_inst_hist_rec_tab.new_inv_organization_id(i),
1142 		  l_inst_hist_rec_tab.old_inv_locator_id(i),
1143 		  l_inst_hist_rec_tab.new_inv_locator_id(i),
1144 		  l_inst_hist_rec_tab.old_pa_project_id(i),
1145 		  l_inst_hist_rec_tab.new_pa_project_id(i),
1146 		  l_inst_hist_rec_tab.old_pa_project_task_id(i),
1147 		  l_inst_hist_rec_tab.new_pa_project_task_id(i),
1148 		  l_inst_hist_rec_tab.old_in_transit_order_line_id(i),
1149 		  l_inst_hist_rec_tab.new_in_transit_order_line_id(i),
1150 		  l_inst_hist_rec_tab.old_wip_job_id(i),
1151 		  l_inst_hist_rec_tab.new_wip_job_id(i),
1152 		  l_inst_hist_rec_tab.old_po_order_line_id(i),
1153 		  l_inst_hist_rec_tab.new_po_order_line_id(i),
1154 		  l_inst_hist_rec_tab.old_install_location_id(i),
1155 		  l_inst_hist_rec_tab.new_install_location_id(i),
1156 		  l_inst_hist_rec_tab.old_last_vld_organization_id(i),
1157 		  l_inst_hist_rec_tab.new_last_vld_organization_id(i),
1158           l_inst_hist_rec_tab.old_last_oe_agreement_id(i),
1159           l_inst_hist_rec_tab.new_last_oe_agreement_id(i),
1160 		  l_inst_hist_rec_tab.old_config_inst_rev_num(i),
1161 		  l_inst_hist_rec_tab.new_config_inst_rev_num(i),
1162    		  l_inst_hist_rec_tab.inst_created_by(i),
1163    		  l_inst_hist_rec_tab.inst_last_updated_by(i),
1164    		  l_inst_hist_rec_tab.inst_last_update_login(i),
1165    		  l_inst_hist_rec_tab.inst_object_version_number(i),
1166    		  l_inst_hist_rec_tab.inst_security_group_id(i),
1167           -- Added for eam
1168           l_inst_hist_rec_tab.old_pn_location_id(i),
1169           l_inst_hist_rec_tab.new_pn_location_id(i),
1170           l_inst_hist_rec_tab.old_category_id(i),
1171           l_inst_hist_rec_tab.new_category_id(i),
1172           l_inst_hist_rec_tab.old_equipment_gen_object_id(i),
1173           l_inst_hist_rec_tab.new_equipment_gen_object_id(i),
1177           l_inst_hist_rec_tab.new_checkin_status(i),
1174           l_inst_hist_rec_tab.old_linear_location_id(i),
1175           l_inst_hist_rec_tab.new_linear_location_id(i),
1176           l_inst_hist_rec_tab.old_checkin_status(i),
1178           -- End addition for eam
1179 		  l_inst_hist_rec_tab.old_instance_number(i),
1180 		  l_inst_hist_rec_tab.new_instance_number(i),
1181 		  l_inst_hist_rec_tab.old_external_reference(i),
1182 		  l_inst_hist_rec_tab.new_external_reference(i),
1183 		  l_inst_hist_rec_tab.old_inventory_revision(i),
1184 		  l_inst_hist_rec_tab.new_inventory_revision(i),
1185 		  l_inst_hist_rec_tab.old_serial_number(i),
1186 		  l_inst_hist_rec_tab.new_serial_number(i),
1187 		  l_inst_hist_rec_tab.old_mfg_serial_number_flag(i),
1188 		  l_inst_hist_rec_tab.new_mfg_serial_number_flag(i),
1189 		  l_inst_hist_rec_tab.old_lot_number(i),
1190 		  l_inst_hist_rec_tab.new_lot_number(i),
1191 		  l_inst_hist_rec_tab.old_unit_of_measure(i),
1192 		  l_inst_hist_rec_tab.new_unit_of_measure(i),
1193 		  l_inst_hist_rec_tab.old_accounting_class_code(i),
1194 		  l_inst_hist_rec_tab.new_accounting_class_code(i),
1195 		  l_inst_hist_rec_tab.old_customer_view_flag(i),
1196 		  l_inst_hist_rec_tab.new_customer_view_flag(i),
1197 		  l_inst_hist_rec_tab.old_merchant_view_flag(i),
1198 		  l_inst_hist_rec_tab.new_merchant_view_flag(i),
1199 		  l_inst_hist_rec_tab.old_sellable_flag(i),
1200 		  l_inst_hist_rec_tab.new_sellable_flag(i),
1201 		  l_inst_hist_rec_tab.old_instance_type_code(i),
1202 		  l_inst_hist_rec_tab.new_instance_type_code(i),
1203 		  l_inst_hist_rec_tab.old_location_type_code(i),
1204 		  l_inst_hist_rec_tab.new_location_type_code(i),
1205 		  l_inst_hist_rec_tab.old_inv_subinventory_name(i),
1206 		  l_inst_hist_rec_tab.new_inv_subinventory_name(i),
1207 		  l_inst_hist_rec_tab.old_completeness_flag(i),
1208 		  l_inst_hist_rec_tab.new_completeness_flag(i),
1209 		  l_inst_hist_rec_tab.old_inst_context(i),
1210 		  l_inst_hist_rec_tab.new_inst_context(i),
1211 		  l_inst_hist_rec_tab.old_inst_attribute1(i),
1212 		  l_inst_hist_rec_tab.new_inst_attribute1(i),
1213 		  l_inst_hist_rec_tab.old_inst_attribute2(i),
1214 		  l_inst_hist_rec_tab.new_inst_attribute2(i),
1215 		  l_inst_hist_rec_tab.old_inst_attribute3(i),
1216 		  l_inst_hist_rec_tab.new_inst_attribute3(i),
1217 		  l_inst_hist_rec_tab.old_inst_attribute4(i),
1218 		  l_inst_hist_rec_tab.new_inst_attribute4(i),
1219 		  l_inst_hist_rec_tab.old_inst_attribute5(i),
1220 		  l_inst_hist_rec_tab.new_inst_attribute5(i),
1221 		  l_inst_hist_rec_tab.old_inst_attribute6(i),
1222 		  l_inst_hist_rec_tab.new_inst_attribute6(i),
1223 		  l_inst_hist_rec_tab.old_inst_attribute7(i),
1224 		  l_inst_hist_rec_tab.new_inst_attribute7(i),
1225 		  l_inst_hist_rec_tab.old_inst_attribute8(i),
1226 		  l_inst_hist_rec_tab.new_inst_attribute8(i),
1227 		  l_inst_hist_rec_tab.old_inst_attribute9(i),
1228 		  l_inst_hist_rec_tab.new_inst_attribute9(i),
1229 		  l_inst_hist_rec_tab.old_inst_attribute10(i),
1230 		  l_inst_hist_rec_tab.new_inst_attribute10(i),
1231 		  l_inst_hist_rec_tab.old_inst_attribute11(i),
1232 		  l_inst_hist_rec_tab.new_inst_attribute11(i),
1233 		  l_inst_hist_rec_tab.old_inst_attribute12(i),
1234 		  l_inst_hist_rec_tab.new_inst_attribute12(i),
1235 		  l_inst_hist_rec_tab.old_inst_attribute13(i),
1236 		  l_inst_hist_rec_tab.new_inst_attribute13(i),
1237 		  l_inst_hist_rec_tab.old_inst_attribute14(i),
1238 		  l_inst_hist_rec_tab.new_inst_attribute14(i),
1239 		  l_inst_hist_rec_tab.old_inst_attribute15(i),
1240 		  l_inst_hist_rec_tab.new_inst_attribute15(i),
1241 		  l_inst_hist_rec_tab.old_install_location_type_code(i),
1242 		  l_inst_hist_rec_tab.new_install_location_type_code(i),
1243 		  l_inst_hist_rec_tab.old_instance_usage_code(i),
1244 		  l_inst_hist_rec_tab.new_instance_usage_code(i),
1245 		  l_inst_hist_rec_tab.old_config_valid_status(i),
1246 		  l_inst_hist_rec_tab.new_config_valid_status(i),
1247 		  l_inst_hist_rec_tab.old_instance_description(i),
1248 		  l_inst_hist_rec_tab.new_instance_description(i),
1249 		  l_inst_hist_rec_tab.inst_full_dump_flag(i),
1250    		  l_inst_hist_rec_tab.inst_migrated_flag(i),
1251        -- Added for eam
1252           l_inst_hist_rec_tab.old_inst_attribute16(i),
1253           l_inst_hist_rec_tab.new_inst_attribute16(i),
1254           l_inst_hist_rec_tab.old_inst_attribute17(i),
1255           l_inst_hist_rec_tab.new_inst_attribute17(i),
1256           l_inst_hist_rec_tab.old_inst_attribute18(i),
1257           l_inst_hist_rec_tab.new_inst_attribute18(i),
1258           l_inst_hist_rec_tab.old_inst_attribute19(i),
1259           l_inst_hist_rec_tab.new_inst_attribute19(i),
1260           l_inst_hist_rec_tab.old_inst_attribute20(i),
1261           l_inst_hist_rec_tab.new_inst_attribute20(i),
1262           l_inst_hist_rec_tab.old_inst_attribute21(i),
1263           l_inst_hist_rec_tab.new_inst_attribute21(i),
1264           l_inst_hist_rec_tab.old_inst_attribute22(i),
1265           l_inst_hist_rec_tab.new_inst_attribute22(i),
1266           l_inst_hist_rec_tab.old_inst_attribute23(i),
1267           l_inst_hist_rec_tab.new_inst_attribute23(i),
1268           l_inst_hist_rec_tab.old_inst_attribute24(i),
1269           l_inst_hist_rec_tab.new_inst_attribute24(i),
1270           l_inst_hist_rec_tab.old_inst_attribute25(i),
1271           l_inst_hist_rec_tab.new_inst_attribute25(i),
1272           l_inst_hist_rec_tab.old_inst_attribute26(i),
1273           l_inst_hist_rec_tab.new_inst_attribute26(i),
1274           l_inst_hist_rec_tab.old_inst_attribute27(i),
1275           l_inst_hist_rec_tab.new_inst_attribute27(i),
1276           l_inst_hist_rec_tab.old_inst_attribute28(i),
1277           l_inst_hist_rec_tab.new_inst_attribute28(i),
1278           l_inst_hist_rec_tab.old_inst_attribute29(i),
1282 
1279           l_inst_hist_rec_tab.new_inst_attribute29(i),
1280           l_inst_hist_rec_tab.old_inst_attribute30(i),
1281           l_inst_hist_rec_tab.new_inst_attribute30(i),
1283           l_inst_hist_rec_tab.old_network_asset_flag(i),
1284           l_inst_hist_rec_tab.new_network_asset_flag(i),
1285           l_inst_hist_rec_tab.old_maintainable_flag(i),
1286           l_inst_hist_rec_tab.new_maintainable_flag(i),
1287           l_inst_hist_rec_tab.old_asset_criticality_code(i),
1288           l_inst_hist_rec_tab.new_asset_criticality_code(i),
1289           l_inst_hist_rec_tab.old_instantiation_flag(i),
1290           l_inst_hist_rec_tab.new_instantiation_flag(i),
1291           l_inst_hist_rec_tab.old_operational_log_flag(i),
1292           l_inst_hist_rec_tab.new_operational_log_flag(i),
1293 
1294        -- End addition for eam
1295 		  l_inst_hist_rec_tab.old_active_start_date(i),
1296 		  l_inst_hist_rec_tab.new_active_start_date(i),
1297 		  l_inst_hist_rec_tab.old_active_end_date(i),
1298 		  l_inst_hist_rec_tab.new_active_end_date(i),
1299           l_inst_hist_rec_tab.old_install_date(i),
1300           l_inst_hist_rec_tab.new_install_date(i),
1301           l_inst_hist_rec_tab.old_return_by_date(i),
1302           l_inst_hist_rec_tab.new_return_by_date(i),
1303           l_inst_hist_rec_tab.old_actual_return_date(i),
1304           l_inst_hist_rec_tab.new_actual_return_date(i),
1305    		  l_inst_hist_rec_tab.inst_creation_date(i),
1306    		  l_inst_hist_rec_tab.inst_last_update_date(i),
1307           -- Added for eam
1308           l_inst_hist_rec_tab.old_supplier_warranty_exp_date(i),
1309           l_inst_hist_rec_tab.new_supplier_warranty_exp_date(i),
1310           -- End addition for eam
1311           null,
1312           null,
1313           null,
1314           null,
1315           null,
1316           null,
1317           null,
1318           null,
1319           null,
1320           null,
1321           null,
1322           null,
1323           null,
1324           null,
1325           null,
1326           null,
1327           l_user_id,
1328           sysdate,
1329           l_user_id,
1330           sysdate,
1331           l_login_id,
1332           1,
1333           null
1334          );
1335 
1336       -- Purge the corresonding Archive data from the Instance history tables
1337 
1338       FORALL i IN 1 .. l_cnt
1339 
1340          Delete From CSI_ITEM_INSTANCES_H
1341          Where instance_history_id = l_inst_hist_rec_tab.instance_history_id(i);
1342 
1343       -- Update csi_item instances table with the last transaction history purged date
1344 
1345       FORALL i IN 1 .. l_cnt
1346 
1347          Update CSI_ITEM_INSTANCES
1348          Set last_purge_date = to_date(purge_to_date,'YYYY/MM/DD HH24:MI:SS')
1349          Where instance_id = l_inst_hist_rec_tab.instance_id(i);
1350 
1351    End If; -- if l_cnt > 0
1352    --
1353    Exit When from_trans = to_trans;
1354    Exit When v_end = to_trans;
1355    --
1356   v_start := v_end + 1;
1357   v_end   := v_start + v_batch;
1358   --
1359  If v_start > to_trans Then
1360     v_start := to_trans;
1361  End If;
1362  --
1363  If v_end > to_trans then
1364     v_end := to_trans;
1365  End If;
1366  --
1367  Commit;
1368  --
1369  Exception
1370   When Others Then
1371    Debug(substr(sqlerrm,1,255));
1372    Rollback to Instance_Archive;
1373  End;
1374 End Loop; -- Local Batch Loop
1375 Commit;
1376 --
1377 END; -- End of Procedure Instance_Archive
1378 --
1379 --
1380 --
1381 --
1382 -- This program is used to archive the Instance Party history. It accepts from  transactions
1383 -- as the input parameters.
1384 --
1385 
1386 PROCEDURE party_archive( errbuf       OUT NOCOPY VARCHAR2,
1387                          retcode      OUT NOCOPY NUMBER,
1388                          from_trans   IN  NUMBER,
1389                          to_trans     IN  NUMBER,
1390                          purge_to_date IN VARCHAR2 )
1391 IS
1392 
1393     l_archive_id      NUMBER;
1394     l_ctr             NUMBER := 0;
1395     l_cnt             NUMBER;
1396     l_table_id        NUMBER;
1397     l_user_id         NUMBER := FND_GLOBAL.USER_ID;
1398     l_login_id        NUMBER := FND_GLOBAL.CONC_LOGIN_ID;
1399     v_batch           NUMBER := 15000;
1400     v_start           NUMBER;
1401     v_end             NUMBER;
1402 
1403     Type NumList IS Table Of Number Index By Binary_Integer;
1404     l_archive_id_tbl   NUMLIST;
1405 
1406     Cursor pty_hist_csr (p_from_trans IN NUMBER,
1407                          p_to_trans   IN NUMBER) IS
1408     Select csh.*
1409     From   CSI_I_PARTIES_H csh,
1410            CSI_TRANSACTIONS csit
1411     Where  csit.transaction_id between from_trans and to_trans
1412     And    csit.creation_date < to_date(purge_to_date, 'YYYY/MM/DD HH24:MI:SS')
1413     And    csh.transaction_id = csit.transaction_id;
1414 
1415     l_pty_hist_csr          pty_hist_csr%RowType;
1416     l_pty_hist_rec_tab      csi_txn_history_purge_pvt.party_history_rec_tab;
1417 
1418 
1419 Begin
1420     --
1421     --
1422     Begin
1423       Select object_id
1424       Into   l_table_id
1425       From   csi_object_dictionary
1426       Where  object_name = 'CSI_I_PARTIES_H';
1427     Exception
1428       When no_data_found Then
1429         l_table_id := 2;
1430       When others Then
1431         l_table_id := 2;
1432     End;
1433     --
1434     Begin
1435       Select fnd_profile.value('CSI_TXN_HISTORY_PURGE_BATCH_SIZE')
1436       Into   v_batch
1440         v_batch := 15000;
1437       From   dual;
1438     Exception
1439       When no_data_found Then
1441     End;
1442     --
1443     v_start := from_trans;
1444     v_end   := from_trans + v_batch;
1445     --
1446     If v_end > to_trans Then
1447        v_end := to_trans;
1448     End If;
1449     --
1450  Loop
1451    Begin
1452       SAVEPOINT Party_Archive;
1453       l_ctr := 0;
1454       --
1455       l_pty_hist_rec_tab.instance_party_history_id.DELETE;
1456       l_pty_hist_rec_tab.instance_party_id.DELETE;
1457       l_pty_hist_rec_tab.transaction_id.DELETE;
1458       l_pty_hist_rec_tab.old_party_source_table.DELETE;
1459       l_pty_hist_rec_tab.new_party_source_table.DELETE;
1460       l_pty_hist_rec_tab.old_party_id.DELETE;
1461       l_pty_hist_rec_tab.new_party_id.DELETE;
1462       l_pty_hist_rec_tab.old_relationship_type_code.DELETE;
1463       l_pty_hist_rec_tab.new_relationship_type_code.DELETE;
1464       l_pty_hist_rec_tab.old_contact_flag.DELETE;
1465       l_pty_hist_rec_tab.new_contact_flag.DELETE;
1466       l_pty_hist_rec_tab.old_contact_ip_id.DELETE;
1467       l_pty_hist_rec_tab.new_contact_ip_id.DELETE;
1468       l_pty_hist_rec_tab.old_active_start_date.DELETE;
1469       l_pty_hist_rec_tab.new_active_start_date.DELETE;
1470       l_pty_hist_rec_tab.old_active_end_date.DELETE;
1471       l_pty_hist_rec_tab.new_active_end_date.DELETE;
1472       l_pty_hist_rec_tab.old_context.DELETE;
1473       l_pty_hist_rec_tab.new_context.DELETE;
1474       l_pty_hist_rec_tab.old_attribute1.DELETE;
1475       l_pty_hist_rec_tab.new_attribute1.DELETE;
1476       l_pty_hist_rec_tab.old_attribute2.DELETE;
1477       l_pty_hist_rec_tab.new_attribute2.DELETE;
1478       l_pty_hist_rec_tab.old_attribute3.DELETE;
1479       l_pty_hist_rec_tab.new_attribute3.DELETE;
1480       l_pty_hist_rec_tab.old_attribute4.DELETE;
1481       l_pty_hist_rec_tab.new_attribute4.DELETE;
1482       l_pty_hist_rec_tab.old_attribute5.DELETE;
1483       l_pty_hist_rec_tab.new_attribute5.DELETE;
1484       l_pty_hist_rec_tab.old_attribute6.DELETE;
1485       l_pty_hist_rec_tab.new_attribute6.DELETE;
1486       l_pty_hist_rec_tab.old_attribute7.DELETE;
1487       l_pty_hist_rec_tab.new_attribute7.DELETE;
1488       l_pty_hist_rec_tab.old_attribute8.DELETE;
1489       l_pty_hist_rec_tab.new_attribute8.DELETE;
1490       l_pty_hist_rec_tab.old_attribute9.DELETE;
1491       l_pty_hist_rec_tab.new_attribute9.DELETE;
1492       l_pty_hist_rec_tab.old_attribute10.DELETE;
1493       l_pty_hist_rec_tab.new_attribute10.DELETE;
1494       l_pty_hist_rec_tab.old_attribute11.DELETE;
1495       l_pty_hist_rec_tab.new_attribute11.DELETE;
1496       l_pty_hist_rec_tab.old_attribute12.DELETE;
1497       l_pty_hist_rec_tab.new_attribute12.DELETE;
1498       l_pty_hist_rec_tab.old_attribute13.DELETE;
1499       l_pty_hist_rec_tab.new_attribute13.DELETE;
1500       l_pty_hist_rec_tab.old_attribute14.DELETE;
1501       l_pty_hist_rec_tab.new_attribute14.DELETE;
1502       l_pty_hist_rec_tab.old_attribute15.DELETE;
1503       l_pty_hist_rec_tab.new_attribute15.DELETE;
1504       l_pty_hist_rec_tab.old_preferred_flag.DELETE;
1505       l_pty_hist_rec_tab.new_preferred_flag.DELETE;
1506       l_pty_hist_rec_tab.old_primary_flag.DELETE;
1507       l_pty_hist_rec_tab.new_primary_flag.DELETE;
1508       l_pty_hist_rec_tab.pty_full_dump_flag.DELETE;
1509       l_pty_hist_rec_tab.pty_created_by.DELETE;
1510       l_pty_hist_rec_tab.pty_creation_date.DELETE;
1511       l_pty_hist_rec_tab.pty_last_updated_by.DELETE;
1512       l_pty_hist_rec_tab.pty_last_update_date.DELETE;
1513       l_pty_hist_rec_tab.pty_last_update_login.DELETE;
1514       l_pty_hist_rec_tab.pty_object_version_number.DELETE;
1515       l_pty_hist_rec_tab.pty_security_group_id.DELETE;
1516       l_pty_hist_rec_tab.pty_migrated_flag.DELETE;
1517       --
1518 
1519   For i in pty_hist_csr(v_start,v_end)
1520   Loop
1521       --
1522       l_ctr := l_ctr + 1;
1523       --
1524       Select csi_history_archive_s.Nextval
1525       Into l_archive_id_tbl(l_ctr)
1526       From dual;
1527       --
1528       l_pty_hist_rec_tab.instance_party_history_id(l_ctr)  :=  i.instance_party_history_id;
1529       l_pty_hist_rec_tab.transaction_id(l_ctr)             :=  i.transaction_id;
1530       l_pty_hist_rec_tab.instance_party_id(l_ctr)          :=  i.instance_party_id;
1531       l_pty_hist_rec_tab.old_party_source_table(l_ctr)     :=  i.old_party_source_table;
1532       l_pty_hist_rec_tab.new_party_source_table(l_ctr)     :=  i.new_party_source_table;
1533       l_pty_hist_rec_tab.old_party_id(l_ctr)               :=  i.old_party_id;
1534       l_pty_hist_rec_tab.new_party_id(l_ctr)               :=  i.new_party_id;
1535       l_pty_hist_rec_tab.old_relationship_type_code(l_ctr) :=  i.old_relationship_type_code;
1536       l_pty_hist_rec_tab.new_relationship_type_code(l_ctr) :=  i.new_relationship_type_code;
1537       l_pty_hist_rec_tab.old_contact_flag(l_ctr)           :=  i.old_contact_flag;
1538       l_pty_hist_rec_tab.new_contact_flag(l_ctr)           :=  i.new_contact_flag;
1539       l_pty_hist_rec_tab.old_contact_ip_id(l_ctr)          :=  i.old_contact_ip_id;
1540       l_pty_hist_rec_tab.new_contact_ip_id(l_ctr)          :=  i.new_contact_ip_id;
1541       l_pty_hist_rec_tab.old_active_start_date(l_ctr)      :=  i.old_active_start_date;
1542       l_pty_hist_rec_tab.new_active_start_date(l_ctr)      :=  i.new_active_start_date;
1543       l_pty_hist_rec_tab.old_active_end_date(l_ctr)        :=  i.old_active_end_date;
1544       l_pty_hist_rec_tab.new_active_end_date(l_ctr)        :=  i.new_active_end_date;
1545       l_pty_hist_rec_tab.old_context(l_ctr)	               :=  i.old_context;
1546       l_pty_hist_rec_tab.new_context(l_ctr)	               :=  i.new_context;
1547       l_pty_hist_rec_tab.old_attribute1(l_ctr)	           :=  i.old_attribute1;
1551       l_pty_hist_rec_tab.old_attribute3(l_ctr)	           :=  i.old_attribute3;
1548       l_pty_hist_rec_tab.new_attribute1(l_ctr)	           :=  i.new_attribute1;
1549       l_pty_hist_rec_tab.old_attribute2(l_ctr)	           :=  i.old_attribute2;
1550       l_pty_hist_rec_tab.new_attribute2(l_ctr)	           :=  i.new_attribute2;
1552       l_pty_hist_rec_tab.new_attribute3(l_ctr)	           :=  i.new_attribute3;
1553       l_pty_hist_rec_tab.old_attribute4(l_ctr)	           :=  i.old_attribute4;
1554       l_pty_hist_rec_tab.new_attribute4(l_ctr)	           :=  i.new_attribute4;
1555       l_pty_hist_rec_tab.old_attribute5(l_ctr)	           :=  i.old_attribute5;
1556       l_pty_hist_rec_tab.new_attribute5(l_ctr)	           :=  i.new_attribute5;
1557       l_pty_hist_rec_tab.old_attribute6(l_ctr)	           :=  i.old_attribute6;
1558       l_pty_hist_rec_tab.new_attribute6(l_ctr)	           :=  i.new_attribute6;
1559       l_pty_hist_rec_tab.old_attribute7(l_ctr)	           :=  i.old_attribute7;
1560       l_pty_hist_rec_tab.new_attribute7(l_ctr)	           :=  i.new_attribute7;
1561       l_pty_hist_rec_tab.old_attribute8(l_ctr)	           :=  i.old_attribute8;
1562       l_pty_hist_rec_tab.new_attribute8(l_ctr)	           :=  i.new_attribute8;
1563       l_pty_hist_rec_tab.old_attribute9(l_ctr)	           :=  i.old_attribute9;
1564       l_pty_hist_rec_tab.new_attribute9(l_ctr)	           :=  i.new_attribute9;
1565       l_pty_hist_rec_tab.old_attribute10(l_ctr)	           :=  i.old_attribute10;
1566       l_pty_hist_rec_tab.new_attribute10(l_ctr)	           :=  i.new_attribute10;
1567       l_pty_hist_rec_tab.old_attribute11(l_ctr)      	   :=  i.old_attribute11;
1568       l_pty_hist_rec_tab.new_attribute11(l_ctr)	           :=  i.new_attribute11;
1569       l_pty_hist_rec_tab.old_attribute12(l_ctr)	           :=  i.old_attribute12;
1570       l_pty_hist_rec_tab.new_attribute12(l_ctr)	           :=  i.new_attribute12;
1571       l_pty_hist_rec_tab.old_attribute13(l_ctr)	           :=  i.old_attribute13;
1572       l_pty_hist_rec_tab.new_attribute13(l_ctr)	           :=  i.new_attribute13;
1573       l_pty_hist_rec_tab.old_attribute14(l_ctr)	           :=  i.old_attribute14;
1574       l_pty_hist_rec_tab.new_attribute14(l_ctr)	           :=  i.new_attribute14;
1575       l_pty_hist_rec_tab.old_attribute15(l_ctr)	           :=  i.old_attribute15;
1576       l_pty_hist_rec_tab.new_attribute15(l_ctr)	           :=  i.new_attribute15;
1577       l_pty_hist_rec_tab.old_preferred_flag(l_ctr)	       :=  i.old_preferred_flag;
1578       l_pty_hist_rec_tab.new_preferred_flag(l_ctr)	       :=  i.new_preferred_flag;
1579       l_pty_hist_rec_tab.old_primary_flag(l_ctr)	       :=  i.old_primary_flag;
1580       l_pty_hist_rec_tab.new_primary_flag(l_ctr)	       :=  i.new_primary_flag;
1581       l_pty_hist_rec_tab.pty_full_dump_flag(l_ctr)         :=  i.full_dump_flag;
1582       l_pty_hist_rec_tab.pty_created_by(l_ctr)             :=  i.created_by;
1583       l_pty_hist_rec_tab.pty_creation_date(l_ctr)          :=  i.creation_date;
1584       l_pty_hist_rec_tab.pty_last_updated_by(l_ctr)        :=  i.last_updated_by;
1585       l_pty_hist_rec_tab.pty_last_update_date(l_ctr)       :=  i.last_update_date;
1586       l_pty_hist_rec_tab.pty_last_update_login(l_ctr)      :=  i.last_update_login;
1587       l_pty_hist_rec_tab.pty_object_version_number(l_ctr)  :=  i.object_version_number;
1588       l_pty_hist_rec_tab.pty_security_group_id(l_ctr)      :=  i.security_group_id;
1589       l_pty_hist_rec_tab.pty_migrated_flag(l_ctr)          :=  i.migrated_flag;
1590 
1591    End Loop;
1592 
1593       -- get the party history count for the transaction range
1594       l_cnt := l_pty_hist_rec_tab.instance_party_history_id.count;
1595       --
1596       Debug('');
1597       Debug('');
1598       Debug('Number of Instance Party history records archived:'||to_char(l_cnt));
1599       Debug('');
1600       Debug('');
1601       --
1602       If l_cnt > 0 Then
1603 
1604         FORALL i IN 1 .. l_cnt
1605 
1606          Insert Into CSI_HISTORY_ARCHIVE
1607          (
1608             HISTORY_ARCHIVE_ID
1609            ,OBJECT_ID
1610            ,ENTITY_HISTORY_ID
1611            ,TRANSACTION_ID
1612            ,ENTITY_ID
1613            ,COL_NUM_01
1614            ,COL_NUM_02
1615            ,COL_NUM_03
1616            ,COL_NUM_04
1617            ,COL_NUM_37
1618            ,COL_NUM_38
1619            ,COL_NUM_39
1620            ,COL_NUM_40
1621            ,COL_NUM_41
1622            ,COL_CHAR_01
1623            ,COL_CHAR_02
1624            ,COL_CHAR_03
1625            ,COL_CHAR_04
1626            ,COL_CHAR_05
1627            ,COL_CHAR_06
1628            ,COL_CHAR_07
1629            ,COL_CHAR_08
1630            ,COL_CHAR_09
1631            ,COL_CHAR_10
1632            ,COL_CHAR_31
1633            ,COL_CHAR_32
1634            ,COL_CHAR_33
1635            ,COL_CHAR_34
1636            ,COL_CHAR_35
1637            ,COL_CHAR_36
1638            ,COL_CHAR_37
1639            ,COL_CHAR_38
1640            ,COL_CHAR_39
1641            ,COL_CHAR_40
1642            ,COL_CHAR_41
1643            ,COL_CHAR_42
1644            ,COL_CHAR_43
1645            ,COL_CHAR_44
1646            ,COL_CHAR_45
1647            ,COL_CHAR_46
1648            ,COL_CHAR_47
1649            ,COL_CHAR_48
1650            ,COL_CHAR_49
1651            ,COL_CHAR_50
1652            ,COL_CHAR_51
1653            ,COL_CHAR_52
1654            ,COL_CHAR_53
1655            ,COL_CHAR_54
1656            ,COL_CHAR_55
1657            ,COL_CHAR_56
1658            ,COL_CHAR_57
1659            ,COL_CHAR_58
1660            ,COL_CHAR_59
1661            ,COL_CHAR_60
1662            ,COL_CHAR_61
1663            ,COL_CHAR_62
1664            ,COL_CHAR_71
1665            ,COL_CHAR_72
1666            ,COL_DATE_01
1667            ,COL_DATE_02
1668            ,COL_DATE_03
1669            ,COL_DATE_04
1670            ,COL_DATE_11
1671            ,COL_DATE_12
1672            ,CONTEXT
1673            ,ATTRIBUTE1
1674            ,ATTRIBUTE2
1675            ,ATTRIBUTE3
1676            ,ATTRIBUTE4
1677            ,ATTRIBUTE5
1678            ,ATTRIBUTE6
1679            ,ATTRIBUTE7
1680            ,ATTRIBUTE8
1681            ,ATTRIBUTE9
1682            ,ATTRIBUTE10
1683            ,ATTRIBUTE11
1684            ,ATTRIBUTE12
1685            ,ATTRIBUTE13
1686            ,ATTRIBUTE14
1687            ,ATTRIBUTE15
1688            ,CREATED_BY
1689            ,CREATION_DATE
1690            ,LAST_UPDATED_BY
1691            ,LAST_UPDATE_DATE
1692            ,LAST_UPDATE_LOGIN
1693            ,OBJECT_VERSION_NUMBER
1694            ,SECURITY_GROUP_ID
1695            )
1696            Values
1697            (
1698            l_archive_id_tbl(i),
1699            l_table_id,
1700            l_pty_hist_rec_tab.instance_party_history_id(i),
1701            l_pty_hist_rec_tab.transaction_id(i),
1702            l_pty_hist_rec_tab.instance_party_id(i),
1703            l_pty_hist_rec_tab.old_party_id(i),
1704            l_pty_hist_rec_tab.new_party_id(i),
1705            l_pty_hist_rec_tab.old_contact_ip_id(i),
1706            l_pty_hist_rec_tab.new_contact_ip_id(i),
1707            l_pty_hist_rec_tab.pty_created_by(i),
1708            l_pty_hist_rec_tab.pty_last_updated_by(i),
1709            l_pty_hist_rec_tab.pty_last_update_login(i),
1710            l_pty_hist_rec_tab.pty_object_version_number(i),
1711            l_pty_hist_rec_tab.pty_security_group_id(i),
1712            l_pty_hist_rec_tab.old_party_source_table(i),
1713            l_pty_hist_rec_tab.new_party_source_table(i),
1714            l_pty_hist_rec_tab.old_relationship_type_code(i),
1715            l_pty_hist_rec_tab.new_relationship_type_code(i),
1716            l_pty_hist_rec_tab.old_contact_flag(i),
1717            l_pty_hist_rec_tab.new_contact_flag(i),
1718            l_pty_hist_rec_tab.old_preferred_flag(i),
1719            l_pty_hist_rec_tab.new_preferred_flag(i),
1720            l_pty_hist_rec_tab.old_primary_flag(i),
1721            l_pty_hist_rec_tab.new_primary_flag(i),
1722            l_pty_hist_rec_tab.old_context(i),
1723            l_pty_hist_rec_tab.new_context(i),
1724            l_pty_hist_rec_tab.old_attribute1(i),
1725            l_pty_hist_rec_tab.new_attribute1(i),
1726            l_pty_hist_rec_tab.old_attribute2(i),
1727            l_pty_hist_rec_tab.new_attribute2(i),
1728            l_pty_hist_rec_tab.old_attribute3(i),
1729            l_pty_hist_rec_tab.new_attribute3(i),
1730            l_pty_hist_rec_tab.old_attribute4(i),
1731            l_pty_hist_rec_tab.new_attribute4(i),
1732            l_pty_hist_rec_tab.old_attribute5(i),
1733            l_pty_hist_rec_tab.new_attribute5(i),
1734            l_pty_hist_rec_tab.old_attribute6(i),
1735            l_pty_hist_rec_tab.new_attribute6(i),
1736            l_pty_hist_rec_tab.old_attribute7(i),
1737            l_pty_hist_rec_tab.new_attribute7(i),
1738            l_pty_hist_rec_tab.old_attribute8(i),
1739            l_pty_hist_rec_tab.new_attribute8(i),
1740            l_pty_hist_rec_tab.old_attribute9(i),
1741            l_pty_hist_rec_tab.new_attribute9(i),
1742            l_pty_hist_rec_tab.old_attribute10(i),
1743            l_pty_hist_rec_tab.new_attribute10(i),
1744            l_pty_hist_rec_tab.old_attribute11(i),
1745            l_pty_hist_rec_tab.new_attribute11(i),
1746            l_pty_hist_rec_tab.old_attribute12(i),
1747            l_pty_hist_rec_tab.new_attribute12(i),
1748            l_pty_hist_rec_tab.old_attribute13(i),
1749            l_pty_hist_rec_tab.new_attribute13(i),
1750            l_pty_hist_rec_tab.old_attribute14(i),
1751            l_pty_hist_rec_tab.new_attribute14(i),
1752            l_pty_hist_rec_tab.old_attribute15(i),
1753            l_pty_hist_rec_tab.new_attribute15(i),
1754            l_pty_hist_rec_tab.pty_full_dump_flag(i),
1755            l_pty_hist_rec_tab.pty_migrated_flag(i),
1759            l_pty_hist_rec_tab.new_active_end_date(i),
1756            l_pty_hist_rec_tab.old_active_start_date(i),
1757            l_pty_hist_rec_tab.new_active_start_date(i),
1758            l_pty_hist_rec_tab.old_active_end_date(i),
1760            l_pty_hist_rec_tab.pty_creation_date(i),
1761            l_pty_hist_rec_tab.pty_last_update_date(i),
1762            null,
1763            null,
1764            null,
1765            null,
1766            null,
1767            null,
1768            null,
1769            null,
1770            null,
1771            null,
1772            null,
1773            null,
1774            null,
1775            null,
1776            null,
1777            null,
1778            l_user_id,
1779            sysdate,
1780            l_user_id,
1781            sysdate,
1782            l_login_id,
1783            1,
1784            null
1785            );
1786 
1787       -- Purge the corresonding Archive data from the Instance history tables
1788 
1789          FORALL i IN 1 .. l_cnt
1790 
1791           Delete From CSI_I_PARTIES_H
1792           Where instance_party_history_id = l_pty_hist_rec_tab.instance_party_history_id(i);
1793 
1794       End If; -- if l_cnt > 0
1795       --
1796       Exit When from_trans = to_trans;
1797       Exit When v_end = to_trans;
1798 
1799      v_start := v_end + 1;
1800      v_end   := v_start + v_batch;
1801      --
1802      --
1803 	 If v_start > to_trans Then
1804 	    v_start := to_trans;
1805 	 End If;
1806 	 --
1807 	 If v_end > to_trans then
1808 	    v_end := to_trans;
1809 	 End If;
1810      --
1811      Commit;
1812      --
1813    Exception
1814       when others then
1815          DEBUG(substr(sqlerrm,1,255));
1816          ROLLBACK to Party_Archive;
1817    End;
1818  End Loop; -- Local Batch Loop
1819  Commit;
1820    --
1821 END; -- Procedure Instance_Party_Archive
1822 
1823 
1824 --
1825 -- This program is used to archive the Instance Party history. It accepts from  transactions
1826 -- as the input parameters.
1827 --
1828 
1829 PROCEDURE Account_archive( errbuf       OUT NOCOPY VARCHAR2,
1830                            retcode      OUT NOCOPY NUMBER,
1831                            from_trans   IN  NUMBER,
1832                            to_trans     IN  NUMBER,
1833                            purge_to_date IN VARCHAR2 )
1834 IS
1835 
1836     l_archive_id      NUMBER;
1837     l_ctr             NUMBER := 0;
1838     l_cnt             NUMBER;
1839     l_table_id        NUMBER;
1840     l_user_id         NUMBER := FND_GLOBAL.USER_ID;
1841     l_login_id        NUMBER := FND_GLOBAL.CONC_LOGIN_ID;
1842     v_batch           NUMBER := 15000;
1843     v_start           NUMBER;
1844     v_end             NUMBER;
1845 
1846     Type NUMLIST IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
1847     l_archive_id_tbl   NUMLIST;
1848 
1849     Cursor acct_hist_csr (p_from_trans IN NUMBER,
1850                           p_to_trans   IN NUMBER) IS
1851     Select csh.*
1852     From   CSI_IP_ACCOUNTS_H csh,
1853            CSI_TRANSACTIONS csit
1854     Where  csit.transaction_id between from_trans and to_trans
1855     And    csit.creation_date < to_date(purge_to_date, 'YYYY/MM/DD HH24:MI:SS')
1856     And    csh.transaction_id = csit.transaction_id;
1857 
1858     l_acct_hist_csr         acct_hist_csr%RowType;
1859     l_acct_hist_rec_tab     csi_txn_history_purge_pvt.account_history_rec_tab;
1860 
1861 
1862 Begin
1863     --
1864     --
1865     Begin
1866       Select object_id
1867       Into   l_table_id
1868       From   csi_object_dictionary
1869       Where  object_name = 'CSI_IP_ACCOUNTS_H';
1870     Exception
1871       When no_data_found Then
1872         l_table_id := 3;
1873       When others Then
1874         l_table_id := 3;
1875     End;
1876     --
1877     --
1878     Begin
1879       Select fnd_profile.value('CSI_TXN_HISTORY_PURGE_BATCH_SIZE')
1880       Into   v_batch
1881       From   dual;
1882     Exception
1883       When no_data_found Then
1884         v_batch := 15000;
1885     End;
1886     --
1887     v_start := from_trans;
1888     v_end   := from_trans + v_batch;
1889     --
1890     If v_end > to_trans Then
1891        v_end := to_trans;
1892     End If;
1893     --
1894  Loop
1895     Begin
1896       SAVEPOINT Account_Archive;
1897       l_ctr := 0;
1898       --
1899       l_acct_hist_rec_tab.ip_account_history_id.DELETE;
1900       l_acct_hist_rec_tab.ip_account_id.DELETE;
1901       l_acct_hist_rec_tab.transaction_id.DELETE;
1902       l_acct_hist_rec_tab.old_party_account_id.DELETE;
1903       l_acct_hist_rec_tab.new_party_account_id.DELETE;
1904       l_acct_hist_rec_tab.old_relationship_type_code.DELETE;
1905       l_acct_hist_rec_tab.new_relationship_type_code.DELETE;
1906       l_acct_hist_rec_tab.old_bill_to_address.DELETE;
1907       l_acct_hist_rec_tab.new_bill_to_address.DELETE;
1908       l_acct_hist_rec_tab.old_ship_to_address.DELETE;
1909       l_acct_hist_rec_tab.new_ship_to_address.DELETE;
1910       l_acct_hist_rec_tab.old_active_start_date.DELETE;
1911       l_acct_hist_rec_tab.new_active_start_date.DELETE;
1912       l_acct_hist_rec_tab.old_active_end_date.DELETE;
1913       l_acct_hist_rec_tab.new_active_end_date.DELETE;
1914       l_acct_hist_rec_tab.old_context.DELETE;
1915       l_acct_hist_rec_tab.new_context.DELETE;
1916       l_acct_hist_rec_tab.old_attribute1.DELETE;
1917       l_acct_hist_rec_tab.new_attribute1.DELETE;
1921       l_acct_hist_rec_tab.new_attribute3.DELETE;
1918       l_acct_hist_rec_tab.old_attribute2.DELETE;
1919       l_acct_hist_rec_tab.new_attribute2.DELETE;
1920       l_acct_hist_rec_tab.old_attribute3.DELETE;
1922       l_acct_hist_rec_tab.old_attribute4.DELETE;
1923       l_acct_hist_rec_tab.new_attribute4.DELETE;
1924       l_acct_hist_rec_tab.old_attribute5.DELETE;
1925       l_acct_hist_rec_tab.new_attribute5.DELETE;
1926       l_acct_hist_rec_tab.old_attribute6.DELETE;
1927       l_acct_hist_rec_tab.new_attribute6.DELETE;
1928       l_acct_hist_rec_tab.old_attribute7.DELETE;
1929       l_acct_hist_rec_tab.new_attribute7.DELETE;
1930       l_acct_hist_rec_tab.old_attribute8.DELETE;
1931       l_acct_hist_rec_tab.new_attribute8.DELETE;
1932       l_acct_hist_rec_tab.old_attribute9.DELETE;
1933       l_acct_hist_rec_tab.new_attribute9.DELETE;
1934       l_acct_hist_rec_tab.old_attribute10.DELETE;
1935       l_acct_hist_rec_tab.new_attribute10.DELETE;
1936       l_acct_hist_rec_tab.old_attribute11.DELETE;
1937       l_acct_hist_rec_tab.new_attribute11.DELETE;
1938       l_acct_hist_rec_tab.old_attribute12.DELETE;
1939       l_acct_hist_rec_tab.new_attribute12.DELETE;
1940       l_acct_hist_rec_tab.old_attribute13.DELETE;
1941       l_acct_hist_rec_tab.new_attribute13.DELETE;
1942       l_acct_hist_rec_tab.old_attribute14.DELETE;
1943       l_acct_hist_rec_tab.new_attribute14.DELETE;
1944       l_acct_hist_rec_tab.old_attribute15.DELETE;
1945       l_acct_hist_rec_tab.new_attribute15.DELETE;
1946       l_acct_hist_rec_tab.acct_full_dump_flag.DELETE;
1947       l_acct_hist_rec_tab.acct_created_by.DELETE;
1948       l_acct_hist_rec_tab.acct_creation_date.DELETE;
1949       l_acct_hist_rec_tab.acct_last_updated_by.DELETE;
1950       l_acct_hist_rec_tab.acct_last_update_date.DELETE;
1951       l_acct_hist_rec_tab.acct_last_update_login.DELETE;
1952       l_acct_hist_rec_tab.acct_object_version_number.DELETE;
1953       l_acct_hist_rec_tab.acct_security_group_id.DELETE;
1954       l_acct_hist_rec_tab.acct_migrated_flag.DELETE;
1955       l_acct_hist_rec_tab.old_instance_party_id.DELETE;
1956       l_acct_hist_rec_tab.new_instance_party_id.DELETE;
1957       --
1958 
1959   For i in acct_hist_csr(v_start,v_end)
1960   Loop
1961       --
1962       l_ctr := l_ctr + 1;
1963       --
1964       Select csi_history_archive_s.Nextval
1965       Into l_archive_id_tbl(l_ctr)
1966       From dual;
1967       --
1968       l_acct_hist_rec_tab.ip_account_history_id(l_ctr)      :=  i.ip_account_history_id;
1969       l_acct_hist_rec_tab.ip_account_id(l_ctr)              :=  i.ip_account_id;
1970       l_acct_hist_rec_tab.transaction_id(l_ctr)             :=  i.transaction_id;
1971       l_acct_hist_rec_tab.old_party_account_id(l_ctr)       :=  i.old_party_account_id;
1972       l_acct_hist_rec_tab.new_party_account_id(l_ctr)       :=  i.new_party_account_id;
1973       l_acct_hist_rec_tab.old_relationship_type_code(l_ctr) :=  i.old_relationship_type_code;
1974       l_acct_hist_rec_tab.new_relationship_type_code(l_ctr) :=  i.new_relationship_type_code;
1975       l_acct_hist_rec_tab.old_bill_to_address(l_ctr)        :=  i.old_bill_to_address;
1976       l_acct_hist_rec_tab.new_bill_to_address(l_ctr)        :=  i.new_bill_to_address;
1977       l_acct_hist_rec_tab.old_ship_to_address(l_ctr)        :=  i.old_ship_to_address;
1978       l_acct_hist_rec_tab.new_ship_to_address(l_ctr)        :=  i.new_ship_to_address;
1979       l_acct_hist_rec_tab.old_active_start_date(l_ctr)      :=  i.old_active_start_date;
1980       l_acct_hist_rec_tab.new_active_start_date(l_ctr)      :=  i.new_active_start_date;
1981       l_acct_hist_rec_tab.old_active_end_date(l_ctr)        :=  i.old_active_end_date;
1982       l_acct_hist_rec_tab.new_active_end_date(l_ctr)        :=  i.new_active_end_date;
1983       l_acct_hist_rec_tab.old_context(l_ctr)	            :=  i.old_context;
1984       l_acct_hist_rec_tab.new_context(l_ctr)	            :=  i.new_context;
1985       l_acct_hist_rec_tab.old_attribute1(l_ctr)	            :=  i.old_attribute1;
1986       l_acct_hist_rec_tab.new_attribute1(l_ctr)	            :=  i.new_attribute1;
1987       l_acct_hist_rec_tab.old_attribute2(l_ctr)	            :=  i.old_attribute2;
1988       l_acct_hist_rec_tab.new_attribute2(l_ctr)	            :=  i.new_attribute2;
1989       l_acct_hist_rec_tab.old_attribute3(l_ctr)	            :=  i.old_attribute3;
1990       l_acct_hist_rec_tab.new_attribute3(l_ctr)	            :=  i.new_attribute3;
1991       l_acct_hist_rec_tab.old_attribute4(l_ctr)	            :=  i.old_attribute4;
1992       l_acct_hist_rec_tab.new_attribute4(l_ctr)	            :=  i.new_attribute4;
1993       l_acct_hist_rec_tab.old_attribute5(l_ctr)	            :=  i.old_attribute5;
1994       l_acct_hist_rec_tab.new_attribute5(l_ctr)	            :=  i.new_attribute5;
1995       l_acct_hist_rec_tab.old_attribute6(l_ctr)	            :=  i.old_attribute6;
1996       l_acct_hist_rec_tab.new_attribute6(l_ctr)	            :=  i.new_attribute6;
1997       l_acct_hist_rec_tab.old_attribute7(l_ctr)	            :=  i.old_attribute7;
1998       l_acct_hist_rec_tab.new_attribute7(l_ctr)	            :=  i.new_attribute7;
1999       l_acct_hist_rec_tab.old_attribute8(l_ctr)	            :=  i.old_attribute8;
2000       l_acct_hist_rec_tab.new_attribute8(l_ctr)	            :=  i.new_attribute8;
2001       l_acct_hist_rec_tab.old_attribute9(l_ctr)	            :=  i.old_attribute9;
2002       l_acct_hist_rec_tab.new_attribute9(l_ctr)	            :=  i.new_attribute9;
2003       l_acct_hist_rec_tab.old_attribute10(l_ctr)	        :=  i.old_attribute10;
2004       l_acct_hist_rec_tab.new_attribute10(l_ctr)	        :=  i.new_attribute10;
2005       l_acct_hist_rec_tab.old_attribute11(l_ctr)      	    :=  i.old_attribute11;
2009       l_acct_hist_rec_tab.old_attribute13(l_ctr)	        :=  i.old_attribute13;
2006       l_acct_hist_rec_tab.new_attribute11(l_ctr)	        :=  i.new_attribute11;
2007       l_acct_hist_rec_tab.old_attribute12(l_ctr)	        :=  i.old_attribute12;
2008       l_acct_hist_rec_tab.new_attribute12(l_ctr)	        :=  i.new_attribute12;
2010       l_acct_hist_rec_tab.new_attribute13(l_ctr)	        :=  i.new_attribute13;
2011       l_acct_hist_rec_tab.old_attribute14(l_ctr)	        :=  i.old_attribute14;
2012       l_acct_hist_rec_tab.new_attribute14(l_ctr)	        :=  i.new_attribute14;
2013       l_acct_hist_rec_tab.old_attribute15(l_ctr)	        :=  i.old_attribute15;
2014       l_acct_hist_rec_tab.new_attribute15(l_ctr)	        :=  i.new_attribute15;
2015       l_acct_hist_rec_tab.acct_full_dump_flag(l_ctr)	    :=  i.full_dump_flag;
2016       l_acct_hist_rec_tab.acct_created_by(l_ctr)            :=  i.created_by;
2017       l_acct_hist_rec_tab.acct_creation_date(l_ctr)         :=  i.creation_date;
2018       l_acct_hist_rec_tab.acct_last_updated_by(l_ctr)       :=  i.last_updated_by;
2019       l_acct_hist_rec_tab.acct_last_update_date(l_ctr)      :=  i.last_update_date;
2020       l_acct_hist_rec_tab.acct_last_update_login(l_ctr)     :=  i.last_update_login;
2021       l_acct_hist_rec_tab.acct_object_version_number(l_ctr)	:=  i.object_version_number;
2022       l_acct_hist_rec_tab.acct_security_group_id(l_ctr)	    :=  i.security_group_id;
2023       l_acct_hist_rec_tab.acct_migrated_flag(l_ctr)	        :=  i.migrated_flag;
2024       l_acct_hist_rec_tab.old_instance_party_id(l_ctr)      :=  i.old_instance_party_id;
2025       l_acct_hist_rec_tab.new_instance_party_id(l_ctr)      :=  i.new_instance_party_id;
2026 
2027    End Loop;
2028 
2029       -- get the party history count for the transaction range
2030       l_cnt := l_acct_hist_rec_tab.ip_account_history_id.count;
2031       --
2032       Debug('');
2033       Debug('');
2034       Debug('Number of Party Account history records archived:'||to_char(l_cnt));
2035       Debug('');
2036       Debug('');
2037       --
2038       If l_cnt > 0 Then
2039 
2040         FORALL i IN 1 .. l_cnt
2041 
2042          Insert Into CSI_HISTORY_ARCHIVE
2043          (
2044             HISTORY_ARCHIVE_ID
2045            ,OBJECT_ID
2046            ,ENTITY_HISTORY_ID
2047            ,TRANSACTION_ID
2048            ,ENTITY_ID
2049            ,COL_NUM_01
2050            ,COL_NUM_02
2051            ,COL_NUM_03
2052            ,COL_NUM_04
2053            ,COL_NUM_05
2054            ,COL_NUM_06
2055            ,COL_NUM_07
2056            ,COL_NUM_08
2057            ,COL_NUM_37
2058            ,COL_NUM_38
2059            ,COL_NUM_39
2060            ,COL_NUM_40
2061            ,COL_NUM_41
2062            ,COL_CHAR_01
2063            ,COL_CHAR_02
2064            ,COL_CHAR_31
2065            ,COL_CHAR_32
2066            ,COL_CHAR_33
2067            ,COL_CHAR_34
2068            ,COL_CHAR_35
2069            ,COL_CHAR_36
2070            ,COL_CHAR_37
2071            ,COL_CHAR_38
2072            ,COL_CHAR_39
2073            ,COL_CHAR_40
2074            ,COL_CHAR_41
2075            ,COL_CHAR_42
2076            ,COL_CHAR_43
2077            ,COL_CHAR_44
2078            ,COL_CHAR_45
2079            ,COL_CHAR_46
2080            ,COL_CHAR_47
2081            ,COL_CHAR_48
2082            ,COL_CHAR_49
2083            ,COL_CHAR_50
2084            ,COL_CHAR_51
2085            ,COL_CHAR_52
2086            ,COL_CHAR_53
2087            ,COL_CHAR_54
2088            ,COL_CHAR_55
2089            ,COL_CHAR_56
2090            ,COL_CHAR_57
2091            ,COL_CHAR_58
2092            ,COL_CHAR_59
2093            ,COL_CHAR_60
2094            ,COL_CHAR_61
2095            ,COL_CHAR_62
2096            ,COL_CHAR_71
2097            ,COL_CHAR_72
2098            ,COL_DATE_01
2099            ,COL_DATE_02
2100            ,COL_DATE_03
2101            ,COL_DATE_04
2102            ,COL_DATE_11
2103            ,COL_DATE_12
2104            ,CONTEXT
2105            ,ATTRIBUTE1
2106            ,ATTRIBUTE2
2107            ,ATTRIBUTE3
2108            ,ATTRIBUTE4
2109            ,ATTRIBUTE5
2110            ,ATTRIBUTE6
2111            ,ATTRIBUTE7
2112            ,ATTRIBUTE8
2113            ,ATTRIBUTE9
2114            ,ATTRIBUTE10
2115            ,ATTRIBUTE11
2116            ,ATTRIBUTE12
2117            ,ATTRIBUTE13
2118            ,ATTRIBUTE14
2119            ,ATTRIBUTE15
2120            ,CREATED_BY
2121            ,CREATION_DATE
2122            ,LAST_UPDATED_BY
2123            ,LAST_UPDATE_DATE
2124            ,LAST_UPDATE_LOGIN
2125            ,OBJECT_VERSION_NUMBER
2126            ,SECURITY_GROUP_ID
2127            )
2128            Values
2129            (
2130            l_archive_id_tbl(i),
2131            l_table_id,
2132            l_acct_hist_rec_tab.ip_account_history_id(i),
2133            l_acct_hist_rec_tab.transaction_id(i),
2134            l_acct_hist_rec_tab.ip_account_id(i),
2135            l_acct_hist_rec_tab.old_party_account_id(i),
2136            l_acct_hist_rec_tab.new_party_account_id(i),
2137            l_acct_hist_rec_tab.old_bill_to_address(i),
2138            l_acct_hist_rec_tab.new_bill_to_address(i),
2139            l_acct_hist_rec_tab.old_ship_to_address(i),
2140            l_acct_hist_rec_tab.new_ship_to_address(i),
2141            l_acct_hist_rec_tab.old_instance_party_id(i),
2142            l_acct_hist_rec_tab.new_instance_party_id(i),
2143            l_acct_hist_rec_tab.acct_created_by(i),
2144            l_acct_hist_rec_tab.acct_last_updated_by(i),
2145            l_acct_hist_rec_tab.acct_last_update_login(i),
2146 		   l_acct_hist_rec_tab.acct_object_version_number(i), -- obj_ver_num
2147            l_acct_hist_rec_tab.acct_security_group_id(i), -- sec_grp_id
2148            l_acct_hist_rec_tab.old_relationship_type_code(i),
2149            l_acct_hist_rec_tab.new_relationship_type_code(i),
2150            l_acct_hist_rec_tab.old_context(i),
2151            l_acct_hist_rec_tab.new_context(i),
2152            l_acct_hist_rec_tab.old_attribute1(i),
2153            l_acct_hist_rec_tab.new_attribute1(i),
2154            l_acct_hist_rec_tab.old_attribute2(i),
2155            l_acct_hist_rec_tab.new_attribute2(i),
2156            l_acct_hist_rec_tab.old_attribute3(i),
2157            l_acct_hist_rec_tab.new_attribute3(i),
2158            l_acct_hist_rec_tab.old_attribute4(i),
2159            l_acct_hist_rec_tab.new_attribute4(i),
2160            l_acct_hist_rec_tab.old_attribute5(i),
2161            l_acct_hist_rec_tab.new_attribute5(i),
2162            l_acct_hist_rec_tab.old_attribute6(i),
2163            l_acct_hist_rec_tab.new_attribute6(i),
2164            l_acct_hist_rec_tab.old_attribute7(i),
2165            l_acct_hist_rec_tab.new_attribute7(i),
2166            l_acct_hist_rec_tab.old_attribute8(i),
2167            l_acct_hist_rec_tab.new_attribute8(i),
2168            l_acct_hist_rec_tab.old_attribute9(i),
2169            l_acct_hist_rec_tab.new_attribute9(i),
2170            l_acct_hist_rec_tab.old_attribute10(i),
2171            l_acct_hist_rec_tab.new_attribute10(i),
2172            l_acct_hist_rec_tab.old_attribute11(i),
2173            l_acct_hist_rec_tab.new_attribute11(i),
2174            l_acct_hist_rec_tab.old_attribute12(i),
2175            l_acct_hist_rec_tab.new_attribute12(i),
2176            l_acct_hist_rec_tab.old_attribute13(i),
2177            l_acct_hist_rec_tab.new_attribute13(i),
2178            l_acct_hist_rec_tab.old_attribute14(i),
2179            l_acct_hist_rec_tab.new_attribute14(i),
2180            l_acct_hist_rec_tab.old_attribute15(i),
2181            l_acct_hist_rec_tab.new_attribute15(i),
2182            l_acct_hist_rec_tab.acct_full_dump_flag(i), --'N', dump_flag
2183            l_acct_hist_rec_tab.acct_migrated_flag(i), -- mig_flag
2184            l_acct_hist_rec_tab.old_active_start_date(i),
2185            l_acct_hist_rec_tab.new_active_start_date(i),
2186            l_acct_hist_rec_tab.old_active_end_date(i),
2187            l_acct_hist_rec_tab.new_active_end_date(i),
2188            l_acct_hist_rec_tab.acct_creation_date(i),
2189            l_acct_hist_rec_tab.acct_last_update_date(i),
2190            null,
2191            null,
2192            null,
2193            null,
2194            null,
2195            null,
2196            null,
2197            null,
2198            null,
2199            null,
2200            null,
2201            null,
2202            null,
2203            null,
2204            null,
2205            null,
2206            l_user_id,
2207            sysdate,
2208            l_user_id,
2209            sysdate,
2210            l_login_id,
2214 
2211            1,
2212            null
2213            );
2215          -- Purge the corresonding Archive data from the Instance history tables
2216 
2217             FORALL i IN 1 .. l_cnt
2218 
2219                Delete From CSI_IP_ACCOUNTS_H
2220                Where ip_account_history_id = l_acct_hist_rec_tab.ip_account_history_id(i);
2221 
2222        End If; -- if l_cnt > 0
2223        --
2224        Exit When from_trans = to_trans;
2225        Exit When v_end = to_trans;
2226 
2227      v_start := v_end + 1;
2228      v_end   := v_start + v_batch;
2229      --
2230      --
2231 	 If v_start > to_trans Then
2232 	    v_start := to_trans;
2233 	 End If;
2234 	 --
2235 	 If v_end > to_trans then
2236 	    v_end := to_trans;
2237 	 End If;
2238      --
2239      Commit;
2240      --
2241    Exception
2242       when others then
2243          Debug(substr(sqlerrm,1,255));
2244          ROLLBACK to Account_Archive;
2245    End;
2246  End Loop; -- Local Batch Loop
2247  Commit;
2248    --
2249 END; -- End of Procedure Inst Party Account Archive
2250 
2251 --
2252 -- This program is used to archive the Operating units history. It accepts from and to transactions
2253 -- as the input parameters.
2254 --
2255 
2256 PROCEDURE Org_Units_archive( errbuf       OUT NOCOPY VARCHAR2,
2257                              retcode      OUT NOCOPY NUMBER,
2258                              from_trans   IN  NUMBER,
2259                              to_trans     IN  NUMBER,
2260                              purge_to_date IN VARCHAR2 )
2261 IS
2262 
2263     l_archive_id      NUMBER;
2264     l_ctr             NUMBER := 0;
2265     l_cnt             NUMBER;
2266     l_table_id        NUMBER;
2267     l_user_id         NUMBER := FND_GLOBAL.USER_ID;
2268     l_login_id        NUMBER := FND_GLOBAL.CONC_LOGIN_ID;
2269     v_batch           NUMBER := 15000;
2270     v_start           NUMBER;
2271     v_end             NUMBER;
2272 
2273     Type NUMLIST IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
2274     l_archive_id_tbl   NUMLIST;
2275 
2276     Cursor org_units_hist_csr (p_from_trans IN NUMBER,
2277                                p_to_trans   IN NUMBER) IS
2278     Select csh.*
2279     From   CSI_I_ORG_ASSIGNMENTS_H csh,
2280            CSI_TRANSACTIONS csit
2281     Where  csit.transaction_id between from_trans and to_trans
2282     And    csit.creation_date < to_date(purge_to_date, 'YYYY/MM/DD HH24:MI:SS')
2283     And    csh.transaction_id = csit.transaction_id;
2284 
2285     l_org_units_hist_csr         org_units_hist_csr%ROWTYPE;
2286     l_org_units_hist_rec_tab     csi_txn_history_purge_pvt.org_units_history_rec_tab;
2287 
2288 
2289 Begin
2290     --
2291     --
2292     Begin
2293       Select object_id
2294       Into   l_table_id
2295       From   csi_object_dictionary
2296       Where  object_name = 'CSI_I_ORG_ASSIGNMENTS_H';
2297     Exception
2298       When no_data_found Then
2299         l_table_id := 4;
2300       When others Then
2301         l_table_id := 4;
2302     End;
2303     --
2304     Begin
2305       Select fnd_profile.value('CSI_TXN_HISTORY_PURGE_BATCH_SIZE')
2306       Into   v_batch
2307       From   dual;
2308     Exception
2309       When no_data_found Then
2310         v_batch := 15000;
2311     End;
2312     --
2313     v_start := from_trans;
2314     v_end   := from_trans + v_batch;
2315     --
2316     If v_end > to_trans Then
2317        v_end := to_trans;
2318     End If;
2319     --
2320  Loop
2321    Begin
2322       SAVEPOINT Org_Archive;
2323       l_ctr := 0;
2324       --
2325       l_org_units_hist_rec_tab.instance_ou_history_id.DELETE;
2326       l_org_units_hist_rec_tab.instance_ou_id.DELETE;
2327       l_org_units_hist_rec_tab.transaction_id.DELETE;
2328       l_org_units_hist_rec_tab.old_operating_unit_id.DELETE;
2329       l_org_units_hist_rec_tab.new_operating_unit_id.DELETE;
2330       l_org_units_hist_rec_tab.old_ou_relnship_type_code.DELETE;
2331       l_org_units_hist_rec_tab.new_ou_relnship_type_code.DELETE;
2332       l_org_units_hist_rec_tab.old_ou_active_start_date.DELETE;
2333       l_org_units_hist_rec_tab.new_ou_active_start_date.DELETE;
2334       l_org_units_hist_rec_tab.old_ou_active_end_date.DELETE;
2335       l_org_units_hist_rec_tab.new_ou_active_end_date.DELETE;
2336       l_org_units_hist_rec_tab.old_ou_context.DELETE;
2337       l_org_units_hist_rec_tab.new_ou_context.DELETE;
2338       l_org_units_hist_rec_tab.old_ou_attribute1.DELETE;
2339       l_org_units_hist_rec_tab.new_ou_attribute1.DELETE;
2340       l_org_units_hist_rec_tab.old_ou_attribute2.DELETE;
2341       l_org_units_hist_rec_tab.new_ou_attribute2.DELETE;
2342       l_org_units_hist_rec_tab.old_ou_attribute3.DELETE;
2343       l_org_units_hist_rec_tab.new_ou_attribute3.DELETE;
2344       l_org_units_hist_rec_tab.old_ou_attribute4.DELETE;
2345       l_org_units_hist_rec_tab.new_ou_attribute4.DELETE;
2346       l_org_units_hist_rec_tab.old_ou_attribute5.DELETE;
2347       l_org_units_hist_rec_tab.new_ou_attribute5.DELETE;
2348       l_org_units_hist_rec_tab.old_ou_attribute6.DELETE;
2349       l_org_units_hist_rec_tab.new_ou_attribute6.DELETE;
2350       l_org_units_hist_rec_tab.old_ou_attribute7.DELETE;
2351       l_org_units_hist_rec_tab.new_ou_attribute7.DELETE;
2352       l_org_units_hist_rec_tab.old_ou_attribute8.DELETE;
2353       l_org_units_hist_rec_tab.new_ou_attribute8.DELETE;
2354       l_org_units_hist_rec_tab.old_ou_attribute9.DELETE;
2355       l_org_units_hist_rec_tab.new_ou_attribute9.DELETE;
2356       l_org_units_hist_rec_tab.old_ou_attribute10.DELETE;
2357       l_org_units_hist_rec_tab.new_ou_attribute10.DELETE;
2358       l_org_units_hist_rec_tab.old_ou_attribute11.DELETE;
2359       l_org_units_hist_rec_tab.new_ou_attribute11.DELETE;
2360       l_org_units_hist_rec_tab.old_ou_attribute12.DELETE;
2361       l_org_units_hist_rec_tab.new_ou_attribute12.DELETE;
2362       l_org_units_hist_rec_tab.old_ou_attribute13.DELETE;
2363       l_org_units_hist_rec_tab.new_ou_attribute13.DELETE;
2364       l_org_units_hist_rec_tab.old_ou_attribute14.DELETE;
2365       l_org_units_hist_rec_tab.new_ou_attribute14.DELETE;
2366       l_org_units_hist_rec_tab.old_ou_attribute15.DELETE;
2367       l_org_units_hist_rec_tab.new_ou_attribute15.DELETE;
2368       l_org_units_hist_rec_tab.ou_full_dump_flag.DELETE;
2369       l_org_units_hist_rec_tab.ou_created_by.DELETE;
2370       l_org_units_hist_rec_tab.ou_creation_date.DELETE;
2371       l_org_units_hist_rec_tab.ou_last_updated_by.DELETE;
2372       l_org_units_hist_rec_tab.ou_last_update_date.DELETE;
2373       l_org_units_hist_rec_tab.ou_last_update_login.DELETE;
2374       l_org_units_hist_rec_tab.ou_object_version_number.DELETE;
2375       l_org_units_hist_rec_tab.ou_security_group_id.DELETE;
2376       l_org_units_hist_rec_tab.ou_migrated_flag.DELETE;
2377       --
2378 
2379   For i in org_units_hist_csr(v_start,v_end)
2380   Loop
2381       --
2382       l_ctr := l_ctr + 1;
2383       --
2384       Select csi_history_archive_s.Nextval
2385       Into l_archive_id_tbl(l_ctr)
2386       From dual;
2387       --
2388       l_org_units_hist_rec_tab.instance_ou_history_id(l_ctr)        :=  i.instance_ou_history_id;
2389       l_org_units_hist_rec_tab.instance_ou_id(l_ctr)                :=  i.instance_ou_id;
2390       l_org_units_hist_rec_tab.transaction_id(l_ctr)                :=  i.transaction_id;
2391       l_org_units_hist_rec_tab.old_operating_unit_id(l_ctr)         :=  i.old_operating_unit_id;
2392       l_org_units_hist_rec_tab.new_operating_unit_id(l_ctr)         :=  i.new_operating_unit_id;
2393       l_org_units_hist_rec_tab.old_ou_relnship_type_code(l_ctr)     :=  i.old_relationship_type_code;
2394       l_org_units_hist_rec_tab.new_ou_relnship_type_code(l_ctr)     :=  i.new_relationship_type_code;
2395       l_org_units_hist_rec_tab.old_ou_active_start_date(l_ctr)      :=  i.old_active_start_date;
2396       l_org_units_hist_rec_tab.new_ou_active_start_date(l_ctr)      :=  i.new_active_start_date;
2397       l_org_units_hist_rec_tab.old_ou_active_end_date(l_ctr)        :=  i.old_active_end_date;
2398       l_org_units_hist_rec_tab.new_ou_active_end_date(l_ctr)        :=  i.new_active_end_date;
2399       l_org_units_hist_rec_tab.old_ou_context(l_ctr)	            :=  i.old_context;
2400       l_org_units_hist_rec_tab.new_ou_context(l_ctr)	            :=  i.new_context;
2401       l_org_units_hist_rec_tab.old_ou_attribute1(l_ctr)	            :=  i.old_attribute1;
2402       l_org_units_hist_rec_tab.new_ou_attribute1(l_ctr)	            :=  i.new_attribute1;
2403       l_org_units_hist_rec_tab.old_ou_attribute2(l_ctr)	            :=  i.old_attribute2;
2404       l_org_units_hist_rec_tab.new_ou_attribute2(l_ctr)	            :=  i.new_attribute2;
2405       l_org_units_hist_rec_tab.old_ou_attribute3(l_ctr)	            :=  i.old_attribute3;
2406       l_org_units_hist_rec_tab.new_ou_attribute3(l_ctr)	            :=  i.new_attribute3;
2407       l_org_units_hist_rec_tab.old_ou_attribute4(l_ctr)	            :=  i.old_attribute4;
2408       l_org_units_hist_rec_tab.new_ou_attribute4(l_ctr)	            :=  i.new_attribute4;
2409       l_org_units_hist_rec_tab.old_ou_attribute5(l_ctr)	            :=  i.old_attribute5;
2410       l_org_units_hist_rec_tab.new_ou_attribute5(l_ctr)	            :=  i.new_attribute5;
2411       l_org_units_hist_rec_tab.old_ou_attribute6(l_ctr)	            :=  i.old_attribute6;
2412       l_org_units_hist_rec_tab.new_ou_attribute6(l_ctr)	            :=  i.new_attribute6;
2413       l_org_units_hist_rec_tab.old_ou_attribute7(l_ctr)	            :=  i.old_attribute7;
2414       l_org_units_hist_rec_tab.new_ou_attribute7(l_ctr)	            :=  i.new_attribute7;
2415       l_org_units_hist_rec_tab.old_ou_attribute8(l_ctr)	            :=  i.old_attribute8;
2416       l_org_units_hist_rec_tab.new_ou_attribute8(l_ctr)	            :=  i.new_attribute8;
2417       l_org_units_hist_rec_tab.old_ou_attribute9(l_ctr)	            :=  i.old_attribute9;
2421       l_org_units_hist_rec_tab.old_ou_attribute11(l_ctr)      	    :=  i.old_attribute11;
2418       l_org_units_hist_rec_tab.new_ou_attribute9(l_ctr)	            :=  i.new_attribute9;
2419       l_org_units_hist_rec_tab.old_ou_attribute10(l_ctr)	        :=  i.old_attribute10;
2420       l_org_units_hist_rec_tab.new_ou_attribute10(l_ctr)	        :=  i.new_attribute10;
2422       l_org_units_hist_rec_tab.new_ou_attribute11(l_ctr)	        :=  i.new_attribute11;
2423       l_org_units_hist_rec_tab.old_ou_attribute12(l_ctr)	        :=  i.old_attribute12;
2424       l_org_units_hist_rec_tab.new_ou_attribute12(l_ctr)	        :=  i.new_attribute12;
2425       l_org_units_hist_rec_tab.old_ou_attribute13(l_ctr)	        :=  i.old_attribute13;
2426       l_org_units_hist_rec_tab.new_ou_attribute13(l_ctr)	        :=  i.new_attribute13;
2427       l_org_units_hist_rec_tab.old_ou_attribute14(l_ctr)	        :=  i.old_attribute14;
2428       l_org_units_hist_rec_tab.new_ou_attribute14(l_ctr)	        :=  i.new_attribute14;
2429       l_org_units_hist_rec_tab.old_ou_attribute15(l_ctr)	        :=  i.old_attribute15;
2430       l_org_units_hist_rec_tab.new_ou_attribute15(l_ctr)	        :=  i.new_attribute15;
2431       l_org_units_hist_rec_tab.ou_full_dump_flag(l_ctr)	            :=  i.full_dump_flag;
2432       l_org_units_hist_rec_tab.ou_created_by(l_ctr)                 :=  i.created_by;
2433       l_org_units_hist_rec_tab.ou_creation_date(l_ctr)              :=  i.creation_date;
2434       l_org_units_hist_rec_tab.ou_last_updated_by(l_ctr)            :=  i.last_updated_by;
2435       l_org_units_hist_rec_tab.ou_last_update_date(l_ctr)           :=  i.last_update_date;
2436       l_org_units_hist_rec_tab.ou_last_update_login(l_ctr)          :=  i.last_update_login;
2437       l_org_units_hist_rec_tab.ou_object_version_number(l_ctr)	    :=  i.object_version_number;
2438       l_org_units_hist_rec_tab.ou_security_group_id(l_ctr)	        :=  i.security_group_id;
2439       l_org_units_hist_rec_tab.ou_migrated_flag(l_ctr)	            :=  i.migrated_flag;
2440 
2441    End Loop;
2442 
2443       -- get the party history count for the transaction range
2444       l_cnt := l_org_units_hist_rec_tab.instance_ou_history_id.count;
2445       --
2446       Debug('');
2447       Debug('');
2448       Debug('Number of Org Assignments history records archived:'||to_char(l_cnt));
2449       Debug('');
2450       Debug('');
2451       --
2452       If l_cnt > 0 Then
2453 
2454         FORALL i IN 1 .. l_cnt
2455 
2456          Insert Into CSI_HISTORY_ARCHIVE
2457          (
2458             HISTORY_ARCHIVE_ID
2459            ,OBJECT_ID
2460            ,ENTITY_HISTORY_ID
2461            ,TRANSACTION_ID
2462            ,ENTITY_ID
2463            ,COL_NUM_01
2464            ,COL_NUM_02
2465            ,COL_NUM_37
2466            ,COL_NUM_38
2467            ,COL_NUM_39
2468            ,COL_NUM_40
2469            ,COL_NUM_41
2470            ,COL_CHAR_01
2471            ,COL_CHAR_02
2472            ,COL_CHAR_31
2473            ,COL_CHAR_32
2474            ,COL_CHAR_33
2475            ,COL_CHAR_34
2476            ,COL_CHAR_35
2477            ,COL_CHAR_36
2478            ,COL_CHAR_37
2479            ,COL_CHAR_38
2480            ,COL_CHAR_39
2481            ,COL_CHAR_40
2482            ,COL_CHAR_41
2483            ,COL_CHAR_42
2484            ,COL_CHAR_43
2485            ,COL_CHAR_44
2486            ,COL_CHAR_45
2487            ,COL_CHAR_46
2488            ,COL_CHAR_47
2489            ,COL_CHAR_48
2490            ,COL_CHAR_49
2491            ,COL_CHAR_50
2492            ,COL_CHAR_51
2493            ,COL_CHAR_52
2494            ,COL_CHAR_53
2495            ,COL_CHAR_54
2496            ,COL_CHAR_55
2497            ,COL_CHAR_56
2498            ,COL_CHAR_57
2499            ,COL_CHAR_58
2500            ,COL_CHAR_59
2501            ,COL_CHAR_60
2502            ,COL_CHAR_61
2503            ,COL_CHAR_62
2504            ,COL_CHAR_71
2505            ,COL_CHAR_72
2506            ,COL_DATE_01
2507            ,COL_DATE_02
2508            ,COL_DATE_03
2509            ,COL_DATE_04
2510            ,COL_DATE_11
2511            ,COL_DATE_12
2512            ,CONTEXT
2513            ,ATTRIBUTE1
2514            ,ATTRIBUTE2
2515            ,ATTRIBUTE3
2516            ,ATTRIBUTE4
2517            ,ATTRIBUTE5
2518            ,ATTRIBUTE6
2519            ,ATTRIBUTE7
2520            ,ATTRIBUTE8
2521            ,ATTRIBUTE9
2522            ,ATTRIBUTE10
2523            ,ATTRIBUTE11
2524            ,ATTRIBUTE12
2525            ,ATTRIBUTE13
2526            ,ATTRIBUTE14
2527            ,ATTRIBUTE15
2528            ,CREATED_BY
2529            ,CREATION_DATE
2530            ,LAST_UPDATED_BY
2531            ,LAST_UPDATE_DATE
2532            ,LAST_UPDATE_LOGIN
2533            ,OBJECT_VERSION_NUMBER
2534            ,SECURITY_GROUP_ID
2535            )
2536            Values
2537            (
2538            l_archive_id_tbl(i),
2539            l_table_id,
2540            l_org_units_hist_rec_tab.instance_ou_history_id(i),
2544            l_org_units_hist_rec_tab.new_operating_unit_id(i),
2541            l_org_units_hist_rec_tab.transaction_id(i),
2542            l_org_units_hist_rec_tab.instance_ou_id(i),
2543            l_org_units_hist_rec_tab.old_operating_unit_id(i),
2545            l_org_units_hist_rec_tab.ou_created_by(i),
2546            l_org_units_hist_rec_tab.ou_last_updated_by(i),
2547            l_org_units_hist_rec_tab.ou_last_update_login(i),
2548 		   l_org_units_hist_rec_tab.ou_object_version_number(i), -- obj_ver_num
2549            l_org_units_hist_rec_tab.ou_security_group_id(i), -- sec_grp_id
2550            l_org_units_hist_rec_tab.old_ou_relnship_type_code(i),
2551            l_org_units_hist_rec_tab.new_ou_relnship_type_code(i),
2552            l_org_units_hist_rec_tab.old_ou_context(i),
2553            l_org_units_hist_rec_tab.new_ou_context(i),
2554            l_org_units_hist_rec_tab.old_ou_attribute1(i),
2555            l_org_units_hist_rec_tab.new_ou_attribute1(i),
2556            l_org_units_hist_rec_tab.old_ou_attribute2(i),
2557            l_org_units_hist_rec_tab.new_ou_attribute2(i),
2558            l_org_units_hist_rec_tab.old_ou_attribute3(i),
2559            l_org_units_hist_rec_tab.new_ou_attribute3(i),
2560            l_org_units_hist_rec_tab.old_ou_attribute4(i),
2561            l_org_units_hist_rec_tab.new_ou_attribute4(i),
2562            l_org_units_hist_rec_tab.old_ou_attribute5(i),
2563            l_org_units_hist_rec_tab.new_ou_attribute5(i),
2564            l_org_units_hist_rec_tab.old_ou_attribute6(i),
2565            l_org_units_hist_rec_tab.new_ou_attribute6(i),
2566            l_org_units_hist_rec_tab.old_ou_attribute7(i),
2567            l_org_units_hist_rec_tab.new_ou_attribute7(i),
2568            l_org_units_hist_rec_tab.old_ou_attribute8(i),
2569            l_org_units_hist_rec_tab.new_ou_attribute8(i),
2570            l_org_units_hist_rec_tab.old_ou_attribute9(i),
2571            l_org_units_hist_rec_tab.new_ou_attribute9(i),
2572            l_org_units_hist_rec_tab.old_ou_attribute10(i),
2573            l_org_units_hist_rec_tab.new_ou_attribute10(i),
2574            l_org_units_hist_rec_tab.old_ou_attribute11(i),
2575            l_org_units_hist_rec_tab.new_ou_attribute11(i),
2576            l_org_units_hist_rec_tab.old_ou_attribute12(i),
2577            l_org_units_hist_rec_tab.new_ou_attribute12(i),
2578            l_org_units_hist_rec_tab.old_ou_attribute13(i),
2579            l_org_units_hist_rec_tab.new_ou_attribute13(i),
2580            l_org_units_hist_rec_tab.old_ou_attribute14(i),
2581            l_org_units_hist_rec_tab.new_ou_attribute14(i),
2582            l_org_units_hist_rec_tab.old_ou_attribute15(i),
2583            l_org_units_hist_rec_tab.new_ou_attribute15(i),
2584            l_org_units_hist_rec_tab.ou_full_dump_flag(i), --'N', dump_flag
2585            l_org_units_hist_rec_tab.ou_migrated_flag(i), -- mig_flag
2586            l_org_units_hist_rec_tab.old_ou_active_start_date(i),
2587            l_org_units_hist_rec_tab.new_ou_active_start_date(i),
2588            l_org_units_hist_rec_tab.old_ou_active_end_date(i),
2589            l_org_units_hist_rec_tab.new_ou_active_end_date(i),
2590            l_org_units_hist_rec_tab.ou_creation_date(i),
2591            l_org_units_hist_rec_tab.ou_last_update_date(i),
2592            null,
2593            null,
2594            null,
2595            null,
2596            null,
2597            null,
2598            null,
2599            null,
2600            null,
2601            null,
2602            null,
2603            null,
2604            null,
2605            null,
2606            null,
2607            null,
2608            l_user_id,
2609            sysdate,
2610            l_user_id,
2611            sysdate,
2612            l_login_id,
2613            1,
2614            null
2615            );
2616 
2617         -- Purge the corresonding Archive data from the Instance history tables
2618 
2619            FORALL i IN 1 .. l_cnt
2620 
2621                Delete From CSI_I_ORG_ASSIGNMENTS_H
2622                Where instance_ou_history_id = l_org_units_hist_rec_tab.instance_ou_history_id(i);
2623 
2624 
2625        End If; -- if l_cnt > 0
2626 
2627        Exit When from_trans = to_trans;
2628        Exit When v_end = to_trans;
2629 
2630      v_start := v_end + 1;
2631      v_end   := v_start + v_batch;
2632      --
2633      --
2634 	 If v_start > to_trans Then
2635 	    v_start := to_trans;
2636 	 End If;
2637 	 --
2638 	 If v_end > to_trans then
2639 	    v_end := to_trans;
2640 	 End If;
2641      --
2642      Commit;
2643      --
2644    Exception
2645       when others then
2646          Debug(substr(sqlerrm,1,255));
2647          ROLLBACK to Org_Archive;
2648    End;
2649  End Loop; -- Local Batch Loop
2650  Commit;
2651    --
2652 END; -- Procedure OrgUnits_Archive
2653 
2654 --
2655 -- This program is used to archive the Extended Attribs history. It accepts from and to transactions
2656 -- as the input parameters.
2657 --
2658 
2659 PROCEDURE Ext_Attribs_archive( errbuf       OUT NOCOPY VARCHAR2,
2660                                retcode      OUT NOCOPY NUMBER,
2661                                from_trans   IN  NUMBER,
2662                                to_trans     IN  NUMBER,
2663                                purge_to_date IN VARCHAR2 )
2664 IS
2665 
2666     l_archive_id      NUMBER;
2667     l_ctr             NUMBER := 0;
2668     l_cnt             NUMBER;
2669     l_table_id        NUMBER;
2673     v_start           NUMBER;
2670     l_user_id         NUMBER := FND_GLOBAL.USER_ID;
2671     l_login_id        NUMBER := FND_GLOBAL.CONC_LOGIN_ID;
2672     v_batch           NUMBER := 15000;
2674     v_end             NUMBER;
2675 
2676     Type NUMLIST IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
2677     l_archive_id_tbl   NUMLIST;
2678 
2679     Cursor ext_attrib_hist_csr (p_from_trans IN NUMBER,
2680                                 p_to_trans   IN NUMBER) IS
2681     Select csh.*
2682     From   CSI_IEA_VALUES_H csh,
2683            CSI_TRANSACTIONS csit
2684     Where  csit.transaction_id between from_trans and to_trans
2685     And    csit.creation_date < to_date(purge_to_date, 'YYYY/MM/DD HH24:MI:SS')
2686     And    csh.transaction_id = csit.transaction_id;
2687 
2688     l_ext_attrib_hist_csr         ext_attrib_hist_csr%ROWTYPE;
2689     l_ext_attrib_hist_rec_tab     csi_txn_history_purge_pvt.ext_attrib_history_rec_tab;
2690 
2691 
2692 Begin
2693     --
2694     --
2695     Begin
2696       Select object_id
2697       Into   l_table_id
2698       From   csi_object_dictionary
2699       Where  object_name = 'CSI_IEA_VALUES_H';
2700     Exception
2701       When no_data_found Then
2702         l_table_id := 5;
2703       When others Then
2704         l_table_id := 5;
2705     End;
2706     --
2707     Begin
2708       Select fnd_profile.value('CSI_TXN_HISTORY_PURGE_BATCH_SIZE')
2709       Into   v_batch
2710       From   dual;
2711     Exception
2712       When no_data_found Then
2713         v_batch := 15000;
2714     End;
2715     --
2716     v_start := from_trans;
2717     v_end   := from_trans + v_batch;
2718     --
2719     If v_end > to_trans Then
2720        v_end := to_trans;
2721     End If;
2722     --
2723  Loop
2724    Begin
2725       SAVEPOINT Ext_Archive;
2726       l_ctr := 0;
2727       --
2728       l_ext_attrib_hist_rec_tab.attribute_value_history_id.DELETE;
2729       l_ext_attrib_hist_rec_tab.attribute_value_id.DELETE;
2730       l_ext_attrib_hist_rec_tab.transaction_id.DELETE;
2731       l_ext_attrib_hist_rec_tab.old_attribute_value.DELETE;
2732       l_ext_attrib_hist_rec_tab.new_attribute_value.DELETE;
2733       l_ext_attrib_hist_rec_tab.old_ext_active_start_date.DELETE;
2734       l_ext_attrib_hist_rec_tab.new_ext_active_start_date.DELETE;
2735       l_ext_attrib_hist_rec_tab.old_ext_active_end_date.DELETE;
2736       l_ext_attrib_hist_rec_tab.new_ext_active_end_date.DELETE;
2737       l_ext_attrib_hist_rec_tab.old_ext_context.DELETE;
2738       l_ext_attrib_hist_rec_tab.new_ext_context.DELETE;
2739       l_ext_attrib_hist_rec_tab.old_ext_attribute1.DELETE;
2740       l_ext_attrib_hist_rec_tab.new_ext_attribute1.DELETE;
2741       l_ext_attrib_hist_rec_tab.old_ext_attribute2.DELETE;
2742       l_ext_attrib_hist_rec_tab.new_ext_attribute2.DELETE;
2743       l_ext_attrib_hist_rec_tab.old_ext_attribute3.DELETE;
2744       l_ext_attrib_hist_rec_tab.new_ext_attribute3.DELETE;
2745       l_ext_attrib_hist_rec_tab.old_ext_attribute4.DELETE;
2746       l_ext_attrib_hist_rec_tab.new_ext_attribute4.DELETE;
2747       l_ext_attrib_hist_rec_tab.old_ext_attribute5.DELETE;
2748       l_ext_attrib_hist_rec_tab.new_ext_attribute5.DELETE;
2749       l_ext_attrib_hist_rec_tab.old_ext_attribute6.DELETE;
2750       l_ext_attrib_hist_rec_tab.new_ext_attribute6.DELETE;
2751       l_ext_attrib_hist_rec_tab.old_ext_attribute7.DELETE;
2752       l_ext_attrib_hist_rec_tab.new_ext_attribute7.DELETE;
2753       l_ext_attrib_hist_rec_tab.old_ext_attribute8.DELETE;
2754       l_ext_attrib_hist_rec_tab.new_ext_attribute8.DELETE;
2755       l_ext_attrib_hist_rec_tab.old_ext_attribute9.DELETE;
2756       l_ext_attrib_hist_rec_tab.new_ext_attribute9.DELETE;
2757       l_ext_attrib_hist_rec_tab.old_ext_attribute10.DELETE;
2758       l_ext_attrib_hist_rec_tab.new_ext_attribute10.DELETE;
2759       l_ext_attrib_hist_rec_tab.old_ext_attribute11.DELETE;
2760       l_ext_attrib_hist_rec_tab.new_ext_attribute11.DELETE;
2761       l_ext_attrib_hist_rec_tab.old_ext_attribute12.DELETE;
2762       l_ext_attrib_hist_rec_tab.new_ext_attribute12.DELETE;
2763       l_ext_attrib_hist_rec_tab.old_ext_attribute13.DELETE;
2764       l_ext_attrib_hist_rec_tab.new_ext_attribute13.DELETE;
2765       l_ext_attrib_hist_rec_tab.old_ext_attribute14.DELETE;
2766       l_ext_attrib_hist_rec_tab.new_ext_attribute14.DELETE;
2767       l_ext_attrib_hist_rec_tab.old_ext_attribute15.DELETE;
2768       l_ext_attrib_hist_rec_tab.new_ext_attribute15.DELETE;
2769       l_ext_attrib_hist_rec_tab.ext_full_dump_flag.DELETE;
2770       l_ext_attrib_hist_rec_tab.ext_created_by.DELETE;
2771       l_ext_attrib_hist_rec_tab.ext_creation_date.DELETE;
2772       l_ext_attrib_hist_rec_tab.ext_last_updated_by.DELETE;
2773       l_ext_attrib_hist_rec_tab.ext_last_update_date.DELETE;
2774       l_ext_attrib_hist_rec_tab.ext_last_update_login.DELETE;
2775       l_ext_attrib_hist_rec_tab.ext_object_version_number.DELETE;
2776       l_ext_attrib_hist_rec_tab.ext_security_group_id.DELETE;
2777       l_ext_attrib_hist_rec_tab.ext_migrated_flag.DELETE;
2778       --
2779 
2780   For i in ext_attrib_hist_csr(v_start,v_end)
2781   Loop
2782       --
2783       l_ctr := l_ctr + 1;
2784       --
2785       Select csi_history_archive_s.Nextval
2786       Into l_archive_id_tbl(l_ctr)
2787       From dual;
2788       --
2789       l_ext_attrib_hist_rec_tab.attribute_value_history_id(l_ctr)   :=  i.attribute_value_history_id;
2790       l_ext_attrib_hist_rec_tab.attribute_value_id(l_ctr)           :=  i.attribute_value_id;
2794       l_ext_attrib_hist_rec_tab.old_ext_active_start_date(l_ctr)    :=  i.old_active_start_date;
2791       l_ext_attrib_hist_rec_tab.transaction_id(l_ctr)               :=  i.transaction_id;
2792       l_ext_attrib_hist_rec_tab.old_attribute_value(l_ctr)          :=  i.old_attribute_value;
2793       l_ext_attrib_hist_rec_tab.new_attribute_value(l_ctr)          :=  i.new_attribute_value;
2795       l_ext_attrib_hist_rec_tab.new_ext_active_start_date(l_ctr)    :=  i.new_active_start_date;
2796       l_ext_attrib_hist_rec_tab.old_ext_active_end_date(l_ctr)      :=  i.old_active_end_date;
2797       l_ext_attrib_hist_rec_tab.new_ext_active_end_date(l_ctr)      :=  i.new_active_end_date;
2798       l_ext_attrib_hist_rec_tab.old_ext_context(l_ctr)	            :=  i.old_context;
2799       l_ext_attrib_hist_rec_tab.new_ext_context(l_ctr)	            :=  i.new_context;
2800       l_ext_attrib_hist_rec_tab.old_ext_attribute1(l_ctr)	        :=  i.old_attribute1;
2801       l_ext_attrib_hist_rec_tab.new_ext_attribute1(l_ctr)	        :=  i.new_attribute1;
2802       l_ext_attrib_hist_rec_tab.old_ext_attribute2(l_ctr)	        :=  i.old_attribute2;
2803       l_ext_attrib_hist_rec_tab.new_ext_attribute2(l_ctr)	        :=  i.new_attribute2;
2804       l_ext_attrib_hist_rec_tab.old_ext_attribute3(l_ctr)	        :=  i.old_attribute3;
2805       l_ext_attrib_hist_rec_tab.new_ext_attribute3(l_ctr)	        :=  i.new_attribute3;
2806       l_ext_attrib_hist_rec_tab.old_ext_attribute4(l_ctr)	        :=  i.old_attribute4;
2807       l_ext_attrib_hist_rec_tab.new_ext_attribute4(l_ctr)	        :=  i.new_attribute4;
2808       l_ext_attrib_hist_rec_tab.old_ext_attribute5(l_ctr)	        :=  i.old_attribute5;
2809       l_ext_attrib_hist_rec_tab.new_ext_attribute5(l_ctr)	        :=  i.new_attribute5;
2810       l_ext_attrib_hist_rec_tab.old_ext_attribute6(l_ctr)	        :=  i.old_attribute6;
2811       l_ext_attrib_hist_rec_tab.new_ext_attribute6(l_ctr)	        :=  i.new_attribute6;
2812       l_ext_attrib_hist_rec_tab.old_ext_attribute7(l_ctr)	        :=  i.old_attribute7;
2813       l_ext_attrib_hist_rec_tab.new_ext_attribute7(l_ctr)	        :=  i.new_attribute7;
2814       l_ext_attrib_hist_rec_tab.old_ext_attribute8(l_ctr)	        :=  i.old_attribute8;
2815       l_ext_attrib_hist_rec_tab.new_ext_attribute8(l_ctr)	        :=  i.new_attribute8;
2816       l_ext_attrib_hist_rec_tab.old_ext_attribute9(l_ctr)	        :=  i.old_attribute9;
2817       l_ext_attrib_hist_rec_tab.new_ext_attribute9(l_ctr)	        :=  i.new_attribute9;
2818       l_ext_attrib_hist_rec_tab.old_ext_attribute10(l_ctr)	        :=  i.old_attribute10;
2819       l_ext_attrib_hist_rec_tab.new_ext_attribute10(l_ctr)	        :=  i.new_attribute10;
2820       l_ext_attrib_hist_rec_tab.old_ext_attribute11(l_ctr)    	    :=  i.old_attribute11;
2821       l_ext_attrib_hist_rec_tab.new_ext_attribute11(l_ctr)	        :=  i.new_attribute11;
2822       l_ext_attrib_hist_rec_tab.old_ext_attribute12(l_ctr)	        :=  i.old_attribute12;
2823       l_ext_attrib_hist_rec_tab.new_ext_attribute12(l_ctr)	        :=  i.new_attribute12;
2824       l_ext_attrib_hist_rec_tab.old_ext_attribute13(l_ctr)	        :=  i.old_attribute13;
2825       l_ext_attrib_hist_rec_tab.new_ext_attribute13(l_ctr)	        :=  i.new_attribute13;
2826       l_ext_attrib_hist_rec_tab.old_ext_attribute14(l_ctr)	        :=  i.old_attribute14;
2827       l_ext_attrib_hist_rec_tab.new_ext_attribute14(l_ctr)	        :=  i.new_attribute14;
2828       l_ext_attrib_hist_rec_tab.old_ext_attribute15(l_ctr)	        :=  i.old_attribute15;
2829       l_ext_attrib_hist_rec_tab.new_ext_attribute15(l_ctr)	        :=  i.new_attribute15;
2830       l_ext_attrib_hist_rec_tab.ext_full_dump_flag(l_ctr)	        :=  i.full_dump_flag;
2831       l_ext_attrib_hist_rec_tab.ext_created_by(l_ctr)               :=  i.created_by;
2832       l_ext_attrib_hist_rec_tab.ext_creation_date(l_ctr)            :=  i.creation_date;
2833       l_ext_attrib_hist_rec_tab.ext_last_updated_by(l_ctr)          :=  i.last_updated_by;
2834       l_ext_attrib_hist_rec_tab.ext_last_update_date(l_ctr)         :=  i.last_update_date;
2835       l_ext_attrib_hist_rec_tab.ext_last_update_login(l_ctr)        :=  i.last_update_login;
2836       l_ext_attrib_hist_rec_tab.ext_object_version_number(l_ctr)    :=  i.object_version_number;
2837       l_ext_attrib_hist_rec_tab.ext_security_group_id(l_ctr)	    :=  i.security_group_id;
2838       l_ext_attrib_hist_rec_tab.ext_migrated_flag(l_ctr)	        :=  i.migrated_flag;
2839 
2840 
2841    End Loop;
2842 
2843       -- get the party history count for the transaction range
2844       l_cnt := l_ext_attrib_hist_rec_tab.attribute_value_history_id.count;
2845       --
2846       Debug('');
2847       Debug('');
2848       Debug('Number of Extended Attributes history records archived:'||to_char(l_cnt));
2849       Debug('');
2850       Debug('');
2851       --
2852       If l_cnt > 0 Then
2853 
2854         FORALL i IN 1 .. l_cnt
2855 
2856          Insert Into CSI_HISTORY_ARCHIVE
2857          (
2858             HISTORY_ARCHIVE_ID
2859            ,OBJECT_ID
2860            ,ENTITY_HISTORY_ID
2861            ,TRANSACTION_ID
2862            ,ENTITY_ID
2863            ,COL_NUM_37
2864            ,COL_NUM_38
2865            ,COL_NUM_39
2866            ,COL_NUM_40
2867            ,COL_NUM_41
2868            ,COL_CHAR_01
2869            ,COL_CHAR_02
2870            ,COL_CHAR_31
2871            ,COL_CHAR_32
2872            ,COL_CHAR_33
2873            ,COL_CHAR_34
2874            ,COL_CHAR_35
2875            ,COL_CHAR_36
2876            ,COL_CHAR_37
2877            ,COL_CHAR_38
2878            ,COL_CHAR_39
2879            ,COL_CHAR_40
2880            ,COL_CHAR_41
2881            ,COL_CHAR_42
2882            ,COL_CHAR_43
2883            ,COL_CHAR_44
2884            ,COL_CHAR_45
2888            ,COL_CHAR_49
2885            ,COL_CHAR_46
2886            ,COL_CHAR_47
2887            ,COL_CHAR_48
2889            ,COL_CHAR_50
2890            ,COL_CHAR_51
2891            ,COL_CHAR_52
2892            ,COL_CHAR_53
2893            ,COL_CHAR_54
2894            ,COL_CHAR_55
2895            ,COL_CHAR_56
2896            ,COL_CHAR_57
2897            ,COL_CHAR_58
2898            ,COL_CHAR_59
2899            ,COL_CHAR_60
2900            ,COL_CHAR_61
2901            ,COL_CHAR_62
2902            ,COL_CHAR_71
2903            ,COL_CHAR_72
2904            ,COL_DATE_01
2905            ,COL_DATE_02
2906            ,COL_DATE_03
2907            ,COL_DATE_04
2908            ,COL_DATE_11
2909            ,COL_DATE_12
2910            ,CONTEXT
2911            ,ATTRIBUTE1
2912            ,ATTRIBUTE2
2913            ,ATTRIBUTE3
2914            ,ATTRIBUTE4
2915            ,ATTRIBUTE5
2916            ,ATTRIBUTE6
2917            ,ATTRIBUTE7
2918            ,ATTRIBUTE8
2919            ,ATTRIBUTE9
2920            ,ATTRIBUTE10
2921            ,ATTRIBUTE11
2922            ,ATTRIBUTE12
2923            ,ATTRIBUTE13
2924            ,ATTRIBUTE14
2925            ,ATTRIBUTE15
2926            ,CREATED_BY
2927            ,CREATION_DATE
2928            ,LAST_UPDATED_BY
2929            ,LAST_UPDATE_DATE
2930            ,LAST_UPDATE_LOGIN
2931            ,OBJECT_VERSION_NUMBER
2932            ,SECURITY_GROUP_ID
2933            )
2934            Values
2935            (
2936            l_archive_id_tbl(i),
2937            l_table_id,
2938            l_ext_attrib_hist_rec_tab.attribute_value_history_id(i),
2939            l_ext_attrib_hist_rec_tab.transaction_id(i),
2940            l_ext_attrib_hist_rec_tab.attribute_value_id(i),
2941            l_ext_attrib_hist_rec_tab.ext_created_by(i),
2942            l_ext_attrib_hist_rec_tab.ext_last_updated_by(i),
2943            l_ext_attrib_hist_rec_tab.ext_last_update_login(i),
2944            l_ext_attrib_hist_rec_tab.ext_object_version_number(i), -- obj_ver_num
2945            l_ext_attrib_hist_rec_tab.ext_security_group_id(i),
2946            l_ext_attrib_hist_rec_tab.old_attribute_value(i),
2947            l_ext_attrib_hist_rec_tab.new_attribute_value(i),
2948            l_ext_attrib_hist_rec_tab.old_ext_context(i),
2949            l_ext_attrib_hist_rec_tab.new_ext_context(i),
2950            l_ext_attrib_hist_rec_tab.old_ext_attribute1(i),
2951            l_ext_attrib_hist_rec_tab.new_ext_attribute1(i),
2952            l_ext_attrib_hist_rec_tab.old_ext_attribute2(i),
2953            l_ext_attrib_hist_rec_tab.new_ext_attribute2(i),
2954            l_ext_attrib_hist_rec_tab.old_ext_attribute3(i),
2955            l_ext_attrib_hist_rec_tab.new_ext_attribute3(i),
2956            l_ext_attrib_hist_rec_tab.old_ext_attribute4(i),
2957            l_ext_attrib_hist_rec_tab.new_ext_attribute4(i),
2958            l_ext_attrib_hist_rec_tab.old_ext_attribute5(i),
2959            l_ext_attrib_hist_rec_tab.new_ext_attribute5(i),
2960            l_ext_attrib_hist_rec_tab.old_ext_attribute6(i),
2961            l_ext_attrib_hist_rec_tab.new_ext_attribute6(i),
2962            l_ext_attrib_hist_rec_tab.old_ext_attribute7(i),
2963            l_ext_attrib_hist_rec_tab.new_ext_attribute7(i),
2964            l_ext_attrib_hist_rec_tab.old_ext_attribute8(i),
2965            l_ext_attrib_hist_rec_tab.new_ext_attribute8(i),
2966            l_ext_attrib_hist_rec_tab.old_ext_attribute9(i),
2967            l_ext_attrib_hist_rec_tab.new_ext_attribute9(i),
2968            l_ext_attrib_hist_rec_tab.old_ext_attribute10(i),
2969            l_ext_attrib_hist_rec_tab.new_ext_attribute10(i),
2970            l_ext_attrib_hist_rec_tab.old_ext_attribute11(i),
2971            l_ext_attrib_hist_rec_tab.new_ext_attribute11(i),
2972            l_ext_attrib_hist_rec_tab.old_ext_attribute12(i),
2973            l_ext_attrib_hist_rec_tab.new_ext_attribute12(i),
2974            l_ext_attrib_hist_rec_tab.old_ext_attribute13(i),
2975            l_ext_attrib_hist_rec_tab.new_ext_attribute13(i),
2976            l_ext_attrib_hist_rec_tab.old_ext_attribute14(i),
2977            l_ext_attrib_hist_rec_tab.new_ext_attribute14(i),
2978            l_ext_attrib_hist_rec_tab.old_ext_attribute15(i),
2979            l_ext_attrib_hist_rec_tab.new_ext_attribute15(i),
2980            l_ext_attrib_hist_rec_tab.ext_full_dump_flag(i), --'N', dump_flag
2981            l_ext_attrib_hist_rec_tab.ext_migrated_flag(i), -- mig_flag
2982            l_ext_attrib_hist_rec_tab.old_ext_active_start_date(i),
2983            l_ext_attrib_hist_rec_tab.new_ext_active_start_date(i),
2984            l_ext_attrib_hist_rec_tab.old_ext_active_end_date(i),
2985            l_ext_attrib_hist_rec_tab.new_ext_active_end_date(i),
2986            l_ext_attrib_hist_rec_tab.ext_creation_date(i),
2987            l_ext_attrib_hist_rec_tab.ext_last_update_date(i),
2988            null,
2989            null,
2990            null,
2991            null,
2992            null,
2993            null,
2994            null,
2995            null,
2996            null,
2997            null,
2998            null,
2999            null,
3000            null,
3001            null,
3002            null,
3003            null,
3004            l_user_id,
3005            sysdate,
3006            l_user_id,
3007            sysdate,
3008            l_login_id,
3009            1,
3010            null
3011            );
3012 
3013          -- Purge the corresonding Archive data from the Instance history tables
3017                Delete From CSI_IEA_VALUES_H
3014 
3015             FORALL i IN 1 .. l_cnt
3016 
3018                Where attribute_value_history_id = l_ext_attrib_hist_rec_tab.attribute_value_history_id(i);
3019 
3020        End If; -- if l_cnt > 0
3021        --
3022        Exit When from_trans = to_trans;
3023        Exit When v_end = to_trans;
3024 
3025      v_start := v_end + 1;
3026      v_end   := v_start + v_batch;
3027      --
3028      --
3029 	 If v_start > to_trans Then
3030 	    v_start := to_trans;
3031 	 End If;
3032 	 --
3033 	 If v_end > to_trans then
3034 	    v_end := to_trans;
3035 	 End If;
3036      --
3037      Commit;
3038      --
3039    Exception
3040       when others then
3041          Debug(substr(sqlerrm,1,255));
3042          ROLLBACK to Ext_Archive;
3043    End;
3044  End Loop; -- Local Batch Loop
3045  Commit;
3046    --
3047 END; -- Procedure ExtAttribs_Archive
3048 
3049 
3050 --
3051 -- This program is used to archive the Pricing Attribs history. It accepts from and to transactions
3052 -- as the input parameters.
3053 --
3054 
3055 PROCEDURE Pricing_archive( errbuf       OUT NOCOPY VARCHAR2,
3056                            retcode      OUT NOCOPY NUMBER,
3057                            from_trans   IN  NUMBER,
3058                            to_trans     IN  NUMBER,
3059                            purge_to_date IN VARCHAR2 )
3060 IS
3061 
3062     l_archive_id      NUMBER;
3063     l_ctr             NUMBER := 0;
3064     l_cnt             NUMBER;
3065     l_table_id        NUMBER;
3066     l_user_id         NUMBER := FND_GLOBAL.USER_ID;
3067     l_login_id        NUMBER := FND_GLOBAL.CONC_LOGIN_ID;
3068     v_batch           NUMBER := 15000;
3069     v_start           NUMBER;
3070     v_end             NUMBER;
3071 
3072     Type NUMLIST IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
3073     l_archive_id_tbl   NUMLIST;
3074 
3075     Cursor pri_attribs_hist_csr (p_from_trans IN NUMBER,
3076                                  p_to_trans   IN NUMBER) IS
3077     Select csh.*
3078     From   CSI_I_PRICING_ATTRIBS_H csh,
3079            CSI_TRANSACTIONS csit
3080     Where  csit.transaction_id between from_trans and to_trans
3081     And    csit.creation_date < to_date(purge_to_date, 'YYYY/MM/DD HH24:MI:SS')
3082     And    csh.transaction_id = csit.transaction_id;
3083 
3084     l_pri_attribs_hist_csr         pri_attribs_hist_csr%ROWTYPE;
3085     l_pri_attribs_hist_rec_tab     csi_txn_history_purge_pvt.pricing_attribs_hist_rec_tab;
3086 
3087 
3088 Begin
3089     --
3090     --
3091     Begin
3092       Select object_id
3093       Into   l_table_id
3094       From   csi_object_dictionary
3095       Where  object_name = 'CSI_I_PRICING_ATTRIBS_H';
3096     Exception
3097       When no_data_found Then
3098         l_table_id := 6;
3099       When others Then
3100         l_table_id := 6;
3101     End;
3102     --
3103     Begin
3104       Select fnd_profile.value('CSI_TXN_HISTORY_PURGE_BATCH_SIZE')
3105       Into   v_batch
3106       From   dual;
3107     Exception
3108       When no_data_found Then
3109         v_batch := 15000;
3110     End;
3111     --
3112     v_start := from_trans;
3113     v_end   := from_trans + v_batch;
3114     --
3115     If v_end > to_trans Then
3116        v_end := to_trans;
3117     End If;
3118     --
3119  Loop
3120    Begin
3121       SAVEPOINT Pricing_Archive;
3122       l_ctr := 0;
3123       --
3124       l_pri_attribs_hist_rec_tab.price_attrib_history_id.DELETE;
3125       l_pri_attribs_hist_rec_tab.pricing_attribute_id.DELETE;
3126       l_pri_attribs_hist_rec_tab.transaction_id.DELETE;
3127       l_pri_attribs_hist_rec_tab.old_pricing_context.DELETE;
3128       l_pri_attribs_hist_rec_tab.new_pricing_context.DELETE;
3132       l_pri_attribs_hist_rec_tab.new_pricing_attribute2.DELETE;
3129       l_pri_attribs_hist_rec_tab.old_pricing_attribute1.DELETE;
3130       l_pri_attribs_hist_rec_tab.new_pricing_attribute1.DELETE;
3131       l_pri_attribs_hist_rec_tab.old_pricing_attribute2.DELETE;
3133       l_pri_attribs_hist_rec_tab.old_pricing_attribute3.DELETE;
3134       l_pri_attribs_hist_rec_tab.new_pricing_attribute3.DELETE;
3135       l_pri_attribs_hist_rec_tab.old_pricing_attribute4.DELETE;
3136       l_pri_attribs_hist_rec_tab.new_pricing_attribute4.DELETE;
3137       l_pri_attribs_hist_rec_tab.old_pricing_attribute5.DELETE;
3138       l_pri_attribs_hist_rec_tab.new_pricing_attribute5.DELETE;
3139       l_pri_attribs_hist_rec_tab.old_pricing_attribute6.DELETE;
3140       l_pri_attribs_hist_rec_tab.new_pricing_attribute6.DELETE;
3141       l_pri_attribs_hist_rec_tab.old_pricing_attribute7.DELETE;
3142       l_pri_attribs_hist_rec_tab.new_pricing_attribute7.DELETE;
3143       l_pri_attribs_hist_rec_tab.old_pricing_attribute8.DELETE;
3144       l_pri_attribs_hist_rec_tab.new_pricing_attribute8.DELETE;
3145       l_pri_attribs_hist_rec_tab.old_pricing_attribute9.DELETE;
3146       l_pri_attribs_hist_rec_tab.new_pricing_attribute9.DELETE;
3147       l_pri_attribs_hist_rec_tab.old_pricing_attribute10.DELETE;
3148       l_pri_attribs_hist_rec_tab.new_pricing_attribute10.DELETE;
3149       l_pri_attribs_hist_rec_tab.old_pricing_attribute11.DELETE;
3150       l_pri_attribs_hist_rec_tab.new_pricing_attribute11.DELETE;
3151       l_pri_attribs_hist_rec_tab.old_pricing_attribute12.DELETE;
3152       l_pri_attribs_hist_rec_tab.new_pricing_attribute12.DELETE;
3153       l_pri_attribs_hist_rec_tab.old_pricing_attribute13.DELETE;
3154       l_pri_attribs_hist_rec_tab.new_pricing_attribute13.DELETE;
3155       l_pri_attribs_hist_rec_tab.old_pricing_attribute14.DELETE;
3156       l_pri_attribs_hist_rec_tab.new_pricing_attribute14.DELETE;
3157       l_pri_attribs_hist_rec_tab.old_pricing_attribute15.DELETE;
3158       l_pri_attribs_hist_rec_tab.new_pricing_attribute15.DELETE;
3159       l_pri_attribs_hist_rec_tab.old_pricing_attribute16.DELETE;
3160       l_pri_attribs_hist_rec_tab.new_pricing_attribute16.DELETE;
3161       l_pri_attribs_hist_rec_tab.old_pricing_attribute17.DELETE;
3162       l_pri_attribs_hist_rec_tab.new_pricing_attribute17.DELETE;
3163       l_pri_attribs_hist_rec_tab.old_pricing_attribute18.DELETE;
3164       l_pri_attribs_hist_rec_tab.new_pricing_attribute18.DELETE;
3165       l_pri_attribs_hist_rec_tab.old_pricing_attribute19.DELETE;
3166       l_pri_attribs_hist_rec_tab.new_pricing_attribute19.DELETE;
3167       l_pri_attribs_hist_rec_tab.old_pricing_attribute20.DELETE;
3168       l_pri_attribs_hist_rec_tab.new_pricing_attribute20.DELETE;
3169       l_pri_attribs_hist_rec_tab.old_pricing_attribute21.DELETE;
3170       l_pri_attribs_hist_rec_tab.new_pricing_attribute21.DELETE;
3171       l_pri_attribs_hist_rec_tab.old_pricing_attribute22.DELETE;
3172       l_pri_attribs_hist_rec_tab.new_pricing_attribute22.DELETE;
3173       l_pri_attribs_hist_rec_tab.old_pricing_attribute23.DELETE;
3174       l_pri_attribs_hist_rec_tab.new_pricing_attribute23.DELETE;
3175       l_pri_attribs_hist_rec_tab.old_pricing_attribute24.DELETE;
3176       l_pri_attribs_hist_rec_tab.new_pricing_attribute24.DELETE;
3177       l_pri_attribs_hist_rec_tab.old_pricing_attribute25.DELETE;
3178       l_pri_attribs_hist_rec_tab.new_pricing_attribute25.DELETE;
3179       l_pri_attribs_hist_rec_tab.old_pricing_attribute26.DELETE;
3180       l_pri_attribs_hist_rec_tab.new_pricing_attribute26.DELETE;
3181       l_pri_attribs_hist_rec_tab.old_pricing_attribute27.DELETE;
3182       l_pri_attribs_hist_rec_tab.new_pricing_attribute27.DELETE;
3183       l_pri_attribs_hist_rec_tab.old_pricing_attribute28.DELETE;
3184       l_pri_attribs_hist_rec_tab.new_pricing_attribute28.DELETE;
3185       l_pri_attribs_hist_rec_tab.old_pricing_attribute29.DELETE;
3186       l_pri_attribs_hist_rec_tab.new_pricing_attribute29.DELETE;
3187       l_pri_attribs_hist_rec_tab.old_pricing_attribute30.DELETE;
3188       l_pri_attribs_hist_rec_tab.new_pricing_attribute30.DELETE;
3189       l_pri_attribs_hist_rec_tab.old_pricing_attribute31.DELETE;
3190       l_pri_attribs_hist_rec_tab.new_pricing_attribute31.DELETE;
3191       l_pri_attribs_hist_rec_tab.old_pricing_attribute32.DELETE;
3192       l_pri_attribs_hist_rec_tab.new_pricing_attribute32.DELETE;
3193       l_pri_attribs_hist_rec_tab.old_pricing_attribute33.DELETE;
3194       l_pri_attribs_hist_rec_tab.new_pricing_attribute33.DELETE;
3195       l_pri_attribs_hist_rec_tab.old_pricing_attribute34.DELETE;
3196       l_pri_attribs_hist_rec_tab.new_pricing_attribute34.DELETE;
3197       l_pri_attribs_hist_rec_tab.old_pricing_attribute35.DELETE;
3198       l_pri_attribs_hist_rec_tab.new_pricing_attribute35.DELETE;
3199       l_pri_attribs_hist_rec_tab.old_pricing_attribute36.DELETE;
3200       l_pri_attribs_hist_rec_tab.new_pricing_attribute36.DELETE;
3201       l_pri_attribs_hist_rec_tab.old_pricing_attribute37.DELETE;
3202       l_pri_attribs_hist_rec_tab.new_pricing_attribute37.DELETE;
3203       l_pri_attribs_hist_rec_tab.old_pricing_attribute38.DELETE;
3204       l_pri_attribs_hist_rec_tab.new_pricing_attribute38.DELETE;
3205       l_pri_attribs_hist_rec_tab.old_pricing_attribute39.DELETE;
3206       l_pri_attribs_hist_rec_tab.new_pricing_attribute39.DELETE;
3207       l_pri_attribs_hist_rec_tab.old_pricing_attribute40.DELETE;
3208       l_pri_attribs_hist_rec_tab.new_pricing_attribute40.DELETE;
3209       l_pri_attribs_hist_rec_tab.old_pricing_attribute41.DELETE;
3210       l_pri_attribs_hist_rec_tab.new_pricing_attribute41.DELETE;
3211       l_pri_attribs_hist_rec_tab.old_pricing_attribute42.DELETE;
3212       l_pri_attribs_hist_rec_tab.new_pricing_attribute42.DELETE;
3213       l_pri_attribs_hist_rec_tab.old_pricing_attribute43.DELETE;
3214       l_pri_attribs_hist_rec_tab.new_pricing_attribute43.DELETE;
3215       l_pri_attribs_hist_rec_tab.old_pricing_attribute44.DELETE;
3216       l_pri_attribs_hist_rec_tab.new_pricing_attribute44.DELETE;
3217       l_pri_attribs_hist_rec_tab.old_pricing_attribute45.DELETE;
3218       l_pri_attribs_hist_rec_tab.new_pricing_attribute45.DELETE;
3219       l_pri_attribs_hist_rec_tab.old_pricing_attribute46.DELETE;
3220       l_pri_attribs_hist_rec_tab.new_pricing_attribute46.DELETE;
3221       l_pri_attribs_hist_rec_tab.old_pricing_attribute47.DELETE;
3222       l_pri_attribs_hist_rec_tab.new_pricing_attribute47.DELETE;
3223       l_pri_attribs_hist_rec_tab.old_pricing_attribute48.DELETE;
3224       l_pri_attribs_hist_rec_tab.new_pricing_attribute48.DELETE;
3225       l_pri_attribs_hist_rec_tab.old_pricing_attribute49.DELETE;
3226       l_pri_attribs_hist_rec_tab.new_pricing_attribute49.DELETE;
3227       l_pri_attribs_hist_rec_tab.old_pricing_attribute50.DELETE;
3228       l_pri_attribs_hist_rec_tab.new_pricing_attribute50.DELETE;
3229       l_pri_attribs_hist_rec_tab.old_pricing_attribute51.DELETE;
3230       l_pri_attribs_hist_rec_tab.new_pricing_attribute51.DELETE;
3231       l_pri_attribs_hist_rec_tab.old_pricing_attribute52.DELETE;
3232       l_pri_attribs_hist_rec_tab.new_pricing_attribute52.DELETE;
3233       l_pri_attribs_hist_rec_tab.old_pricing_attribute53.DELETE;
3234       l_pri_attribs_hist_rec_tab.new_pricing_attribute53.DELETE;
3235       l_pri_attribs_hist_rec_tab.old_pricing_attribute54.DELETE;
3236       l_pri_attribs_hist_rec_tab.new_pricing_attribute54.DELETE;
3237       l_pri_attribs_hist_rec_tab.old_pricing_attribute55.DELETE;
3238       l_pri_attribs_hist_rec_tab.new_pricing_attribute55.DELETE;
3239       l_pri_attribs_hist_rec_tab.old_pricing_attribute56.DELETE;
3240       l_pri_attribs_hist_rec_tab.new_pricing_attribute56.DELETE;
3241       l_pri_attribs_hist_rec_tab.old_pricing_attribute57.DELETE;
3242       l_pri_attribs_hist_rec_tab.new_pricing_attribute57.DELETE;
3243       l_pri_attribs_hist_rec_tab.old_pricing_attribute58.DELETE;
3244       l_pri_attribs_hist_rec_tab.new_pricing_attribute58.DELETE;
3245       l_pri_attribs_hist_rec_tab.old_pricing_attribute59.DELETE;
3246       l_pri_attribs_hist_rec_tab.new_pricing_attribute59.DELETE;
3247       l_pri_attribs_hist_rec_tab.old_pricing_attribute60.DELETE;
3248       l_pri_attribs_hist_rec_tab.new_pricing_attribute60.DELETE;
3249       l_pri_attribs_hist_rec_tab.old_pricing_attribute61.DELETE;
3250       l_pri_attribs_hist_rec_tab.new_pricing_attribute61.DELETE;
3251       l_pri_attribs_hist_rec_tab.old_pricing_attribute62.DELETE;
3252       l_pri_attribs_hist_rec_tab.new_pricing_attribute62.DELETE;
3253       l_pri_attribs_hist_rec_tab.old_pricing_attribute63.DELETE;
3254       l_pri_attribs_hist_rec_tab.new_pricing_attribute63.DELETE;
3255       l_pri_attribs_hist_rec_tab.old_pricing_attribute64.DELETE;
3256       l_pri_attribs_hist_rec_tab.new_pricing_attribute64.DELETE;
3257       l_pri_attribs_hist_rec_tab.old_pricing_attribute65.DELETE;
3258       l_pri_attribs_hist_rec_tab.new_pricing_attribute65.DELETE;
3259       l_pri_attribs_hist_rec_tab.old_pricing_attribute66.DELETE;
3260       l_pri_attribs_hist_rec_tab.new_pricing_attribute66.DELETE;
3261       l_pri_attribs_hist_rec_tab.old_pricing_attribute67.DELETE;
3262       l_pri_attribs_hist_rec_tab.new_pricing_attribute67.DELETE;
3263       l_pri_attribs_hist_rec_tab.old_pricing_attribute68.DELETE;
3264       l_pri_attribs_hist_rec_tab.new_pricing_attribute68.DELETE;
3265       l_pri_attribs_hist_rec_tab.old_pricing_attribute69.DELETE;
3266       l_pri_attribs_hist_rec_tab.new_pricing_attribute69.DELETE;
3267       l_pri_attribs_hist_rec_tab.old_pricing_attribute70.DELETE;
3268       l_pri_attribs_hist_rec_tab.new_pricing_attribute70.DELETE;
3269       l_pri_attribs_hist_rec_tab.old_pricing_attribute71.DELETE;
3270       l_pri_attribs_hist_rec_tab.new_pricing_attribute71.DELETE;
3271       l_pri_attribs_hist_rec_tab.old_pricing_attribute72.DELETE;
3272       l_pri_attribs_hist_rec_tab.new_pricing_attribute72.DELETE;
3273       l_pri_attribs_hist_rec_tab.old_pricing_attribute73.DELETE;
3274       l_pri_attribs_hist_rec_tab.new_pricing_attribute73.DELETE;
3275       l_pri_attribs_hist_rec_tab.old_pricing_attribute74.DELETE;
3276       l_pri_attribs_hist_rec_tab.new_pricing_attribute74.DELETE;
3277       l_pri_attribs_hist_rec_tab.old_pricing_attribute75.DELETE;
3278       l_pri_attribs_hist_rec_tab.new_pricing_attribute75.DELETE;
3279       l_pri_attribs_hist_rec_tab.old_pricing_attribute76.DELETE;
3280       l_pri_attribs_hist_rec_tab.new_pricing_attribute76.DELETE;
3281       l_pri_attribs_hist_rec_tab.old_pricing_attribute77.DELETE;
3282       l_pri_attribs_hist_rec_tab.new_pricing_attribute77.DELETE;
3283       l_pri_attribs_hist_rec_tab.old_pricing_attribute78.DELETE;
3287       l_pri_attribs_hist_rec_tab.old_pricing_attribute80.DELETE;
3284       l_pri_attribs_hist_rec_tab.new_pricing_attribute78.DELETE;
3285       l_pri_attribs_hist_rec_tab.old_pricing_attribute79.DELETE;
3286       l_pri_attribs_hist_rec_tab.new_pricing_attribute79.DELETE;
3288       l_pri_attribs_hist_rec_tab.new_pricing_attribute80.DELETE;
3289       l_pri_attribs_hist_rec_tab.old_pricing_attribute81.DELETE;
3290       l_pri_attribs_hist_rec_tab.new_pricing_attribute81.DELETE;
3291       l_pri_attribs_hist_rec_tab.old_pricing_attribute82.DELETE;
3292       l_pri_attribs_hist_rec_tab.new_pricing_attribute82.DELETE;
3293       l_pri_attribs_hist_rec_tab.old_pricing_attribute83.DELETE;
3294       l_pri_attribs_hist_rec_tab.new_pricing_attribute83.DELETE;
3295       l_pri_attribs_hist_rec_tab.old_pricing_attribute84.DELETE;
3296       l_pri_attribs_hist_rec_tab.new_pricing_attribute84.DELETE;
3297       l_pri_attribs_hist_rec_tab.old_pricing_attribute85.DELETE;
3298       l_pri_attribs_hist_rec_tab.new_pricing_attribute85.DELETE;
3299       l_pri_attribs_hist_rec_tab.old_pricing_attribute86.DELETE;
3300       l_pri_attribs_hist_rec_tab.new_pricing_attribute86.DELETE;
3301       l_pri_attribs_hist_rec_tab.old_pricing_attribute87.DELETE;
3302       l_pri_attribs_hist_rec_tab.new_pricing_attribute87.DELETE;
3303       l_pri_attribs_hist_rec_tab.old_pricing_attribute88.DELETE;
3304       l_pri_attribs_hist_rec_tab.new_pricing_attribute88.DELETE;
3305       l_pri_attribs_hist_rec_tab.old_pricing_attribute89.DELETE;
3306       l_pri_attribs_hist_rec_tab.new_pricing_attribute89.DELETE;
3307       l_pri_attribs_hist_rec_tab.old_pricing_attribute90.DELETE;
3308       l_pri_attribs_hist_rec_tab.new_pricing_attribute90.DELETE;
3309       l_pri_attribs_hist_rec_tab.old_pricing_attribute91.DELETE;
3310       l_pri_attribs_hist_rec_tab.new_pricing_attribute91.DELETE;
3311       l_pri_attribs_hist_rec_tab.old_pricing_attribute92.DELETE;
3312       l_pri_attribs_hist_rec_tab.new_pricing_attribute92.DELETE;
3313       l_pri_attribs_hist_rec_tab.old_pricing_attribute93.DELETE;
3314       l_pri_attribs_hist_rec_tab.new_pricing_attribute93.DELETE;
3315       l_pri_attribs_hist_rec_tab.old_pricing_attribute94.DELETE;
3316       l_pri_attribs_hist_rec_tab.new_pricing_attribute94.DELETE;
3317       l_pri_attribs_hist_rec_tab.old_pricing_attribute95.DELETE;
3318       l_pri_attribs_hist_rec_tab.new_pricing_attribute95.DELETE;
3319       l_pri_attribs_hist_rec_tab.old_pricing_attribute96.DELETE;
3320       l_pri_attribs_hist_rec_tab.new_pricing_attribute96.DELETE;
3321       l_pri_attribs_hist_rec_tab.old_pricing_attribute97.DELETE;
3322       l_pri_attribs_hist_rec_tab.new_pricing_attribute97.DELETE;
3323       l_pri_attribs_hist_rec_tab.old_pricing_attribute98.DELETE;
3324       l_pri_attribs_hist_rec_tab.new_pricing_attribute98.DELETE;
3325       l_pri_attribs_hist_rec_tab.old_pricing_attribute99.DELETE;
3326       l_pri_attribs_hist_rec_tab.new_pricing_attribute99.DELETE;
3327       l_pri_attribs_hist_rec_tab.old_pricing_attribute100.DELETE;
3328       l_pri_attribs_hist_rec_tab.new_pricing_attribute100.DELETE;
3329       l_pri_attribs_hist_rec_tab.old_pri_active_start_date.DELETE;
3330       l_pri_attribs_hist_rec_tab.new_pri_active_start_date.DELETE;
3331       l_pri_attribs_hist_rec_tab.old_pri_active_end_date.DELETE;
3332       l_pri_attribs_hist_rec_tab.new_pri_active_end_date.DELETE;
3333       l_pri_attribs_hist_rec_tab.old_pri_context.DELETE;
3334       l_pri_attribs_hist_rec_tab.new_pri_context.DELETE;
3335       l_pri_attribs_hist_rec_tab.old_pri_attribute1.DELETE;
3336       l_pri_attribs_hist_rec_tab.new_pri_attribute1.DELETE;
3337       l_pri_attribs_hist_rec_tab.old_pri_attribute2.DELETE;
3338       l_pri_attribs_hist_rec_tab.new_pri_attribute2.DELETE;
3339       l_pri_attribs_hist_rec_tab.old_pri_attribute3.DELETE;
3340       l_pri_attribs_hist_rec_tab.new_pri_attribute3.DELETE;
3341       l_pri_attribs_hist_rec_tab.old_pri_attribute4.DELETE;
3342       l_pri_attribs_hist_rec_tab.new_pri_attribute4.DELETE;
3343       l_pri_attribs_hist_rec_tab.old_pri_attribute5.DELETE;
3344       l_pri_attribs_hist_rec_tab.new_pri_attribute5.DELETE;
3345       l_pri_attribs_hist_rec_tab.old_pri_attribute6.DELETE;
3346       l_pri_attribs_hist_rec_tab.new_pri_attribute6.DELETE;
3347       l_pri_attribs_hist_rec_tab.old_pri_attribute7.DELETE;
3348       l_pri_attribs_hist_rec_tab.new_pri_attribute7.DELETE;
3349       l_pri_attribs_hist_rec_tab.old_pri_attribute8.DELETE;
3350       l_pri_attribs_hist_rec_tab.new_pri_attribute8.DELETE;
3351       l_pri_attribs_hist_rec_tab.old_pri_attribute9.DELETE;
3352       l_pri_attribs_hist_rec_tab.new_pri_attribute9.DELETE;
3353       l_pri_attribs_hist_rec_tab.old_pri_attribute10.DELETE;
3354       l_pri_attribs_hist_rec_tab.new_pri_attribute10.DELETE;
3355       l_pri_attribs_hist_rec_tab.old_pri_attribute11.DELETE;
3356       l_pri_attribs_hist_rec_tab.new_pri_attribute11.DELETE;
3357       l_pri_attribs_hist_rec_tab.old_pri_attribute12.DELETE;
3358       l_pri_attribs_hist_rec_tab.new_pri_attribute12.DELETE;
3359       l_pri_attribs_hist_rec_tab.old_pri_attribute13.DELETE;
3360       l_pri_attribs_hist_rec_tab.new_pri_attribute13.DELETE;
3361       l_pri_attribs_hist_rec_tab.old_pri_attribute14.DELETE;
3362       l_pri_attribs_hist_rec_tab.new_pri_attribute14.DELETE;
3363       l_pri_attribs_hist_rec_tab.old_pri_attribute15.DELETE;
3364       l_pri_attribs_hist_rec_tab.new_pri_attribute15.DELETE;
3365       l_pri_attribs_hist_rec_tab.pri_full_dump_flag.DELETE;
3366       l_pri_attribs_hist_rec_tab.pri_created_by.DELETE;
3367       l_pri_attribs_hist_rec_tab.pri_creation_date.DELETE;
3368       l_pri_attribs_hist_rec_tab.pri_last_updated_by.DELETE;
3369       l_pri_attribs_hist_rec_tab.pri_last_update_date.DELETE;
3370       l_pri_attribs_hist_rec_tab.pri_last_update_login.DELETE;
3374       --
3371       l_pri_attribs_hist_rec_tab.pri_object_version_number.DELETE;
3372       l_pri_attribs_hist_rec_tab.pri_security_group_id.DELETE;
3373       l_pri_attribs_hist_rec_tab.pri_migrated_flag.DELETE;
3375 
3376   For i in pri_attribs_hist_csr(v_start,v_end)
3377   Loop
3378       --
3379       l_ctr := l_ctr + 1;
3380       --
3381       Select csi_history_archive_s.Nextval
3382       Into l_archive_id_tbl(l_ctr)
3383       From dual;
3384       --
3385       l_pri_attribs_hist_rec_tab.price_attrib_history_id(l_ctr)           :=  i.price_attrib_history_id;
3386       l_pri_attribs_hist_rec_tab.pricing_attribute_id(l_ctr)              :=  i.pricing_attribute_id;
3387       l_pri_attribs_hist_rec_tab.transaction_id(l_ctr)                    :=  i.transaction_id;
3388       l_pri_attribs_hist_rec_tab.old_pricing_context(l_ctr)               :=  i.old_pricing_context;
3389       l_pri_attribs_hist_rec_tab.new_pricing_context(l_ctr)               :=  i.new_pricing_context;
3390       l_pri_attribs_hist_rec_tab.old_pricing_attribute1(l_ctr)            :=  i.old_pricing_attribute1;
3391       l_pri_attribs_hist_rec_tab.new_pricing_attribute1(l_ctr)            :=  i.new_pricing_attribute1;
3392       l_pri_attribs_hist_rec_tab.old_pricing_attribute2(l_ctr)            :=  i.old_pricing_attribute2;
3393       l_pri_attribs_hist_rec_tab.new_pricing_attribute2(l_ctr)            :=  i.new_pricing_attribute2;
3394       l_pri_attribs_hist_rec_tab.old_pricing_attribute3(l_ctr)            :=  i.old_pricing_attribute3;
3395       l_pri_attribs_hist_rec_tab.new_pricing_attribute3(l_ctr)            :=  i.new_pricing_attribute3;
3396       l_pri_attribs_hist_rec_tab.old_pricing_attribute4(l_ctr)            :=  i.old_pricing_attribute4;
3397       l_pri_attribs_hist_rec_tab.new_pricing_attribute4(l_ctr)            :=  i.new_pricing_attribute4;
3398       l_pri_attribs_hist_rec_tab.old_pricing_attribute5(l_ctr)            :=  i.old_pricing_attribute5;
3399       l_pri_attribs_hist_rec_tab.new_pricing_attribute5(l_ctr)            :=  i.new_pricing_attribute5;
3400       l_pri_attribs_hist_rec_tab.old_pricing_attribute6(l_ctr)            :=  i.old_pricing_attribute6;
3401       l_pri_attribs_hist_rec_tab.new_pricing_attribute6(l_ctr)            :=  i.new_pricing_attribute6;
3402       l_pri_attribs_hist_rec_tab.old_pricing_attribute7(l_ctr)            :=  i.old_pricing_attribute7;
3403       l_pri_attribs_hist_rec_tab.new_pricing_attribute7(l_ctr)            :=  i.new_pricing_attribute7;
3404       l_pri_attribs_hist_rec_tab.old_pricing_attribute8(l_ctr)            :=  i.old_pricing_attribute8;
3405       l_pri_attribs_hist_rec_tab.new_pricing_attribute8(l_ctr)            :=  i.new_pricing_attribute8;
3406       l_pri_attribs_hist_rec_tab.old_pricing_attribute9(l_ctr)            :=  i.old_pricing_attribute9;
3407       l_pri_attribs_hist_rec_tab.new_pricing_attribute9(l_ctr)            :=  i.new_pricing_attribute9;
3408       l_pri_attribs_hist_rec_tab.old_pricing_attribute10(l_ctr)           :=  i.old_pricing_attribute10;
3409       l_pri_attribs_hist_rec_tab.new_pricing_attribute10(l_ctr)           :=  i.new_pricing_attribute10;
3410       l_pri_attribs_hist_rec_tab.old_pricing_attribute11(l_ctr)           :=  i.old_pricing_attribute11;
3411       l_pri_attribs_hist_rec_tab.new_pricing_attribute11(l_ctr)           :=  i.new_pricing_attribute11;
3412       l_pri_attribs_hist_rec_tab.old_pricing_attribute12(l_ctr)           :=  i.old_pricing_attribute12;
3413       l_pri_attribs_hist_rec_tab.new_pricing_attribute12(l_ctr)           :=  i.new_pricing_attribute12;
3414       l_pri_attribs_hist_rec_tab.old_pricing_attribute13(l_ctr)           :=  i.old_pricing_attribute13;
3415       l_pri_attribs_hist_rec_tab.new_pricing_attribute13(l_ctr)           :=  i.new_pricing_attribute13;
3416       l_pri_attribs_hist_rec_tab.old_pricing_attribute14(l_ctr)           :=  i.old_pricing_attribute14;
3417       l_pri_attribs_hist_rec_tab.new_pricing_attribute14(l_ctr)           :=  i.new_pricing_attribute14;
3418       l_pri_attribs_hist_rec_tab.old_pricing_attribute15(l_ctr)           :=  i.old_pricing_attribute15;
3419       l_pri_attribs_hist_rec_tab.new_pricing_attribute15(l_ctr)           :=  i.new_pricing_attribute15;
3420       l_pri_attribs_hist_rec_tab.old_pricing_attribute16(l_ctr)           :=  i.old_pricing_attribute16;
3421       l_pri_attribs_hist_rec_tab.new_pricing_attribute16(l_ctr)           :=  i.new_pricing_attribute16;
3422       l_pri_attribs_hist_rec_tab.old_pricing_attribute17(l_ctr)           :=  i.old_pricing_attribute17;
3423       l_pri_attribs_hist_rec_tab.new_pricing_attribute17(l_ctr)           :=  i.new_pricing_attribute17;
3424       l_pri_attribs_hist_rec_tab.old_pricing_attribute18(l_ctr)           :=  i.old_pricing_attribute18;
3425       l_pri_attribs_hist_rec_tab.new_pricing_attribute18(l_ctr)           :=  i.new_pricing_attribute18;
3426       l_pri_attribs_hist_rec_tab.old_pricing_attribute19(l_ctr)           :=  i.old_pricing_attribute19;
3427       l_pri_attribs_hist_rec_tab.new_pricing_attribute19(l_ctr)           :=  i.new_pricing_attribute19;
3428       l_pri_attribs_hist_rec_tab.old_pricing_attribute20(l_ctr)           :=  i.old_pricing_attribute20;
3429       l_pri_attribs_hist_rec_tab.new_pricing_attribute20(l_ctr)           :=  i.new_pricing_attribute20;
3430       l_pri_attribs_hist_rec_tab.old_pricing_attribute21(l_ctr)           :=  i.old_pricing_attribute21;
3431       l_pri_attribs_hist_rec_tab.new_pricing_attribute21(l_ctr)           :=  i.new_pricing_attribute21;
3432       l_pri_attribs_hist_rec_tab.old_pricing_attribute22(l_ctr)           :=  i.old_pricing_attribute22;
3433       l_pri_attribs_hist_rec_tab.new_pricing_attribute22(l_ctr)           :=  i.new_pricing_attribute22;
3434       l_pri_attribs_hist_rec_tab.old_pricing_attribute23(l_ctr)           :=  i.old_pricing_attribute23;
3435       l_pri_attribs_hist_rec_tab.new_pricing_attribute23(l_ctr)           :=  i.new_pricing_attribute23;
3436       l_pri_attribs_hist_rec_tab.old_pricing_attribute24(l_ctr)           :=  i.old_pricing_attribute24;
3437       l_pri_attribs_hist_rec_tab.new_pricing_attribute24(l_ctr)           :=  i.new_pricing_attribute24;
3441       l_pri_attribs_hist_rec_tab.new_pricing_attribute26(l_ctr)           :=  i.new_pricing_attribute26;
3438       l_pri_attribs_hist_rec_tab.old_pricing_attribute25(l_ctr)           :=  i.old_pricing_attribute25;
3439       l_pri_attribs_hist_rec_tab.new_pricing_attribute25(l_ctr)           :=  i.new_pricing_attribute25;
3440       l_pri_attribs_hist_rec_tab.old_pricing_attribute26(l_ctr)           :=  i.old_pricing_attribute26;
3442       l_pri_attribs_hist_rec_tab.old_pricing_attribute27(l_ctr)           :=  i.old_pricing_attribute27;
3443       l_pri_attribs_hist_rec_tab.new_pricing_attribute27(l_ctr)           :=  i.new_pricing_attribute27;
3444       l_pri_attribs_hist_rec_tab.old_pricing_attribute28(l_ctr)           :=  i.old_pricing_attribute28;
3445       l_pri_attribs_hist_rec_tab.new_pricing_attribute28(l_ctr)           :=  i.new_pricing_attribute28;
3446       l_pri_attribs_hist_rec_tab.old_pricing_attribute29(l_ctr)           :=  i.old_pricing_attribute29;
3447       l_pri_attribs_hist_rec_tab.new_pricing_attribute29(l_ctr)           :=  i.new_pricing_attribute29;
3448       l_pri_attribs_hist_rec_tab.old_pricing_attribute30(l_ctr)           :=  i.old_pricing_attribute30;
3449       l_pri_attribs_hist_rec_tab.new_pricing_attribute30(l_ctr)           :=  i.new_pricing_attribute30;
3450       l_pri_attribs_hist_rec_tab.old_pricing_attribute31(l_ctr)           :=  i.old_pricing_attribute31;
3451       l_pri_attribs_hist_rec_tab.new_pricing_attribute31(l_ctr)           :=  i.new_pricing_attribute31;
3452       l_pri_attribs_hist_rec_tab.old_pricing_attribute32(l_ctr)           :=  i.old_pricing_attribute32;
3453       l_pri_attribs_hist_rec_tab.new_pricing_attribute32(l_ctr)           :=  i.new_pricing_attribute32;
3454       l_pri_attribs_hist_rec_tab.old_pricing_attribute33(l_ctr)           :=  i.old_pricing_attribute33;
3455       l_pri_attribs_hist_rec_tab.new_pricing_attribute33(l_ctr)           :=  i.new_pricing_attribute33;
3456       l_pri_attribs_hist_rec_tab.old_pricing_attribute34(l_ctr)           :=  i.old_pricing_attribute34;
3457       l_pri_attribs_hist_rec_tab.new_pricing_attribute34(l_ctr)           :=  i.new_pricing_attribute34;
3458       l_pri_attribs_hist_rec_tab.old_pricing_attribute35(l_ctr)           :=  i.old_pricing_attribute35;
3459       l_pri_attribs_hist_rec_tab.new_pricing_attribute35(l_ctr)           :=  i.new_pricing_attribute35;
3460       l_pri_attribs_hist_rec_tab.old_pricing_attribute36(l_ctr)           :=  i.old_pricing_attribute36;
3461       l_pri_attribs_hist_rec_tab.new_pricing_attribute36(l_ctr)           :=  i.new_pricing_attribute36;
3462       l_pri_attribs_hist_rec_tab.old_pricing_attribute37(l_ctr)           :=  i.old_pricing_attribute37;
3463       l_pri_attribs_hist_rec_tab.new_pricing_attribute37(l_ctr)           :=  i.new_pricing_attribute37;
3464       l_pri_attribs_hist_rec_tab.old_pricing_attribute38(l_ctr)           :=  i.old_pricing_attribute38;
3465       l_pri_attribs_hist_rec_tab.new_pricing_attribute38(l_ctr)           :=  i.new_pricing_attribute38;
3466       l_pri_attribs_hist_rec_tab.old_pricing_attribute39(l_ctr)           :=  i.old_pricing_attribute39;
3467       l_pri_attribs_hist_rec_tab.new_pricing_attribute39(l_ctr)           :=  i.new_pricing_attribute39;
3468       l_pri_attribs_hist_rec_tab.old_pricing_attribute40(l_ctr)           :=  i.old_pricing_attribute40;
3469       l_pri_attribs_hist_rec_tab.new_pricing_attribute40(l_ctr)           :=  i.new_pricing_attribute40;
3470       l_pri_attribs_hist_rec_tab.old_pricing_attribute41(l_ctr)           :=  i.old_pricing_attribute41;
3471       l_pri_attribs_hist_rec_tab.new_pricing_attribute41(l_ctr)           :=  i.new_pricing_attribute41;
3472       l_pri_attribs_hist_rec_tab.old_pricing_attribute42(l_ctr)           :=  i.old_pricing_attribute42;
3473       l_pri_attribs_hist_rec_tab.new_pricing_attribute42(l_ctr)           :=  i.new_pricing_attribute42;
3474       l_pri_attribs_hist_rec_tab.old_pricing_attribute43(l_ctr)           :=  i.old_pricing_attribute43;
3475       l_pri_attribs_hist_rec_tab.new_pricing_attribute43(l_ctr)           :=  i.new_pricing_attribute43;
3476       l_pri_attribs_hist_rec_tab.old_pricing_attribute44(l_ctr)           :=  i.old_pricing_attribute44;
3477       l_pri_attribs_hist_rec_tab.new_pricing_attribute44(l_ctr)           :=  i.new_pricing_attribute44;
3478       l_pri_attribs_hist_rec_tab.old_pricing_attribute45(l_ctr)           :=  i.old_pricing_attribute45;
3479       l_pri_attribs_hist_rec_tab.new_pricing_attribute45(l_ctr)           :=  i.new_pricing_attribute45;
3480       l_pri_attribs_hist_rec_tab.old_pricing_attribute46(l_ctr)           :=  i.old_pricing_attribute46;
3481       l_pri_attribs_hist_rec_tab.new_pricing_attribute46(l_ctr)           :=  i.new_pricing_attribute46;
3482       l_pri_attribs_hist_rec_tab.old_pricing_attribute47(l_ctr)           :=  i.old_pricing_attribute47;
3483       l_pri_attribs_hist_rec_tab.new_pricing_attribute47(l_ctr)           :=  i.new_pricing_attribute47;
3484       l_pri_attribs_hist_rec_tab.old_pricing_attribute48(l_ctr)           :=  i.old_pricing_attribute48;
3485       l_pri_attribs_hist_rec_tab.new_pricing_attribute48(l_ctr)           :=  i.new_pricing_attribute48;
3486       l_pri_attribs_hist_rec_tab.old_pricing_attribute49(l_ctr)           :=  i.old_pricing_attribute49;
3487       l_pri_attribs_hist_rec_tab.new_pricing_attribute49(l_ctr)           :=  i.new_pricing_attribute49;
3488       l_pri_attribs_hist_rec_tab.old_pricing_attribute50(l_ctr)           :=  i.old_pricing_attribute50;
3489       l_pri_attribs_hist_rec_tab.new_pricing_attribute50(l_ctr)           :=  i.new_pricing_attribute50;
3490       l_pri_attribs_hist_rec_tab.old_pricing_attribute51(l_ctr)           :=  i.old_pricing_attribute51;
3491       l_pri_attribs_hist_rec_tab.new_pricing_attribute51(l_ctr)           :=  i.new_pricing_attribute51;
3492       l_pri_attribs_hist_rec_tab.old_pricing_attribute52(l_ctr)           :=  i.old_pricing_attribute52;
3493       l_pri_attribs_hist_rec_tab.new_pricing_attribute52(l_ctr)           :=  i.new_pricing_attribute52;
3497       l_pri_attribs_hist_rec_tab.new_pricing_attribute54(l_ctr)           :=  i.new_pricing_attribute54;
3494       l_pri_attribs_hist_rec_tab.old_pricing_attribute53(l_ctr)           :=  i.old_pricing_attribute53;
3495       l_pri_attribs_hist_rec_tab.new_pricing_attribute53(l_ctr)           :=  i.new_pricing_attribute53;
3496       l_pri_attribs_hist_rec_tab.old_pricing_attribute54(l_ctr)           :=  i.old_pricing_attribute54;
3498       l_pri_attribs_hist_rec_tab.old_pricing_attribute55(l_ctr)           :=  i.old_pricing_attribute55;
3499       l_pri_attribs_hist_rec_tab.new_pricing_attribute55(l_ctr)           :=  i.new_pricing_attribute55;
3500       l_pri_attribs_hist_rec_tab.old_pricing_attribute56(l_ctr)           :=  i.old_pricing_attribute56;
3501       l_pri_attribs_hist_rec_tab.new_pricing_attribute56(l_ctr)           :=  i.new_pricing_attribute56;
3502       l_pri_attribs_hist_rec_tab.old_pricing_attribute57(l_ctr)           :=  i.old_pricing_attribute57;
3503       l_pri_attribs_hist_rec_tab.new_pricing_attribute57(l_ctr)           :=  i.new_pricing_attribute57;
3504       l_pri_attribs_hist_rec_tab.old_pricing_attribute58(l_ctr)           :=  i.old_pricing_attribute58;
3505       l_pri_attribs_hist_rec_tab.new_pricing_attribute58(l_ctr)           :=  i.new_pricing_attribute58;
3506       l_pri_attribs_hist_rec_tab.old_pricing_attribute59(l_ctr)           :=  i.old_pricing_attribute59;
3507       l_pri_attribs_hist_rec_tab.new_pricing_attribute59(l_ctr)           :=  i.new_pricing_attribute59;
3508       l_pri_attribs_hist_rec_tab.old_pricing_attribute60(l_ctr)           :=  i.old_pricing_attribute60;
3509       l_pri_attribs_hist_rec_tab.new_pricing_attribute60(l_ctr)           :=  i.new_pricing_attribute60;
3510       l_pri_attribs_hist_rec_tab.old_pricing_attribute61(l_ctr)           :=  i.old_pricing_attribute61;
3511       l_pri_attribs_hist_rec_tab.new_pricing_attribute61(l_ctr)           :=  i.new_pricing_attribute61;
3512       l_pri_attribs_hist_rec_tab.old_pricing_attribute62(l_ctr)           :=  i.old_pricing_attribute62;
3513       l_pri_attribs_hist_rec_tab.new_pricing_attribute62(l_ctr)           :=  i.new_pricing_attribute62;
3514       l_pri_attribs_hist_rec_tab.old_pricing_attribute63(l_ctr)           :=  i.old_pricing_attribute63;
3515       l_pri_attribs_hist_rec_tab.new_pricing_attribute63(l_ctr)           :=  i.new_pricing_attribute63;
3516       l_pri_attribs_hist_rec_tab.old_pricing_attribute64(l_ctr)           :=  i.old_pricing_attribute64;
3517       l_pri_attribs_hist_rec_tab.new_pricing_attribute64(l_ctr)           :=  i.new_pricing_attribute64;
3518       l_pri_attribs_hist_rec_tab.old_pricing_attribute65(l_ctr)           :=  i.old_pricing_attribute65;
3519       l_pri_attribs_hist_rec_tab.new_pricing_attribute65(l_ctr)           :=  i.new_pricing_attribute65;
3520       l_pri_attribs_hist_rec_tab.old_pricing_attribute66(l_ctr)           :=  i.old_pricing_attribute66;
3521       l_pri_attribs_hist_rec_tab.new_pricing_attribute66(l_ctr)           :=  i.new_pricing_attribute66;
3522       l_pri_attribs_hist_rec_tab.old_pricing_attribute67(l_ctr)           :=  i.old_pricing_attribute67;
3523       l_pri_attribs_hist_rec_tab.new_pricing_attribute67(l_ctr)           :=  i.new_pricing_attribute67;
3524       l_pri_attribs_hist_rec_tab.old_pricing_attribute68(l_ctr)           :=  i.old_pricing_attribute68;
3525       l_pri_attribs_hist_rec_tab.new_pricing_attribute68(l_ctr)           :=  i.new_pricing_attribute68;
3526       l_pri_attribs_hist_rec_tab.old_pricing_attribute69(l_ctr)           :=  i.old_pricing_attribute69;
3527       l_pri_attribs_hist_rec_tab.new_pricing_attribute69(l_ctr)           :=  i.new_pricing_attribute69;
3528       l_pri_attribs_hist_rec_tab.old_pricing_attribute70(l_ctr)           :=  i.old_pricing_attribute70;
3529       l_pri_attribs_hist_rec_tab.new_pricing_attribute70(l_ctr)           :=  i.new_pricing_attribute70;
3530       l_pri_attribs_hist_rec_tab.old_pricing_attribute71(l_ctr)           :=  i.old_pricing_attribute71;
3531       l_pri_attribs_hist_rec_tab.new_pricing_attribute71(l_ctr)           :=  i.new_pricing_attribute71;
3532       l_pri_attribs_hist_rec_tab.old_pricing_attribute72(l_ctr)           :=  i.old_pricing_attribute72;
3533       l_pri_attribs_hist_rec_tab.new_pricing_attribute72(l_ctr)           :=  i.new_pricing_attribute72;
3534       l_pri_attribs_hist_rec_tab.old_pricing_attribute73(l_ctr)           :=  i.old_pricing_attribute73;
3535       l_pri_attribs_hist_rec_tab.new_pricing_attribute73(l_ctr)           :=  i.new_pricing_attribute73;
3536       l_pri_attribs_hist_rec_tab.old_pricing_attribute74(l_ctr)           :=  i.old_pricing_attribute74;
3537       l_pri_attribs_hist_rec_tab.new_pricing_attribute74(l_ctr)           :=  i.new_pricing_attribute74;
3538       l_pri_attribs_hist_rec_tab.old_pricing_attribute75(l_ctr)           :=  i.old_pricing_attribute75;
3539       l_pri_attribs_hist_rec_tab.new_pricing_attribute75(l_ctr)           :=  i.new_pricing_attribute75;
3540       l_pri_attribs_hist_rec_tab.old_pricing_attribute76(l_ctr)           :=  i.old_pricing_attribute76;
3541       l_pri_attribs_hist_rec_tab.new_pricing_attribute76(l_ctr)           :=  i.new_pricing_attribute76;
3542       l_pri_attribs_hist_rec_tab.old_pricing_attribute77(l_ctr)           :=  i.old_pricing_attribute77;
3543       l_pri_attribs_hist_rec_tab.new_pricing_attribute77(l_ctr)           :=  i.new_pricing_attribute77;
3544       l_pri_attribs_hist_rec_tab.old_pricing_attribute78(l_ctr)           :=  i.old_pricing_attribute78;
3545       l_pri_attribs_hist_rec_tab.new_pricing_attribute78(l_ctr)           :=  i.new_pricing_attribute78;
3546       l_pri_attribs_hist_rec_tab.old_pricing_attribute79(l_ctr)           :=  i.old_pricing_attribute79;
3547       l_pri_attribs_hist_rec_tab.new_pricing_attribute79(l_ctr)           :=  i.new_pricing_attribute79;
3548       l_pri_attribs_hist_rec_tab.old_pricing_attribute80(l_ctr)           :=  i.old_pricing_attribute80;
3549       l_pri_attribs_hist_rec_tab.new_pricing_attribute80(l_ctr)           :=  i.new_pricing_attribute80;
3550       l_pri_attribs_hist_rec_tab.old_pricing_attribute81(l_ctr)           :=  i.old_pricing_attribute81;
3554       l_pri_attribs_hist_rec_tab.old_pricing_attribute83(l_ctr)           :=  i.old_pricing_attribute83;
3551       l_pri_attribs_hist_rec_tab.new_pricing_attribute81(l_ctr)           :=  i.new_pricing_attribute81;
3552       l_pri_attribs_hist_rec_tab.old_pricing_attribute82(l_ctr)           :=  i.old_pricing_attribute82;
3553       l_pri_attribs_hist_rec_tab.new_pricing_attribute82(l_ctr)           :=  i.new_pricing_attribute82;
3555       l_pri_attribs_hist_rec_tab.new_pricing_attribute83(l_ctr)           :=  i.new_pricing_attribute83;
3556       l_pri_attribs_hist_rec_tab.old_pricing_attribute84(l_ctr)           :=  i.old_pricing_attribute84;
3557       l_pri_attribs_hist_rec_tab.new_pricing_attribute84(l_ctr)           :=  i.new_pricing_attribute84;
3558       l_pri_attribs_hist_rec_tab.old_pricing_attribute85(l_ctr)           :=  i.old_pricing_attribute85;
3559       l_pri_attribs_hist_rec_tab.new_pricing_attribute85(l_ctr)           :=  i.new_pricing_attribute85;
3560       l_pri_attribs_hist_rec_tab.old_pricing_attribute86(l_ctr)           :=  i.old_pricing_attribute86;
3561       l_pri_attribs_hist_rec_tab.new_pricing_attribute86(l_ctr)           :=  i.new_pricing_attribute86;
3562       l_pri_attribs_hist_rec_tab.old_pricing_attribute87(l_ctr)           :=  i.old_pricing_attribute87;
3563       l_pri_attribs_hist_rec_tab.new_pricing_attribute87(l_ctr)           :=  i.new_pricing_attribute87;
3564       l_pri_attribs_hist_rec_tab.old_pricing_attribute88(l_ctr)           :=  i.old_pricing_attribute88;
3565       l_pri_attribs_hist_rec_tab.new_pricing_attribute88(l_ctr)           :=  i.new_pricing_attribute88;
3566       l_pri_attribs_hist_rec_tab.old_pricing_attribute89(l_ctr)           :=  i.old_pricing_attribute89;
3567       l_pri_attribs_hist_rec_tab.new_pricing_attribute89(l_ctr)           :=  i.new_pricing_attribute89;
3568       l_pri_attribs_hist_rec_tab.old_pricing_attribute90(l_ctr)           :=  i.old_pricing_attribute90;
3569       l_pri_attribs_hist_rec_tab.new_pricing_attribute90(l_ctr)           :=  i.new_pricing_attribute90;
3570       l_pri_attribs_hist_rec_tab.old_pricing_attribute91(l_ctr)           :=  i.old_pricing_attribute91;
3571       l_pri_attribs_hist_rec_tab.new_pricing_attribute91(l_ctr)           :=  i.new_pricing_attribute91;
3572       l_pri_attribs_hist_rec_tab.old_pricing_attribute92(l_ctr)           :=  i.old_pricing_attribute92;
3573       l_pri_attribs_hist_rec_tab.new_pricing_attribute92(l_ctr)           :=  i.new_pricing_attribute92;
3574       l_pri_attribs_hist_rec_tab.old_pricing_attribute93(l_ctr)           :=  i.old_pricing_attribute93;
3575       l_pri_attribs_hist_rec_tab.new_pricing_attribute93(l_ctr)           :=  i.new_pricing_attribute93;
3576       l_pri_attribs_hist_rec_tab.old_pricing_attribute94(l_ctr)           :=  i.old_pricing_attribute94;
3577       l_pri_attribs_hist_rec_tab.new_pricing_attribute94(l_ctr)           :=  i.new_pricing_attribute94;
3578       l_pri_attribs_hist_rec_tab.old_pricing_attribute95(l_ctr)           :=  i.old_pricing_attribute95;
3579       l_pri_attribs_hist_rec_tab.new_pricing_attribute95(l_ctr)           :=  i.new_pricing_attribute95;
3580       l_pri_attribs_hist_rec_tab.old_pricing_attribute96(l_ctr)           :=  i.old_pricing_attribute96;
3581       l_pri_attribs_hist_rec_tab.new_pricing_attribute96(l_ctr)           :=  i.new_pricing_attribute96;
3582       l_pri_attribs_hist_rec_tab.old_pricing_attribute97(l_ctr)           :=  i.old_pricing_attribute97;
3583       l_pri_attribs_hist_rec_tab.new_pricing_attribute97(l_ctr)           :=  i.new_pricing_attribute97;
3584       l_pri_attribs_hist_rec_tab.old_pricing_attribute98(l_ctr)           :=  i.old_pricing_attribute98;
3585       l_pri_attribs_hist_rec_tab.new_pricing_attribute98(l_ctr)           :=  i.new_pricing_attribute98;
3586       l_pri_attribs_hist_rec_tab.old_pricing_attribute99(l_ctr)           :=  i.old_pricing_attribute99;
3587       l_pri_attribs_hist_rec_tab.new_pricing_attribute99(l_ctr)           :=  i.new_pricing_attribute99;
3588       l_pri_attribs_hist_rec_tab.old_pricing_attribute100(l_ctr)          :=  i.old_pricing_attribute100;
3589       l_pri_attribs_hist_rec_tab.new_pricing_attribute100(l_ctr)          :=  i.new_pricing_attribute100;
3590       l_pri_attribs_hist_rec_tab.old_pri_active_start_date(l_ctr)         :=  i.old_active_start_date;
3591       l_pri_attribs_hist_rec_tab.new_pri_active_start_date(l_ctr)         :=  i.new_active_start_date;
3592       l_pri_attribs_hist_rec_tab.old_pri_active_end_date(l_ctr)           :=  i.old_active_end_date;
3593       l_pri_attribs_hist_rec_tab.new_pri_active_end_date(l_ctr)           :=  i.new_active_end_date;
3594       l_pri_attribs_hist_rec_tab.old_pri_context(l_ctr)                   :=  i.old_context;
3595       l_pri_attribs_hist_rec_tab.new_pri_context(l_ctr)                   :=  i.new_context;
3596       l_pri_attribs_hist_rec_tab.old_pri_attribute1(l_ctr)                :=  i.old_attribute1;
3597       l_pri_attribs_hist_rec_tab.new_pri_attribute1(l_ctr)                :=  i.new_attribute1;
3598       l_pri_attribs_hist_rec_tab.old_pri_attribute2(l_ctr)                :=  i.old_attribute2;
3599       l_pri_attribs_hist_rec_tab.new_pri_attribute2(l_ctr)                :=  i.old_attribute2;
3600       l_pri_attribs_hist_rec_tab.old_pri_attribute3(l_ctr)                :=  i.old_attribute3;
3601       l_pri_attribs_hist_rec_tab.new_pri_attribute3(l_ctr)                :=  i.old_attribute3;
3602       l_pri_attribs_hist_rec_tab.old_pri_attribute4(l_ctr)                :=  i.old_attribute4;
3603       l_pri_attribs_hist_rec_tab.new_pri_attribute4(l_ctr)                :=  i.old_attribute4;
3604       l_pri_attribs_hist_rec_tab.old_pri_attribute5(l_ctr)                :=  i.old_attribute5;
3605       l_pri_attribs_hist_rec_tab.new_pri_attribute5(l_ctr)                :=  i.old_attribute5;
3606       l_pri_attribs_hist_rec_tab.old_pri_attribute6(l_ctr)                :=  i.old_attribute6;
3607       l_pri_attribs_hist_rec_tab.new_pri_attribute6(l_ctr)                :=  i.old_attribute6;
3608       l_pri_attribs_hist_rec_tab.old_pri_attribute7(l_ctr)                :=  i.old_attribute7;
3612       l_pri_attribs_hist_rec_tab.old_pri_attribute9(l_ctr)                :=  i.old_attribute9;
3609       l_pri_attribs_hist_rec_tab.new_pri_attribute7(l_ctr)                :=  i.old_attribute7;
3610       l_pri_attribs_hist_rec_tab.old_pri_attribute8(l_ctr)                :=  i.old_attribute8;
3611       l_pri_attribs_hist_rec_tab.new_pri_attribute8(l_ctr)                :=  i.old_attribute8;
3613       l_pri_attribs_hist_rec_tab.new_pri_attribute9(l_ctr)                :=  i.old_attribute9;
3614       l_pri_attribs_hist_rec_tab.old_pri_attribute10(l_ctr)               :=  i.old_attribute10;
3615       l_pri_attribs_hist_rec_tab.new_pri_attribute10(l_ctr)               :=  i.old_attribute10;
3616       l_pri_attribs_hist_rec_tab.old_pri_attribute11(l_ctr)               :=  i.old_attribute11;
3617       l_pri_attribs_hist_rec_tab.new_pri_attribute11(l_ctr)               :=  i.old_attribute11;
3618       l_pri_attribs_hist_rec_tab.old_pri_attribute12(l_ctr)               :=  i.old_attribute12;
3619       l_pri_attribs_hist_rec_tab.new_pri_attribute12(l_ctr)               :=  i.old_attribute12;
3620       l_pri_attribs_hist_rec_tab.old_pri_attribute13(l_ctr)               :=  i.old_attribute13;
3621       l_pri_attribs_hist_rec_tab.new_pri_attribute13(l_ctr)               :=  i.old_attribute13;
3622       l_pri_attribs_hist_rec_tab.old_pri_attribute14(l_ctr)               :=  i.old_attribute14;
3623       l_pri_attribs_hist_rec_tab.new_pri_attribute14(l_ctr)               :=  i.old_attribute14;
3624       l_pri_attribs_hist_rec_tab.old_pri_attribute15(l_ctr)               :=  i.old_attribute15;
3625       l_pri_attribs_hist_rec_tab.new_pri_attribute15(l_ctr)               :=  i.old_attribute15;
3626       l_pri_attribs_hist_rec_tab.pri_full_dump_flag(l_ctr)                :=  i.full_dump_flag;
3627       l_pri_attribs_hist_rec_tab.pri_created_by(l_ctr)                    :=  i.created_by;
3628       l_pri_attribs_hist_rec_tab.pri_creation_date(l_ctr)                 :=  i.creation_date;
3629       l_pri_attribs_hist_rec_tab.pri_last_updated_by(l_ctr)               :=  i.last_updated_by;
3630       l_pri_attribs_hist_rec_tab.pri_last_update_date(l_ctr)              :=  i.last_update_date;
3631       l_pri_attribs_hist_rec_tab.pri_last_update_login(l_ctr)             :=  i.last_update_login;
3632       l_pri_attribs_hist_rec_tab.pri_object_version_number(l_ctr)         :=  i.object_version_number;
3633       l_pri_attribs_hist_rec_tab.pri_security_group_id(l_ctr)             :=  i.security_group_id;
3634       l_pri_attribs_hist_rec_tab.pri_migrated_flag(l_ctr)                 :=  i.migrated_flag;
3635 
3636    End Loop;
3637 
3638       -- get the party history count for the transaction range
3639       l_cnt := l_pri_attribs_hist_rec_tab.price_attrib_history_id.count;
3640       --
3641       Debug('');
3642       Debug('');
3643       Debug('Number of Pricing Attributes history records archived:'||to_char(l_cnt));
3644       Debug('');
3645       Debug('');
3646       --
3647       If l_cnt > 0 Then
3648 
3649         FORALL i IN 1 .. l_cnt
3650 
3651          Insert Into CSI_HISTORY_ARCHIVE
3652          (
3653             HISTORY_ARCHIVE_ID
3654            ,OBJECT_ID
3655            ,ENTITY_HISTORY_ID
3656            ,TRANSACTION_ID
3657            ,ENTITY_ID
3658            ,COL_NUM_37
3659            ,COL_NUM_38
3660            ,COL_NUM_39
3661            ,COL_NUM_40
3662            ,COL_NUM_41
3663           ,COL_CHAR_01
3664           ,COL_CHAR_02
3665           ,COL_CHAR_03
3666           ,COL_CHAR_04
3667           ,COL_CHAR_05
3668           ,COL_CHAR_06
3669           ,COL_CHAR_07
3670           ,COL_CHAR_08
3671           ,COL_CHAR_09
3672           ,COL_CHAR_10
3673           ,COL_CHAR_11
3674           ,COL_CHAR_12
3675           ,COL_CHAR_13
3676           ,COL_CHAR_14
3677           ,COL_CHAR_15
3678           ,COL_CHAR_16
3679           ,COL_CHAR_17
3680           ,COL_CHAR_18
3681           ,COL_CHAR_19
3682           ,COL_CHAR_20
3683           ,COL_CHAR_21
3684           ,COL_CHAR_22
3685           ,COL_CHAR_23
3686           ,COL_CHAR_24
3687           ,COL_CHAR_25
3688           ,COL_CHAR_26
3689           ,COL_CHAR_27
3690           ,COL_CHAR_28
3691           ,COL_CHAR_29
3692           ,COL_CHAR_30
3693           ,COL_CHAR_31
3694           ,COL_CHAR_32
3695           ,COL_CHAR_33
3696           ,COL_CHAR_34
3697           ,COL_CHAR_35
3698           ,COL_CHAR_36
3699           ,COL_CHAR_37
3700           ,COL_CHAR_38
3701           ,COL_CHAR_39
3702           ,COL_CHAR_40
3703           ,COL_CHAR_41
3704           ,COL_CHAR_42
3705           ,COL_CHAR_43
3706           ,COL_CHAR_44
3707           ,COL_CHAR_45
3708           ,COL_CHAR_46
3709           ,COL_CHAR_47
3710           ,COL_CHAR_48
3711           ,COL_CHAR_49
3712           ,COL_CHAR_50
3713           ,COL_CHAR_51
3714           ,COL_CHAR_52
3715           ,COL_CHAR_53
3716           ,COL_CHAR_54
3717           ,COL_CHAR_55
3718           ,COL_CHAR_56
3719           ,COL_CHAR_57
3720           ,COL_CHAR_58
3721           ,COL_CHAR_59
3722           ,COL_CHAR_60
3723           ,COL_CHAR_61
3724           ,COL_CHAR_62
3725           ,COL_CHAR_63
3726           ,COL_CHAR_64
3727           ,COL_CHAR_65
3728           ,COL_CHAR_66
3729           ,COL_CHAR_67
3730           ,COL_CHAR_68
3731           ,COL_CHAR_69
3732           ,COL_CHAR_70
3733           ,COL_CHAR_71
3734           ,COL_CHAR_72
3735           ,COL_CHAR_73
3736           ,COL_CHAR_74
3737           ,COL_CHAR_75
3738           ,COL_CHAR_76
3739           ,COL_CHAR_77
3740           ,COL_CHAR_78
3744           ,COL_CHAR_82
3741           ,COL_CHAR_79
3742           ,COL_CHAR_80
3743           ,COL_CHAR_81
3745           ,COL_CHAR_83
3746           ,COL_CHAR_84
3747           ,COL_CHAR_85
3748           ,COL_CHAR_86
3749           ,COL_CHAR_87
3750           ,COL_CHAR_88
3751           ,COL_CHAR_89
3752           ,COL_CHAR_90
3753           ,COL_CHAR_91
3754           ,COL_CHAR_92
3755           ,COL_CHAR_93
3756           ,COL_CHAR_94
3757           ,COL_CHAR_95
3758           ,COL_CHAR_96
3759           ,COL_CHAR_97
3760           ,COL_CHAR_98
3761           ,COL_CHAR_99
3762           ,COL_CHAR_100
3763           ,COL_CHAR_101
3764           ,COL_CHAR_102
3765           ,COL_CHAR_103
3766           ,COL_CHAR_104
3767           ,COL_CHAR_105
3768           ,COL_CHAR_106
3769           ,COL_CHAR_107
3770           ,COL_CHAR_108
3771           ,COL_CHAR_109
3772           ,COL_CHAR_110
3773           ,COL_CHAR_111
3774           ,COL_CHAR_112
3775           ,COL_CHAR_113
3776           ,COL_CHAR_114
3777           ,COL_CHAR_115
3778           ,COL_CHAR_116
3779           ,COL_CHAR_117
3780           ,COL_CHAR_118
3781           ,COL_CHAR_119
3782           ,COL_CHAR_120
3783           ,COL_CHAR_121
3784           ,COL_CHAR_122
3785           ,COL_CHAR_123
3786           ,COL_CHAR_124
3787           ,COL_CHAR_125
3788           ,COL_CHAR_126
3789           ,COL_CHAR_127
3790           ,COL_CHAR_128
3791           ,COL_CHAR_129
3792           ,COL_CHAR_130
3793           ,COL_CHAR_131
3794           ,COL_CHAR_132
3795           ,COL_CHAR_133
3796           ,COL_CHAR_134
3797           ,COL_CHAR_135
3798           ,COL_CHAR_136
3799           ,COL_CHAR_137
3800           ,COL_CHAR_138
3801           ,COL_CHAR_139
3802           ,COL_CHAR_140
3803           ,COL_CHAR_141
3804           ,COL_CHAR_142
3805           ,COL_CHAR_143
3806           ,COL_CHAR_144
3807           ,COL_CHAR_145
3808           ,COL_CHAR_146
3809           ,COL_CHAR_147
3810           ,COL_CHAR_148
3811           ,COL_CHAR_149
3812           ,COL_CHAR_150
3813           ,COL_CHAR_151
3814           ,COL_CHAR_152
3815           ,COL_CHAR_153
3816           ,COL_CHAR_154
3817           ,COL_CHAR_155
3818           ,COL_CHAR_156
3819           ,COL_CHAR_157
3820           ,COL_CHAR_158
3821           ,COL_CHAR_159
3822           ,COL_CHAR_160
3823           ,COL_CHAR_161
3824           ,COL_CHAR_162
3825           ,COL_CHAR_163
3826           ,COL_CHAR_164
3827           ,COL_CHAR_165
3828           ,COL_CHAR_166
3829           ,COL_CHAR_167
3830           ,COL_CHAR_168
3831           ,COL_CHAR_169
3832           ,COL_CHAR_170
3833           ,COL_CHAR_171
3834           ,COL_CHAR_172
3835           ,COL_CHAR_173
3836           ,COL_CHAR_174
3837           ,COL_CHAR_175
3838           ,COL_CHAR_176
3839           ,COL_CHAR_177
3840           ,COL_CHAR_178
3841           ,COL_CHAR_179
3842           ,COL_CHAR_180
3843           ,COL_CHAR_181
3844           ,COL_CHAR_182
3845           ,COL_CHAR_183
3846           ,COL_CHAR_184
3847           ,COL_CHAR_185
3848           ,COL_CHAR_186
3849           ,COL_CHAR_187
3850           ,COL_CHAR_188
3851           ,COL_CHAR_189
3852           ,COL_CHAR_190
3853           ,COL_CHAR_191
3854           ,COL_CHAR_192
3855           ,COL_CHAR_193
3856           ,COL_CHAR_194
3857           ,COL_CHAR_195
3861           ,COL_CHAR_199
3858           ,COL_CHAR_196
3859           ,COL_CHAR_197
3860           ,COL_CHAR_198
3862           ,COL_CHAR_200
3863           ,COL_CHAR_201
3864           ,COL_CHAR_202
3865           ,COL_CHAR_203
3866           ,COL_CHAR_204
3867           ,COL_CHAR_205
3868           ,COL_CHAR_206
3869           ,COL_CHAR_207
3870           ,COL_CHAR_208
3871           ,COL_CHAR_209
3872           ,COL_CHAR_210
3873           ,COL_CHAR_211
3874           ,COL_CHAR_212
3875           ,COL_CHAR_213
3876           ,COL_CHAR_214
3877           ,COL_CHAR_215
3878           ,COL_CHAR_216
3879           ,COL_CHAR_217
3880           ,COL_CHAR_218
3881           ,COL_CHAR_219
3882           ,COL_CHAR_220
3883           ,COL_CHAR_221
3884           ,COL_CHAR_222
3885           ,COL_CHAR_223
3886           ,COL_CHAR_224
3887           ,COL_CHAR_225
3888           ,COL_CHAR_226
3889           ,COL_CHAR_227
3890           ,COL_CHAR_228
3891           ,COL_CHAR_229
3892           ,COL_CHAR_230
3893           ,COL_CHAR_231
3894           ,COL_CHAR_232
3895           ,COL_CHAR_233
3896           ,COL_CHAR_234
3897           ,COL_CHAR_235
3898           ,COL_CHAR_236
3899           ,COL_DATE_01
3900           ,COL_DATE_02
3901           ,COL_DATE_03
3902           ,COL_DATE_04
3903           ,COL_DATE_11
3904           ,COL_DATE_12
3905           ,CONTEXT
3906           ,ATTRIBUTE1
3907           ,ATTRIBUTE2
3908           ,ATTRIBUTE3
3909           ,ATTRIBUTE4
3910           ,ATTRIBUTE5
3911           ,ATTRIBUTE6
3912           ,ATTRIBUTE7
3913           ,ATTRIBUTE8
3914           ,ATTRIBUTE9
3915           ,ATTRIBUTE10
3916           ,ATTRIBUTE11
3917           ,ATTRIBUTE12
3918           ,ATTRIBUTE13
3919           ,ATTRIBUTE14
3920           ,ATTRIBUTE15
3921           ,CREATED_BY
3922           ,CREATION_DATE
3923           ,LAST_UPDATED_BY
3924           ,LAST_UPDATE_DATE
3925           ,LAST_UPDATE_LOGIN
3926           ,OBJECT_VERSION_NUMBER
3927           ,SECURITY_GROUP_ID
3928            )
3929            Values
3930            (
3931                l_archive_id_tbl(i),
3932                l_table_id,
3933                l_pri_attribs_hist_rec_tab.price_attrib_history_id(i),
3934                l_pri_attribs_hist_rec_tab.transaction_id(i),
3935                l_pri_attribs_hist_rec_tab.pricing_attribute_id(i),
3936                l_pri_attribs_hist_rec_tab.pri_created_by(i),
3937                l_pri_attribs_hist_rec_tab.pri_last_updated_by(i),
3938                l_pri_attribs_hist_rec_tab.pri_last_update_login(i),
3939                l_pri_attribs_hist_rec_tab.pri_object_version_number(i),
3940                l_pri_attribs_hist_rec_tab.pri_security_group_id(i),
3941                l_pri_attribs_hist_rec_tab.old_pricing_context(i),
3942                l_pri_attribs_hist_rec_tab.new_pricing_context(i),
3943                l_pri_attribs_hist_rec_tab.old_pricing_attribute1(i),
3944                l_pri_attribs_hist_rec_tab.new_pricing_attribute1(i),
3945                l_pri_attribs_hist_rec_tab.old_pricing_attribute2(i),
3946                l_pri_attribs_hist_rec_tab.new_pricing_attribute2(i),
3947                l_pri_attribs_hist_rec_tab.old_pricing_attribute3(i),
3948                l_pri_attribs_hist_rec_tab.new_pricing_attribute3(i),
3949                l_pri_attribs_hist_rec_tab.old_pricing_attribute4(i),
3950                l_pri_attribs_hist_rec_tab.new_pricing_attribute4(i),
3951                l_pri_attribs_hist_rec_tab.old_pricing_attribute5(i),
3952                l_pri_attribs_hist_rec_tab.new_pricing_attribute5(i),
3953                l_pri_attribs_hist_rec_tab.old_pricing_attribute6(i),
3954                l_pri_attribs_hist_rec_tab.new_pricing_attribute6(i),
3955                l_pri_attribs_hist_rec_tab.old_pricing_attribute7(i),
3956                l_pri_attribs_hist_rec_tab.new_pricing_attribute7(i),
3957                l_pri_attribs_hist_rec_tab.old_pricing_attribute8(i),
3958                l_pri_attribs_hist_rec_tab.new_pricing_attribute8(i),
3959                l_pri_attribs_hist_rec_tab.old_pricing_attribute9(i),
3960                l_pri_attribs_hist_rec_tab.new_pricing_attribute9(i),
3961                l_pri_attribs_hist_rec_tab.old_pricing_attribute10(i),
3962                l_pri_attribs_hist_rec_tab.new_pricing_attribute10(i),
3963                l_pri_attribs_hist_rec_tab.old_pricing_attribute11(i),
3964                l_pri_attribs_hist_rec_tab.new_pricing_attribute11(i),
3965                l_pri_attribs_hist_rec_tab.old_pricing_attribute12(i),
3966                l_pri_attribs_hist_rec_tab.new_pricing_attribute12(i),
3967                l_pri_attribs_hist_rec_tab.old_pricing_attribute13(i),
3968                l_pri_attribs_hist_rec_tab.new_pricing_attribute13(i),
3969                l_pri_attribs_hist_rec_tab.old_pricing_attribute14(i),
3970                l_pri_attribs_hist_rec_tab.new_pricing_attribute14(i),
3971                l_pri_attribs_hist_rec_tab.old_pri_context(i),
3972                l_pri_attribs_hist_rec_tab.new_pri_context(i),
3973                l_pri_attribs_hist_rec_tab.old_pri_attribute1(i),
3974                l_pri_attribs_hist_rec_tab.new_pri_attribute1(i),
3975                l_pri_attribs_hist_rec_tab.old_pri_attribute2(i),
3976                l_pri_attribs_hist_rec_tab.new_pri_attribute2(i),
3977                l_pri_attribs_hist_rec_tab.old_pri_attribute3(i),
3978                l_pri_attribs_hist_rec_tab.new_pri_attribute3(i),
3979                l_pri_attribs_hist_rec_tab.old_pri_attribute4(i),
3980                l_pri_attribs_hist_rec_tab.new_pri_attribute4(i),
3981                l_pri_attribs_hist_rec_tab.old_pri_attribute5(i),
3982                l_pri_attribs_hist_rec_tab.new_pri_attribute5(i),
3983                l_pri_attribs_hist_rec_tab.old_pri_attribute6(i),
3984                l_pri_attribs_hist_rec_tab.new_pri_attribute6(i),
3985                l_pri_attribs_hist_rec_tab.old_pri_attribute7(i),
3989                l_pri_attribs_hist_rec_tab.old_pri_attribute9(i),
3986                l_pri_attribs_hist_rec_tab.new_pri_attribute7(i),
3987                l_pri_attribs_hist_rec_tab.old_pri_attribute8(i),
3988                l_pri_attribs_hist_rec_tab.new_pri_attribute8(i),
3990                l_pri_attribs_hist_rec_tab.new_pri_attribute9(i),
3991                l_pri_attribs_hist_rec_tab.old_pri_attribute10(i),
3992                l_pri_attribs_hist_rec_tab.new_pri_attribute10(i),
3993                l_pri_attribs_hist_rec_tab.old_pri_attribute11(i),
3994                l_pri_attribs_hist_rec_tab.new_pri_attribute11(i),
3995                l_pri_attribs_hist_rec_tab.old_pri_attribute12(i),
3996                l_pri_attribs_hist_rec_tab.new_pri_attribute12(i),
3997                l_pri_attribs_hist_rec_tab.old_pri_attribute13(i),
3998                l_pri_attribs_hist_rec_tab.new_pri_attribute13(i),
3999                l_pri_attribs_hist_rec_tab.old_pri_attribute14(i),
4000                l_pri_attribs_hist_rec_tab.new_pri_attribute14(i),
4001                l_pri_attribs_hist_rec_tab.old_pri_attribute15(i),
4002                l_pri_attribs_hist_rec_tab.new_pri_attribute15(i),
4003                l_pri_attribs_hist_rec_tab.old_pricing_attribute15(i),
4004                l_pri_attribs_hist_rec_tab.new_pricing_attribute15(i),
4005                l_pri_attribs_hist_rec_tab.old_pricing_attribute16(i),
4006                l_pri_attribs_hist_rec_tab.new_pricing_attribute16(i),
4007                l_pri_attribs_hist_rec_tab.old_pricing_attribute17(i),
4008                l_pri_attribs_hist_rec_tab.new_pricing_attribute17(i),
4009                l_pri_attribs_hist_rec_tab.old_pricing_attribute18(i),
4010                l_pri_attribs_hist_rec_tab.new_pricing_attribute18(i),
4011                l_pri_attribs_hist_rec_tab.pri_full_dump_flag(i),
4012                l_pri_attribs_hist_rec_tab.pri_migrated_flag(i),
4013                l_pri_attribs_hist_rec_tab.old_pricing_attribute19(i),
4014                l_pri_attribs_hist_rec_tab.new_pricing_attribute19(i),
4015                l_pri_attribs_hist_rec_tab.old_pricing_attribute20(i),
4016                l_pri_attribs_hist_rec_tab.new_pricing_attribute20(i),
4017                l_pri_attribs_hist_rec_tab.old_pricing_attribute21(i),
4018                l_pri_attribs_hist_rec_tab.new_pricing_attribute21(i),
4019                l_pri_attribs_hist_rec_tab.old_pricing_attribute22(i),
4020                l_pri_attribs_hist_rec_tab.new_pricing_attribute22(i),
4021                l_pri_attribs_hist_rec_tab.old_pricing_attribute23(i),
4022                l_pri_attribs_hist_rec_tab.new_pricing_attribute23(i),
4023                l_pri_attribs_hist_rec_tab.old_pricing_attribute24(i),
4024                l_pri_attribs_hist_rec_tab.new_pricing_attribute24(i),
4025                l_pri_attribs_hist_rec_tab.old_pricing_attribute25(i),
4026                l_pri_attribs_hist_rec_tab.new_pricing_attribute25(i),
4027                l_pri_attribs_hist_rec_tab.old_pricing_attribute26(i),
4028                l_pri_attribs_hist_rec_tab.new_pricing_attribute26(i),
4029                l_pri_attribs_hist_rec_tab.old_pricing_attribute27(i),
4030                l_pri_attribs_hist_rec_tab.new_pricing_attribute27(i),
4031                l_pri_attribs_hist_rec_tab.old_pricing_attribute28(i),
4032                l_pri_attribs_hist_rec_tab.new_pricing_attribute28(i),
4033                l_pri_attribs_hist_rec_tab.old_pricing_attribute29(i),
4034                l_pri_attribs_hist_rec_tab.new_pricing_attribute29(i),
4035                l_pri_attribs_hist_rec_tab.old_pricing_attribute30(i),
4036                l_pri_attribs_hist_rec_tab.new_pricing_attribute30(i),
4037                l_pri_attribs_hist_rec_tab.old_pricing_attribute31(i),
4038                l_pri_attribs_hist_rec_tab.new_pricing_attribute31(i),
4039                l_pri_attribs_hist_rec_tab.old_pricing_attribute32(i),
4040                l_pri_attribs_hist_rec_tab.new_pricing_attribute32(i),
4041                l_pri_attribs_hist_rec_tab.old_pricing_attribute33(i),
4042                l_pri_attribs_hist_rec_tab.new_pricing_attribute33(i),
4043                l_pri_attribs_hist_rec_tab.old_pricing_attribute34(i),
4044                l_pri_attribs_hist_rec_tab.new_pricing_attribute34(i),
4045                l_pri_attribs_hist_rec_tab.old_pricing_attribute35(i),
4046                l_pri_attribs_hist_rec_tab.new_pricing_attribute35(i),
4047                l_pri_attribs_hist_rec_tab.old_pricing_attribute36(i),
4048                l_pri_attribs_hist_rec_tab.new_pricing_attribute36(i),
4049                l_pri_attribs_hist_rec_tab.old_pricing_attribute37(i),
4050                l_pri_attribs_hist_rec_tab.new_pricing_attribute37(i),
4051                l_pri_attribs_hist_rec_tab.old_pricing_attribute38(i),
4052                l_pri_attribs_hist_rec_tab.new_pricing_attribute38(i),
4053                l_pri_attribs_hist_rec_tab.old_pricing_attribute39(i),
4054                l_pri_attribs_hist_rec_tab.new_pricing_attribute39(i),
4055                l_pri_attribs_hist_rec_tab.old_pricing_attribute40(i),
4056                l_pri_attribs_hist_rec_tab.new_pricing_attribute40(i),
4057                l_pri_attribs_hist_rec_tab.old_pricing_attribute41(i),
4058                l_pri_attribs_hist_rec_tab.new_pricing_attribute41(i),
4059                l_pri_attribs_hist_rec_tab.old_pricing_attribute42(i),
4060                l_pri_attribs_hist_rec_tab.new_pricing_attribute42(i),
4061                l_pri_attribs_hist_rec_tab.old_pricing_attribute43(i),
4062                l_pri_attribs_hist_rec_tab.new_pricing_attribute43(i),
4063                l_pri_attribs_hist_rec_tab.old_pricing_attribute44(i),
4064                l_pri_attribs_hist_rec_tab.new_pricing_attribute44(i),
4065                l_pri_attribs_hist_rec_tab.old_pricing_attribute45(i),
4066                l_pri_attribs_hist_rec_tab.new_pricing_attribute45(i),
4067                l_pri_attribs_hist_rec_tab.old_pricing_attribute46(i),
4068                l_pri_attribs_hist_rec_tab.new_pricing_attribute46(i),
4069                l_pri_attribs_hist_rec_tab.old_pricing_attribute47(i),
4070                l_pri_attribs_hist_rec_tab.new_pricing_attribute47(i),
4071                l_pri_attribs_hist_rec_tab.old_pricing_attribute48(i),
4075                l_pri_attribs_hist_rec_tab.old_pricing_attribute50(i),
4072                l_pri_attribs_hist_rec_tab.new_pricing_attribute48(i),
4073                l_pri_attribs_hist_rec_tab.old_pricing_attribute49(i),
4074                l_pri_attribs_hist_rec_tab.new_pricing_attribute49(i),
4076                l_pri_attribs_hist_rec_tab.new_pricing_attribute50(i),
4077                l_pri_attribs_hist_rec_tab.old_pricing_attribute51(i),
4078                l_pri_attribs_hist_rec_tab.new_pricing_attribute51(i),
4079                l_pri_attribs_hist_rec_tab.old_pricing_attribute52(i),
4080                l_pri_attribs_hist_rec_tab.new_pricing_attribute52(i),
4081                l_pri_attribs_hist_rec_tab.old_pricing_attribute53(i),
4082                l_pri_attribs_hist_rec_tab.new_pricing_attribute53(i),
4083                l_pri_attribs_hist_rec_tab.old_pricing_attribute54(i),
4084                l_pri_attribs_hist_rec_tab.new_pricing_attribute54(i),
4085                l_pri_attribs_hist_rec_tab.old_pricing_attribute55(i),
4086                l_pri_attribs_hist_rec_tab.new_pricing_attribute55(i),
4087                l_pri_attribs_hist_rec_tab.old_pricing_attribute56(i),
4088                l_pri_attribs_hist_rec_tab.new_pricing_attribute56(i),
4089                l_pri_attribs_hist_rec_tab.old_pricing_attribute57(i),
4090                l_pri_attribs_hist_rec_tab.new_pricing_attribute57(i),
4091                l_pri_attribs_hist_rec_tab.old_pricing_attribute58(i),
4092                l_pri_attribs_hist_rec_tab.new_pricing_attribute58(i),
4093                l_pri_attribs_hist_rec_tab.old_pricing_attribute59(i),
4094                l_pri_attribs_hist_rec_tab.new_pricing_attribute59(i),
4095                l_pri_attribs_hist_rec_tab.old_pricing_attribute60(i),
4096                l_pri_attribs_hist_rec_tab.new_pricing_attribute60(i),
4097                l_pri_attribs_hist_rec_tab.old_pricing_attribute61(i),
4098                l_pri_attribs_hist_rec_tab.new_pricing_attribute61(i),
4099                l_pri_attribs_hist_rec_tab.old_pricing_attribute62(i),
4100                l_pri_attribs_hist_rec_tab.new_pricing_attribute62(i),
4101                l_pri_attribs_hist_rec_tab.old_pricing_attribute63(i),
4102                l_pri_attribs_hist_rec_tab.new_pricing_attribute63(i),
4103                l_pri_attribs_hist_rec_tab.old_pricing_attribute64(i),
4104                l_pri_attribs_hist_rec_tab.new_pricing_attribute64(i),
4105                l_pri_attribs_hist_rec_tab.old_pricing_attribute65(i),
4106                l_pri_attribs_hist_rec_tab.new_pricing_attribute65(i),
4107                l_pri_attribs_hist_rec_tab.old_pricing_attribute66(i),
4108                l_pri_attribs_hist_rec_tab.new_pricing_attribute66(i),
4109                l_pri_attribs_hist_rec_tab.old_pricing_attribute67(i),
4110                l_pri_attribs_hist_rec_tab.new_pricing_attribute67(i),
4111                l_pri_attribs_hist_rec_tab.old_pricing_attribute68(i),
4112                l_pri_attribs_hist_rec_tab.new_pricing_attribute68(i),
4113                l_pri_attribs_hist_rec_tab.old_pricing_attribute69(i),
4114                l_pri_attribs_hist_rec_tab.new_pricing_attribute69(i),
4115                l_pri_attribs_hist_rec_tab.old_pricing_attribute70(i),
4116                l_pri_attribs_hist_rec_tab.new_pricing_attribute70(i),
4117                l_pri_attribs_hist_rec_tab.old_pricing_attribute71(i),
4118                l_pri_attribs_hist_rec_tab.new_pricing_attribute71(i),
4119                l_pri_attribs_hist_rec_tab.old_pricing_attribute72(i),
4120                l_pri_attribs_hist_rec_tab.new_pricing_attribute72(i),
4121                l_pri_attribs_hist_rec_tab.old_pricing_attribute73(i),
4122                l_pri_attribs_hist_rec_tab.new_pricing_attribute73(i),
4123                l_pri_attribs_hist_rec_tab.old_pricing_attribute74(i),
4124                l_pri_attribs_hist_rec_tab.new_pricing_attribute74(i),
4125                l_pri_attribs_hist_rec_tab.old_pricing_attribute75(i),
4126                l_pri_attribs_hist_rec_tab.new_pricing_attribute75(i),
4127                l_pri_attribs_hist_rec_tab.old_pricing_attribute76(i),
4128                l_pri_attribs_hist_rec_tab.new_pricing_attribute76(i),
4129                l_pri_attribs_hist_rec_tab.old_pricing_attribute77(i),
4130                l_pri_attribs_hist_rec_tab.new_pricing_attribute77(i),
4131                l_pri_attribs_hist_rec_tab.old_pricing_attribute78(i),
4132                l_pri_attribs_hist_rec_tab.new_pricing_attribute78(i),
4133                l_pri_attribs_hist_rec_tab.old_pricing_attribute79(i),
4134                l_pri_attribs_hist_rec_tab.new_pricing_attribute79(i),
4135                l_pri_attribs_hist_rec_tab.old_pricing_attribute80(i),
4136                l_pri_attribs_hist_rec_tab.new_pricing_attribute80(i),
4137                l_pri_attribs_hist_rec_tab.old_pricing_attribute81(i),
4138                l_pri_attribs_hist_rec_tab.new_pricing_attribute81(i),
4139                l_pri_attribs_hist_rec_tab.old_pricing_attribute82(i),
4140                l_pri_attribs_hist_rec_tab.new_pricing_attribute82(i),
4141                l_pri_attribs_hist_rec_tab.old_pricing_attribute83(i),
4142                l_pri_attribs_hist_rec_tab.new_pricing_attribute83(i),
4143                l_pri_attribs_hist_rec_tab.old_pricing_attribute84(i),
4144                l_pri_attribs_hist_rec_tab.new_pricing_attribute84(i),
4145                l_pri_attribs_hist_rec_tab.old_pricing_attribute85(i),
4146                l_pri_attribs_hist_rec_tab.new_pricing_attribute85(i),
4147                l_pri_attribs_hist_rec_tab.old_pricing_attribute86(i),
4148                l_pri_attribs_hist_rec_tab.new_pricing_attribute86(i),
4149                l_pri_attribs_hist_rec_tab.old_pricing_attribute87(i),
4150                l_pri_attribs_hist_rec_tab.new_pricing_attribute87(i),
4151                l_pri_attribs_hist_rec_tab.old_pricing_attribute88(i),
4152                l_pri_attribs_hist_rec_tab.new_pricing_attribute88(i),
4153                l_pri_attribs_hist_rec_tab.old_pricing_attribute89(i),
4154                l_pri_attribs_hist_rec_tab.new_pricing_attribute89(i),
4155                l_pri_attribs_hist_rec_tab.old_pricing_attribute90(i),
4156                l_pri_attribs_hist_rec_tab.new_pricing_attribute90(i),
4160                l_pri_attribs_hist_rec_tab.new_pricing_attribute92(i),
4157                l_pri_attribs_hist_rec_tab.old_pricing_attribute91(i),
4158                l_pri_attribs_hist_rec_tab.new_pricing_attribute91(i),
4159                l_pri_attribs_hist_rec_tab.old_pricing_attribute92(i),
4161                l_pri_attribs_hist_rec_tab.old_pricing_attribute93(i),
4162                l_pri_attribs_hist_rec_tab.new_pricing_attribute93(i),
4163                l_pri_attribs_hist_rec_tab.old_pricing_attribute94(i),
4164                l_pri_attribs_hist_rec_tab.new_pricing_attribute94(i),
4165                l_pri_attribs_hist_rec_tab.old_pricing_attribute95(i),
4166                l_pri_attribs_hist_rec_tab.new_pricing_attribute95(i),
4167                l_pri_attribs_hist_rec_tab.old_pricing_attribute96(i),
4168                l_pri_attribs_hist_rec_tab.new_pricing_attribute96(i),
4169                l_pri_attribs_hist_rec_tab.old_pricing_attribute97(i),
4170                l_pri_attribs_hist_rec_tab.new_pricing_attribute97(i),
4171                l_pri_attribs_hist_rec_tab.old_pricing_attribute98(i),
4172                l_pri_attribs_hist_rec_tab.new_pricing_attribute98(i),
4173                l_pri_attribs_hist_rec_tab.old_pricing_attribute99(i),
4174                l_pri_attribs_hist_rec_tab.new_pricing_attribute99(i),
4175                l_pri_attribs_hist_rec_tab.old_pricing_attribute100(i),
4176                l_pri_attribs_hist_rec_tab.new_pricing_attribute100(i),
4177                l_pri_attribs_hist_rec_tab.old_pri_active_start_date(i),
4178                l_pri_attribs_hist_rec_tab.new_pri_active_start_date(i),
4179                l_pri_attribs_hist_rec_tab.old_pri_active_end_date(i),
4180                l_pri_attribs_hist_rec_tab.new_pri_active_end_date(i),
4181                l_pri_attribs_hist_rec_tab.pri_creation_date(i),
4182                l_pri_attribs_hist_rec_tab.pri_last_update_date(i),
4183                null,
4184                null,
4185                null,
4186                null,
4187                null,
4188                null,
4189                null,
4190                null,
4191                null,
4192                null,
4193                null,
4194                null,
4195                null,
4196                null,
4197                null,
4198                null,
4199                l_user_id,
4200                sysdate,
4201                l_user_id,
4202                sysdate,
4203                l_login_id,
4204                1,
4205                null
4206                );
4207 
4208          -- Purge the corresonding Archive data from the Instance history tables
4209 
4210             FORALL i IN 1 .. l_cnt
4211 
4212                Delete From CSI_I_PRICING_ATTRIBS_H
4213                Where price_attrib_history_id = l_pri_attribs_hist_rec_tab.price_attrib_history_id(i);
4214 
4215 
4216        End If; -- if l_cnt > 0
4217        --
4218        Exit When from_trans = to_trans;
4219        Exit When v_end = to_trans;
4220 
4221      v_start := v_end + 1;
4222      v_end   := v_start + v_batch;
4223      --
4224      --
4225 	 If v_start > to_trans Then
4226 	    v_start := to_trans;
4227 	 End If;
4228 	 --
4229 	 If v_end > to_trans then
4230 	    v_end := to_trans;
4231 	 End If;
4232      --
4233      Commit;
4234      --
4235    Exception
4236       when others then
4237          Debug(substr(sqlerrm,1,255));
4238          ROLLBACK to Pricing_Archive;
4239    End;
4240  End Loop; -- Local Batch Loop
4241  Commit;
4242    --
4243 END; -- Procedure PriAttribs_Archive
4244 
4245 --
4246 -- This program is used to archive the Operating units history. It accepts from and to transactions
4247 -- as the input parameters.
4248 --
4249 
4250 PROCEDURE Assets_archive( errbuf       OUT NOCOPY VARCHAR2,
4251                           retcode      OUT NOCOPY NUMBER,
4252                           from_trans   IN  NUMBER,
4253                           to_trans     IN  NUMBER,
4254                           purge_to_date IN VARCHAR2 )
4255 IS
4256 
4257     l_archive_id      NUMBER;
4258     l_ctr             NUMBER := 0;
4259     l_cnt             NUMBER;
4260     l_table_id        NUMBER;
4261     l_user_id         NUMBER := FND_GLOBAL.USER_ID;
4262     l_login_id        NUMBER := FND_GLOBAL.CONC_LOGIN_ID;
4263     v_batch           NUMBER := 15000;
4264     v_start           NUMBER;
4265     v_end             NUMBER;
4266 
4267     Type NUMLIST IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
4268     l_archive_id_tbl   NUMLIST;
4269 
4270     Cursor ins_asset_hist_csr (p_from_trans IN NUMBER,
4271                                p_to_trans   IN NUMBER) IS
4272     Select csh.*
4273     From   CSI_I_ASSETS_H csh,
4274            CSI_TRANSACTIONS csit
4275     Where  csit.transaction_id between from_trans and to_trans
4276     And    csit.creation_date < to_date(purge_to_date, 'YYYY/MM/DD HH24:MI:SS')
4277     And    csh.transaction_id = csit.transaction_id;
4278 
4279     l_ins_asset_hist_csr         ins_asset_hist_csr%ROWTYPE;
4280     l_ins_asset_hist_rec_tab     csi_txn_history_purge_pvt.ins_asset_history_rec_tab;
4281 
4282 
4283 Begin
4284     --
4285     --
4286     Begin
4287       Select object_id
4288       Into   l_table_id
4289       From   csi_object_dictionary
4290       Where  object_name = 'CSI_I_ASSETS_H';
4291     Exception
4292       When no_data_found Then
4293         l_table_id := 7;
4294       When others Then
4295         l_table_id := 7;
4296     End;
4297     --
4298     Begin
4299       Select fnd_profile.value('CSI_TXN_HISTORY_PURGE_BATCH_SIZE')
4300       Into   v_batch
4301       From   dual;
4302     Exception
4303       When no_data_found Then
4304         v_batch := 15000;
4305     End;
4309     --
4306     --
4307     v_start := from_trans;
4308     v_end   := from_trans + v_batch;
4310     If v_end > to_trans Then
4311        v_end := to_trans;
4312     End If;
4313     --
4314  Loop
4315    Begin
4316       SAVEPOINT Asset_Archive;
4317       l_ctr := 0;
4318       --
4319       l_ins_asset_hist_rec_tab.instance_asset_history_id.DELETE;
4320       l_ins_asset_hist_rec_tab.instance_asset_id.DELETE;
4321       l_ins_asset_hist_rec_tab.transaction_id.DELETE;
4322       l_ins_asset_hist_rec_tab.old_instance_id.DELETE;
4323       l_ins_asset_hist_rec_tab.new_instance_id.DELETE;
4324       l_ins_asset_hist_rec_tab.old_fa_asset_id.DELETE;
4325       l_ins_asset_hist_rec_tab.new_fa_asset_id.DELETE;
4326       l_ins_asset_hist_rec_tab.old_asset_quantity.DELETE;
4327       l_ins_asset_hist_rec_tab.new_asset_quantity.DELETE;
4328       l_ins_asset_hist_rec_tab.old_fa_book_type_code.DELETE;
4329       l_ins_asset_hist_rec_tab.new_fa_book_type_code.DELETE;
4330       l_ins_asset_hist_rec_tab.old_fa_location_id.DELETE;
4331       l_ins_asset_hist_rec_tab.new_fa_location_id.DELETE;
4332       l_ins_asset_hist_rec_tab.old_update_status.DELETE;
4333       l_ins_asset_hist_rec_tab.new_update_status.DELETE;
4334       l_ins_asset_hist_rec_tab.old_ast_active_start_date.DELETE;
4335       l_ins_asset_hist_rec_tab.new_ast_active_start_date.DELETE;
4336       l_ins_asset_hist_rec_tab.old_ast_active_end_date.DELETE;
4337       l_ins_asset_hist_rec_tab.new_ast_active_end_date.DELETE;
4338       l_ins_asset_hist_rec_tab.ast_full_dump_flag.DELETE;
4339       l_ins_asset_hist_rec_tab.ast_created_by.DELETE;
4340       l_ins_asset_hist_rec_tab.ast_creation_date.DELETE;
4341       l_ins_asset_hist_rec_tab.ast_last_updated_by.DELETE;
4342       l_ins_asset_hist_rec_tab.ast_last_update_date.DELETE;
4343       l_ins_asset_hist_rec_tab.ast_last_update_login.DELETE;
4344       l_ins_asset_hist_rec_tab.ast_object_version_number.DELETE;
4345       l_ins_asset_hist_rec_tab.ast_security_group_id.DELETE;
4346       l_ins_asset_hist_rec_tab.ast_migrated_flag.DELETE;
4347       --
4348 
4349   For i in ins_asset_hist_csr(v_start,v_end)
4350   Loop
4351       --
4352       l_ctr := l_ctr + 1;
4353       --
4354       Select csi_history_archive_s.Nextval
4355       Into l_archive_id_tbl(l_ctr)
4356       From dual;
4357       --
4358       l_ins_asset_hist_rec_tab.instance_asset_history_id(l_ctr)        :=  i.instance_asset_history_id;
4359       l_ins_asset_hist_rec_tab.instance_asset_id(l_ctr)                :=  i.instance_asset_id;
4360       l_ins_asset_hist_rec_tab.transaction_id(l_ctr)                   :=  i.transaction_id;
4361       l_ins_asset_hist_rec_tab.old_instance_id(l_ctr)                  :=  i.old_instance_id;
4362       l_ins_asset_hist_rec_tab.new_instance_id(l_ctr)                  :=  i.new_instance_id;
4363       l_ins_asset_hist_rec_tab.old_fa_asset_id(l_ctr)                  :=  i.old_fa_asset_id;
4364       l_ins_asset_hist_rec_tab.new_fa_asset_id(l_ctr)                  :=  i.new_fa_asset_id;
4365       l_ins_asset_hist_rec_tab.old_asset_quantity(l_ctr)               :=  i.old_asset_quantity;
4366       l_ins_asset_hist_rec_tab.new_asset_quantity(l_ctr)               :=  i.new_asset_quantity;
4367       l_ins_asset_hist_rec_tab.old_fa_book_type_code(l_ctr)            :=  i.old_fa_book_type_code;
4368       l_ins_asset_hist_rec_tab.new_fa_book_type_code(l_ctr)            :=  i.new_fa_book_type_code;
4369       l_ins_asset_hist_rec_tab.old_fa_location_id(l_ctr)               :=  i.old_fa_location_id;
4370       l_ins_asset_hist_rec_tab.new_fa_location_id(l_ctr)               :=  i.new_fa_location_id;
4371       l_ins_asset_hist_rec_tab.old_update_status(l_ctr)                :=  i.old_update_status;
4372       l_ins_asset_hist_rec_tab.new_update_status(l_ctr)                :=  i.new_update_status;
4373       l_ins_asset_hist_rec_tab.old_ast_active_start_date(l_ctr)        :=  i.old_active_start_date;
4374       l_ins_asset_hist_rec_tab.new_ast_active_start_date(l_ctr)        :=  i.new_active_start_date;
4375       l_ins_asset_hist_rec_tab.old_ast_active_end_date(l_ctr)          :=  i.old_active_end_date;
4376       l_ins_asset_hist_rec_tab.new_ast_active_end_date(l_ctr)          :=  i.new_active_end_date;
4377       l_ins_asset_hist_rec_tab.ast_full_dump_flag(l_ctr)	           :=  i.full_dump_flag;
4378       l_ins_asset_hist_rec_tab.ast_created_by(l_ctr)                   :=  i.created_by;
4379       l_ins_asset_hist_rec_tab.ast_creation_date(l_ctr)                :=  i.creation_date;
4380       l_ins_asset_hist_rec_tab.ast_last_updated_by(l_ctr)              :=  i.last_updated_by;
4381       l_ins_asset_hist_rec_tab.ast_last_update_date(l_ctr)             :=  i.last_update_date;
4382       l_ins_asset_hist_rec_tab.ast_last_update_login(l_ctr)            :=  i.last_update_login;
4383       l_ins_asset_hist_rec_tab.ast_object_version_number(l_ctr)	       :=  i.object_version_number;
4384       l_ins_asset_hist_rec_tab.ast_security_group_id(l_ctr)	           :=  i.security_group_id;
4385       l_ins_asset_hist_rec_tab.ast_migrated_flag(l_ctr)	               :=  i.migrated_flag;
4386 
4387    End Loop;
4388 
4389       -- get the party history count for the transaction range
4390       l_cnt := l_ins_asset_hist_rec_tab.instance_asset_history_id.count;
4391       --
4392       Debug('');
4393       Debug('');
4394       Debug('Number of Instance Asset history records archived:'||to_char(l_cnt));
4395       Debug('');
4396       Debug('');
4397       --
4398       If l_cnt > 0 Then
4399 
4400         FORALL i IN 1 .. l_cnt
4401 
4402          Insert Into CSI_HISTORY_ARCHIVE
4403          (
4404 
4405             HISTORY_ARCHIVE_ID
4406            ,OBJECT_ID
4407            ,ENTITY_HISTORY_ID
4408            ,TRANSACTION_ID
4409            ,ENTITY_ID
4410            ,COL_NUM_01
4411            ,COL_NUM_02
4412            ,COL_NUM_03
4413            ,COL_NUM_04
4414            ,COL_NUM_05
4415            ,COL_NUM_06
4416            ,COL_NUM_07
4417            ,COL_NUM_08
4418            ,COL_NUM_37
4419            ,COL_NUM_38
4423            ,COL_CHAR_01
4420            ,COL_NUM_39
4421            ,COL_NUM_40
4422            ,COL_NUM_41
4424            ,COL_CHAR_02
4425            ,COL_CHAR_03
4426            ,COL_CHAR_04
4427            ,COL_CHAR_71
4428            ,COL_CHAR_72
4429            ,COL_DATE_01
4430            ,COL_DATE_02
4431            ,COL_DATE_03
4432            ,COL_DATE_04
4433            ,COL_DATE_11
4434            ,COL_DATE_12
4435            ,CONTEXT
4436            ,ATTRIBUTE1
4437            ,ATTRIBUTE2
4438            ,ATTRIBUTE3
4439            ,ATTRIBUTE4
4440            ,ATTRIBUTE5
4441            ,ATTRIBUTE6
4442            ,ATTRIBUTE7
4443            ,ATTRIBUTE8
4444            ,ATTRIBUTE9
4445            ,ATTRIBUTE10
4446            ,ATTRIBUTE11
4447            ,ATTRIBUTE12
4448            ,ATTRIBUTE13
4449            ,ATTRIBUTE14
4450            ,ATTRIBUTE15
4451            ,CREATED_BY
4452            ,CREATION_DATE
4453            ,LAST_UPDATED_BY
4454            ,LAST_UPDATE_DATE
4455            ,LAST_UPDATE_LOGIN
4456            ,OBJECT_VERSION_NUMBER
4457            ,SECURITY_GROUP_ID
4458            )
4459            Values
4460            (
4461            l_archive_id_tbl(i),
4462            l_table_id,
4463            l_ins_asset_hist_rec_tab.instance_asset_history_id(i),
4464            l_ins_asset_hist_rec_tab.transaction_id(i),
4465            l_ins_asset_hist_rec_tab.instance_asset_id(i),
4466            l_ins_asset_hist_rec_tab.old_instance_id(i),
4467            l_ins_asset_hist_rec_tab.new_instance_id(i),
4468            l_ins_asset_hist_rec_tab.old_fa_asset_id(i),
4469            l_ins_asset_hist_rec_tab.new_fa_asset_id(i),
4470            l_ins_asset_hist_rec_tab.old_asset_quantity(i),
4471            l_ins_asset_hist_rec_tab.new_asset_quantity(i),
4472            l_ins_asset_hist_rec_tab.old_fa_location_id(i),
4473            l_ins_asset_hist_rec_tab.new_fa_location_id(i),
4474            l_ins_asset_hist_rec_tab.ast_created_by(i),
4475            l_ins_asset_hist_rec_tab.ast_last_updated_by(i),
4476            l_ins_asset_hist_rec_tab.ast_last_update_login(i),
4477 	   l_ins_asset_hist_rec_tab.ast_object_version_number(i), -- obj_ver_num
4478            l_ins_asset_hist_rec_tab.ast_security_group_id(i), -- sec_grp_id
4479            l_ins_asset_hist_rec_tab.old_fa_book_type_code(i),
4480            l_ins_asset_hist_rec_tab.new_fa_book_type_code(i),
4481            l_ins_asset_hist_rec_tab.old_update_status(i),
4482            l_ins_asset_hist_rec_tab.new_update_status(i),
4483            l_ins_asset_hist_rec_tab.ast_full_dump_flag(i), --'N', dump_flag
4484            l_ins_asset_hist_rec_tab.ast_migrated_flag(i), -- mig_flag
4485            l_ins_asset_hist_rec_tab.old_ast_active_start_date(i),
4486            l_ins_asset_hist_rec_tab.new_ast_active_start_date(i),
4487            l_ins_asset_hist_rec_tab.old_ast_active_end_date(i),
4488            l_ins_asset_hist_rec_tab.new_ast_active_end_date(i),
4489            l_ins_asset_hist_rec_tab.ast_creation_date(i),
4490            l_ins_asset_hist_rec_tab.ast_last_update_date(i),
4491            null,
4492            null,
4493            null,
4494            null,
4495            null,
4496            null,
4497            null,
4498            null,
4499            null,
4500            null,
4501            null,
4502            null,
4503            null,
4504            null,
4505            null,
4506            null,
4507            l_user_id,
4508            sysdate,
4509            l_user_id,
4510            sysdate,
4511            l_login_id,
4512            1,
4513            null
4514            );
4515 
4516          -- Purge the corresonding Archive data from the Instance Asset history tables
4517 
4518             FORALL i IN 1 .. l_cnt
4519 
4520                Delete From CSI_I_ASSETS_H
4521                Where instance_asset_history_id = l_ins_asset_hist_rec_tab.instance_asset_history_id(i);
4522 
4523        End If; -- if l_cnt > 0
4524        --
4525        Exit When from_trans = to_trans;
4526        Exit When v_end = to_trans;
4527 
4528      v_start := v_end + 1;
4529      v_end   := v_start + v_batch;
4530      --
4531      --
4532 	 If v_start > to_trans Then
4533 	    v_start := to_trans;
4534 	 End If;
4535 	 --
4536 	 If v_end > to_trans then
4537 	    v_end := to_trans;
4538 	 End If;
4539      --
4540      Commit;
4541      --
4542    Exception
4543       when others then
4544          Debug(substr(sqlerrm,1,255));
4545          ROLLBACK to Asset_Archive;
4546    End;
4547  End Loop; -- Local Batch Loop
4548  Commit;
4549    --
4550 END; -- Procedure InstAssets_Archive
4551 
4552 
4553 PROCEDURE Ver_Labels_archive( errbuf       OUT NOCOPY VARCHAR2,
4554                               retcode      OUT NOCOPY NUMBER,
4555                               from_trans   IN  NUMBER,
4556                               to_trans     IN  NUMBER,
4557                               purge_to_date IN VARCHAR2 )
4558 IS
4559 
4560     l_archive_id      NUMBER;
4561     l_ctr             NUMBER := 0;
4562     l_cnt             NUMBER;
4563     l_table_id        NUMBER;
4564     l_user_id         NUMBER := FND_GLOBAL.USER_ID;
4565     l_login_id        NUMBER := FND_GLOBAL.CONC_LOGIN_ID;
4566     v_batch           NUMBER := 15000;
4567     v_start           NUMBER;
4568     v_end             NUMBER;
4569 
4570     Type NUMLIST IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
4571     l_archive_id_tbl   NUMLIST;
4572 
4573     Cursor ver_label_hist_csr (p_from_trans IN NUMBER,
4577            CSI_TRANSACTIONS csit
4574                                p_to_trans   IN NUMBER) IS
4575     Select csh.*
4576     From   CSI_I_VERSION_LABELS_H csh,
4578     Where  csit.transaction_id between from_trans and to_trans
4579     And    csit.creation_date < to_date(purge_to_date, 'YYYY/MM/DD HH24:MI:SS')
4580     And    csh.transaction_id = csit.transaction_id;
4581 
4582     l_ver_label_hist_csr         ver_label_hist_csr%ROWTYPE;
4583     l_ver_label_hist_rec_tab     csi_txn_history_purge_pvt.ver_label_history_rec_tab;
4584 
4585 
4586 Begin
4587     --
4588     --
4589     Begin
4590       Select object_id
4591       Into   l_table_id
4592       From   csi_object_dictionary
4593       Where  object_name = 'CSI_I_VERSION_LABELS_H';
4594     Exception
4595       When no_data_found Then
4596         l_table_id := 8;
4597       When others Then
4598         l_table_id := 8;
4599     End;
4600     --
4601     Begin
4602       Select fnd_profile.value('CSI_TXN_HISTORY_PURGE_BATCH_SIZE')
4603       Into   v_batch
4604       From   dual;
4605     Exception
4606       When no_data_found Then
4607         v_batch := 15000;
4608     End;
4609     --
4610     v_start := from_trans;
4611     v_end   := from_trans + v_batch;
4612     --
4613     If v_end > to_trans Then
4614        v_end := to_trans;
4615     End If;
4616     --
4617  Loop
4618    Begin
4619       SAVEPOINT Version_Archive;
4620       l_ctr := 0;
4621       --
4622       l_ver_label_hist_rec_tab.version_label_history_id.DELETE;
4623       l_ver_label_hist_rec_tab.version_label_id.DELETE;
4624       l_ver_label_hist_rec_tab.transaction_id.DELETE;
4625       l_ver_label_hist_rec_tab.old_version_label.DELETE;
4626       l_ver_label_hist_rec_tab.new_version_label.DELETE;
4627       l_ver_label_hist_rec_tab.old_ver_description.DELETE;
4628       l_ver_label_hist_rec_tab.new_ver_description.DELETE;
4629       l_ver_label_hist_rec_tab.old_date_time_stamp.DELETE;
4630       l_ver_label_hist_rec_tab.new_date_time_stamp.DELETE;
4631       l_ver_label_hist_rec_tab.old_ver_active_start_date.DELETE;
4632       l_ver_label_hist_rec_tab.new_ver_active_start_date.DELETE;
4633       l_ver_label_hist_rec_tab.old_ver_active_end_date.DELETE;
4634       l_ver_label_hist_rec_tab.new_ver_active_end_date.DELETE;
4635       l_ver_label_hist_rec_tab.old_ver_context.DELETE;
4636       l_ver_label_hist_rec_tab.new_ver_context.DELETE;
4637       l_ver_label_hist_rec_tab.old_ver_attribute1.DELETE;
4638       l_ver_label_hist_rec_tab.new_ver_attribute1.DELETE;
4639       l_ver_label_hist_rec_tab.old_ver_attribute2.DELETE;
4640       l_ver_label_hist_rec_tab.new_ver_attribute2.DELETE;
4641       l_ver_label_hist_rec_tab.old_ver_attribute3.DELETE;
4642       l_ver_label_hist_rec_tab.new_ver_attribute3.DELETE;
4643       l_ver_label_hist_rec_tab.old_ver_attribute4.DELETE;
4644       l_ver_label_hist_rec_tab.new_ver_attribute4.DELETE;
4645       l_ver_label_hist_rec_tab.old_ver_attribute5.DELETE;
4646       l_ver_label_hist_rec_tab.new_ver_attribute5.DELETE;
4647       l_ver_label_hist_rec_tab.old_ver_attribute6.DELETE;
4648       l_ver_label_hist_rec_tab.new_ver_attribute6.DELETE;
4649       l_ver_label_hist_rec_tab.old_ver_attribute7.DELETE;
4650       l_ver_label_hist_rec_tab.new_ver_attribute7.DELETE;
4651       l_ver_label_hist_rec_tab.old_ver_attribute8.DELETE;
4652       l_ver_label_hist_rec_tab.new_ver_attribute8.DELETE;
4653       l_ver_label_hist_rec_tab.old_ver_attribute9.DELETE;
4654       l_ver_label_hist_rec_tab.new_ver_attribute9.DELETE;
4655       l_ver_label_hist_rec_tab.old_ver_attribute10.DELETE;
4656       l_ver_label_hist_rec_tab.new_ver_attribute10.DELETE;
4657       l_ver_label_hist_rec_tab.old_ver_attribute11.DELETE;
4658       l_ver_label_hist_rec_tab.new_ver_attribute11.DELETE;
4659       l_ver_label_hist_rec_tab.old_ver_attribute12.DELETE;
4660       l_ver_label_hist_rec_tab.new_ver_attribute12.DELETE;
4661       l_ver_label_hist_rec_tab.old_ver_attribute13.DELETE;
4662       l_ver_label_hist_rec_tab.new_ver_attribute13.DELETE;
4663       l_ver_label_hist_rec_tab.old_ver_attribute14.DELETE;
4664       l_ver_label_hist_rec_tab.new_ver_attribute14.DELETE;
4665       l_ver_label_hist_rec_tab.old_ver_attribute15.DELETE;
4666       l_ver_label_hist_rec_tab.new_ver_attribute15.DELETE;
4667       l_ver_label_hist_rec_tab.ver_full_dump_flag.DELETE;
4668       l_ver_label_hist_rec_tab.ver_created_by.DELETE;
4669       l_ver_label_hist_rec_tab.ver_creation_date.DELETE;
4670       l_ver_label_hist_rec_tab.ver_last_updated_by.DELETE;
4671       l_ver_label_hist_rec_tab.ver_last_update_date.DELETE;
4672       l_ver_label_hist_rec_tab.ver_last_update_login.DELETE;
4673       l_ver_label_hist_rec_tab.ver_object_version_number.DELETE;
4674       l_ver_label_hist_rec_tab.ver_security_group_id.DELETE;
4675       l_ver_label_hist_rec_tab.ver_migrated_flag.DELETE;
4676       --
4677 
4678   For i in ver_label_hist_csr(v_start,v_end)
4679   Loop
4680       --
4681       l_ctr := l_ctr + 1;
4682       --
4683       Select csi_history_archive_s.Nextval
4684       Into l_archive_id_tbl(l_ctr)
4685       From dual;
4686       --
4687       l_ver_label_hist_rec_tab.version_label_history_id(l_ctr)         :=  i.version_label_history_id;
4688       l_ver_label_hist_rec_tab.version_label_id(l_ctr)                 :=  i.version_label_id;
4689       l_ver_label_hist_rec_tab.transaction_id(l_ctr)                   :=  i.transaction_id;
4690       l_ver_label_hist_rec_tab.old_version_label(l_ctr)                :=  i.old_version_label;
4691       l_ver_label_hist_rec_tab.new_version_label(l_ctr)                :=  i.new_version_label;
4692       l_ver_label_hist_rec_tab.old_ver_description(l_ctr)              :=  i.old_description;
4693       l_ver_label_hist_rec_tab.new_ver_description(l_ctr)              :=  i.new_description;
4694       l_ver_label_hist_rec_tab.old_date_time_stamp(l_ctr)              :=  i.old_date_time_stamp;
4695       l_ver_label_hist_rec_tab.new_date_time_stamp(l_ctr)              :=  i.new_date_time_stamp;
4696       l_ver_label_hist_rec_tab.old_ver_active_start_date(l_ctr)        :=  i.old_active_start_date;
4697       l_ver_label_hist_rec_tab.new_ver_active_start_date(l_ctr)        :=  i.new_active_start_date;
4698       l_ver_label_hist_rec_tab.old_ver_active_end_date(l_ctr)          :=  i.old_active_end_date;
4702       l_ver_label_hist_rec_tab.old_ver_attribute1(l_ctr)	           :=  i.old_attribute1;
4699       l_ver_label_hist_rec_tab.new_ver_active_end_date(l_ctr)          :=  i.new_active_end_date;
4700       l_ver_label_hist_rec_tab.old_ver_context(l_ctr)	               :=  i.old_context;
4701       l_ver_label_hist_rec_tab.new_ver_context(l_ctr)	               :=  i.new_context;
4703       l_ver_label_hist_rec_tab.new_ver_attribute1(l_ctr)	           :=  i.new_attribute1;
4704       l_ver_label_hist_rec_tab.old_ver_attribute2(l_ctr)	           :=  i.old_attribute2;
4705       l_ver_label_hist_rec_tab.new_ver_attribute2(l_ctr)	           :=  i.new_attribute2;
4706       l_ver_label_hist_rec_tab.old_ver_attribute3(l_ctr)	           :=  i.old_attribute3;
4707       l_ver_label_hist_rec_tab.new_ver_attribute3(l_ctr)	           :=  i.new_attribute3;
4708       l_ver_label_hist_rec_tab.old_ver_attribute4(l_ctr)	           :=  i.old_attribute4;
4709       l_ver_label_hist_rec_tab.new_ver_attribute4(l_ctr)	           :=  i.new_attribute4;
4710       l_ver_label_hist_rec_tab.old_ver_attribute5(l_ctr)	           :=  i.old_attribute5;
4711       l_ver_label_hist_rec_tab.new_ver_attribute5(l_ctr)	           :=  i.new_attribute5;
4712       l_ver_label_hist_rec_tab.old_ver_attribute6(l_ctr)	           :=  i.old_attribute6;
4713       l_ver_label_hist_rec_tab.new_ver_attribute6(l_ctr)	           :=  i.new_attribute6;
4714       l_ver_label_hist_rec_tab.old_ver_attribute7(l_ctr)	           :=  i.old_attribute7;
4715       l_ver_label_hist_rec_tab.new_ver_attribute7(l_ctr)	           :=  i.new_attribute7;
4716       l_ver_label_hist_rec_tab.old_ver_attribute8(l_ctr)	           :=  i.old_attribute8;
4717       l_ver_label_hist_rec_tab.new_ver_attribute8(l_ctr)	           :=  i.new_attribute8;
4718       l_ver_label_hist_rec_tab.old_ver_attribute9(l_ctr)	           :=  i.old_attribute9;
4719       l_ver_label_hist_rec_tab.new_ver_attribute9(l_ctr)	           :=  i.new_attribute9;
4720       l_ver_label_hist_rec_tab.old_ver_attribute10(l_ctr)	           :=  i.old_attribute10;
4721       l_ver_label_hist_rec_tab.new_ver_attribute10(l_ctr)	           :=  i.new_attribute10;
4722       l_ver_label_hist_rec_tab.old_ver_attribute11(l_ctr)      	       :=  i.old_attribute11;
4723       l_ver_label_hist_rec_tab.new_ver_attribute11(l_ctr)	           :=  i.new_attribute11;
4724       l_ver_label_hist_rec_tab.old_ver_attribute12(l_ctr)	           :=  i.old_attribute12;
4725       l_ver_label_hist_rec_tab.new_ver_attribute12(l_ctr)	           :=  i.new_attribute12;
4726       l_ver_label_hist_rec_tab.old_ver_attribute13(l_ctr)	           :=  i.old_attribute13;
4727       l_ver_label_hist_rec_tab.new_ver_attribute13(l_ctr)	           :=  i.new_attribute13;
4728       l_ver_label_hist_rec_tab.old_ver_attribute14(l_ctr)	           :=  i.old_attribute14;
4729       l_ver_label_hist_rec_tab.new_ver_attribute14(l_ctr)	           :=  i.new_attribute14;
4730       l_ver_label_hist_rec_tab.old_ver_attribute15(l_ctr)	           :=  i.old_attribute15;
4731       l_ver_label_hist_rec_tab.new_ver_attribute15(l_ctr)	           :=  i.new_attribute15;
4732       l_ver_label_hist_rec_tab.ver_full_dump_flag(l_ctr)	           :=  i.full_dump_flag;
4733       l_ver_label_hist_rec_tab.ver_created_by(l_ctr)                   :=  i.created_by;
4734       l_ver_label_hist_rec_tab.ver_creation_date(l_ctr)                :=  i.creation_date;
4735       l_ver_label_hist_rec_tab.ver_last_updated_by(l_ctr)              :=  i.last_updated_by;
4736       l_ver_label_hist_rec_tab.ver_last_update_date(l_ctr)             :=  i.last_update_date;
4737       l_ver_label_hist_rec_tab.ver_last_update_login(l_ctr)            :=  i.last_update_login;
4738       l_ver_label_hist_rec_tab.ver_object_version_number(l_ctr)	       :=  i.object_version_number;
4739       l_ver_label_hist_rec_tab.ver_security_group_id(l_ctr)	           :=  i.security_group_id;
4740       l_ver_label_hist_rec_tab.ver_migrated_flag(l_ctr)	               :=  i.migrated_flag;
4741 
4742    End Loop;
4743 
4744       -- get the party history count for the transaction range
4745       l_cnt := l_ver_label_hist_rec_tab.version_label_history_id.count;
4746       --
4747       Debug('');
4748       Debug('');
4749       Debug('Number of Instance Version labels history records archived:'||to_char(l_cnt));
4750       Debug('');
4751       Debug('');
4752       --
4753       If l_cnt > 0 Then
4754 
4755         FORALL i IN 1 .. l_cnt
4756 
4757          Insert Into CSI_HISTORY_ARCHIVE
4758          (
4759             HISTORY_ARCHIVE_ID
4760            ,OBJECT_ID
4761            ,ENTITY_HISTORY_ID
4762            ,TRANSACTION_ID
4763            ,ENTITY_ID
4764            ,COL_NUM_37
4765            ,COL_NUM_38
4766            ,COL_NUM_39
4767            ,COL_NUM_40
4768            ,COL_NUM_41
4769            ,COL_CHAR_01
4770            ,COL_CHAR_02
4771            ,COL_CHAR_03
4772            ,COL_CHAR_04
4773            ,COL_CHAR_31
4774            ,COL_CHAR_32
4775            ,COL_CHAR_33
4776            ,COL_CHAR_34
4777            ,COL_CHAR_35
4778            ,COL_CHAR_36
4779            ,COL_CHAR_37
4780            ,COL_CHAR_38
4781            ,COL_CHAR_39
4782            ,COL_CHAR_40
4783            ,COL_CHAR_41
4784            ,COL_CHAR_42
4785            ,COL_CHAR_43
4786            ,COL_CHAR_44
4787            ,COL_CHAR_45
4788            ,COL_CHAR_46
4789            ,COL_CHAR_47
4790            ,COL_CHAR_48
4791            ,COL_CHAR_49
4792            ,COL_CHAR_50
4793            ,COL_CHAR_51
4794            ,COL_CHAR_52
4795            ,COL_CHAR_53
4796            ,COL_CHAR_54
4797            ,COL_CHAR_55
4798            ,COL_CHAR_56
4799            ,COL_CHAR_57
4800            ,COL_CHAR_58
4801            ,COL_CHAR_59
4802            ,COL_CHAR_60
4803            ,COL_CHAR_61
4804            ,COL_CHAR_62
4805            ,COL_CHAR_71
4806            ,COL_CHAR_72
4807            ,COL_DATE_01
4808            ,COL_DATE_02
4809            ,COL_DATE_03
4810            ,COL_DATE_04
4811            ,COL_DATE_05
4812            ,COL_DATE_06
4816            ,ATTRIBUTE1
4813            ,COL_DATE_11
4814            ,COL_DATE_12
4815            ,CONTEXT
4817            ,ATTRIBUTE2
4818            ,ATTRIBUTE3
4819            ,ATTRIBUTE4
4820            ,ATTRIBUTE5
4821            ,ATTRIBUTE6
4822            ,ATTRIBUTE7
4823            ,ATTRIBUTE8
4824            ,ATTRIBUTE9
4825            ,ATTRIBUTE10
4826            ,ATTRIBUTE11
4827            ,ATTRIBUTE12
4828            ,ATTRIBUTE13
4829            ,ATTRIBUTE14
4830            ,ATTRIBUTE15
4831            ,CREATED_BY
4832            ,CREATION_DATE
4833            ,LAST_UPDATED_BY
4834            ,LAST_UPDATE_DATE
4835            ,LAST_UPDATE_LOGIN
4836            ,OBJECT_VERSION_NUMBER
4837            ,SECURITY_GROUP_ID
4838            )
4839            Values
4840            (
4841            l_archive_id_tbl(i),
4842            l_table_id,
4843            l_ver_label_hist_rec_tab.version_label_history_id(i),
4844            l_ver_label_hist_rec_tab.transaction_id(i),
4845            l_ver_label_hist_rec_tab.version_label_id(i),
4846            l_ver_label_hist_rec_tab.ver_created_by(i),
4847            l_ver_label_hist_rec_tab.ver_last_updated_by(i),
4848            l_ver_label_hist_rec_tab.ver_last_update_login(i),
4849            l_ver_label_hist_rec_tab.ver_object_version_number(i), -- obj_ver_num
4850            l_ver_label_hist_rec_tab.ver_security_group_id(i), -- sec_grp_id
4851            l_ver_label_hist_rec_tab.old_version_label(i),
4852            l_ver_label_hist_rec_tab.new_version_label(i),
4853            l_ver_label_hist_rec_tab.old_ver_description(i),
4854            l_ver_label_hist_rec_tab.new_ver_description(i),
4855            l_ver_label_hist_rec_tab.old_ver_context(i),
4856            l_ver_label_hist_rec_tab.new_ver_context(i),
4857            l_ver_label_hist_rec_tab.old_ver_attribute1(i),
4858            l_ver_label_hist_rec_tab.new_ver_attribute1(i),
4859            l_ver_label_hist_rec_tab.old_ver_attribute2(i),
4860            l_ver_label_hist_rec_tab.new_ver_attribute2(i),
4861            l_ver_label_hist_rec_tab.old_ver_attribute3(i),
4862            l_ver_label_hist_rec_tab.new_ver_attribute3(i),
4863            l_ver_label_hist_rec_tab.old_ver_attribute4(i),
4864            l_ver_label_hist_rec_tab.new_ver_attribute4(i),
4865            l_ver_label_hist_rec_tab.old_ver_attribute5(i),
4866            l_ver_label_hist_rec_tab.new_ver_attribute5(i),
4867            l_ver_label_hist_rec_tab.old_ver_attribute6(i),
4868            l_ver_label_hist_rec_tab.new_ver_attribute6(i),
4869            l_ver_label_hist_rec_tab.old_ver_attribute7(i),
4870            l_ver_label_hist_rec_tab.new_ver_attribute7(i),
4871            l_ver_label_hist_rec_tab.old_ver_attribute8(i),
4872            l_ver_label_hist_rec_tab.new_ver_attribute8(i),
4873            l_ver_label_hist_rec_tab.old_ver_attribute9(i),
4874            l_ver_label_hist_rec_tab.new_ver_attribute9(i),
4875            l_ver_label_hist_rec_tab.old_ver_attribute10(i),
4876            l_ver_label_hist_rec_tab.new_ver_attribute10(i),
4877            l_ver_label_hist_rec_tab.old_ver_attribute11(i),
4878            l_ver_label_hist_rec_tab.new_ver_attribute11(i),
4879            l_ver_label_hist_rec_tab.old_ver_attribute12(i),
4880            l_ver_label_hist_rec_tab.new_ver_attribute12(i),
4881            l_ver_label_hist_rec_tab.old_ver_attribute13(i),
4882            l_ver_label_hist_rec_tab.new_ver_attribute13(i),
4883            l_ver_label_hist_rec_tab.old_ver_attribute14(i),
4884            l_ver_label_hist_rec_tab.new_ver_attribute14(i),
4885            l_ver_label_hist_rec_tab.old_ver_attribute15(i),
4886            l_ver_label_hist_rec_tab.new_ver_attribute15(i),
4887            l_ver_label_hist_rec_tab.ver_full_dump_flag(i), --'N', dump_flag
4888            l_ver_label_hist_rec_tab.ver_migrated_flag(i), -- mig_flag
4889            l_ver_label_hist_rec_tab.old_ver_active_start_date(i),
4890            l_ver_label_hist_rec_tab.new_ver_active_start_date(i),
4891            l_ver_label_hist_rec_tab.old_ver_active_end_date(i),
4892            l_ver_label_hist_rec_tab.new_ver_active_end_date(i),
4893            l_ver_label_hist_rec_tab.old_date_time_stamp(i),
4894            l_ver_label_hist_rec_tab.new_date_time_stamp(i),
4895            l_ver_label_hist_rec_tab.ver_creation_date(i),
4896            l_ver_label_hist_rec_tab.ver_last_update_date(i),
4897            null,
4898            null,
4899            null,
4900            null,
4901            null,
4902            null,
4903            null,
4904            null,
4905            null,
4906            null,
4907            null,
4908            null,
4909            null,
4910            null,
4911            null,
4912            null,
4913            l_user_id,
4914            sysdate,
4915            l_user_id,
4916            sysdate,
4917            l_login_id,
4918            1,
4919            null
4920            );
4921 
4922          -- Purge the corresonding Archive data from the Instance Ver. Labels history tables
4923 
4927               Where version_label_history_id = l_ver_label_hist_rec_tab.version_label_history_id(i);
4924             FORALL i IN 1 .. l_cnt
4925 
4926               Delete From CSI_I_VERSION_LABELS_H
4928 
4929 
4930        End If; -- if l_cnt > 0
4931        --
4932        Exit When from_trans = to_trans;
4933        Exit When v_end = to_trans;
4934 
4935      v_start := v_end + 1;
4936      v_end   := v_start + v_batch;
4937      --
4938      --
4939 	 If v_start > to_trans Then
4940 	    v_start := to_trans;
4941 	 End If;
4942 	 --
4943 	 If v_end > to_trans then
4944 	    v_end := to_trans;
4945 	 End If;
4946      --
4947      Commit;
4948      --
4949    Exception
4950       when others then
4951          Debug(substr(sqlerrm,1,255));
4952          ROLLBACK to Version_Archive;
4953    End;
4954  End Loop; -- Local Batch Loop
4955  Commit;
4956    --
4957 END; -- Procedure VersionLabels_Archive
4958 
4959 
4960 --
4961 -- This program is used to archive the Operating units history. It accepts from and to transactions
4962 -- as the input parameters.
4963 --
4964 
4965 PROCEDURE Inst_Relnships_archive( errbuf       OUT NOCOPY VARCHAR2,
4966                                   retcode      OUT NOCOPY NUMBER,
4967                                   from_trans   IN  NUMBER,
4968                                   to_trans     IN  NUMBER,
4969                                   purge_to_date IN VARCHAR2 )
4970 IS
4971 
4972     l_archive_id      NUMBER;
4973     l_ctr             NUMBER := 0;
4974     l_cnt             NUMBER;
4975     l_table_id        NUMBER;
4976     l_user_id         NUMBER := FND_GLOBAL.USER_ID;
4977     l_login_id        NUMBER := FND_GLOBAL.CONC_LOGIN_ID;
4978     v_batch           NUMBER := 15000;
4979     v_start           NUMBER;
4980     v_end             NUMBER;
4981 
4982     Type NUMLIST IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
4983     l_archive_id_tbl   NUMLIST;
4984 
4985     Cursor rel_hist_csr (p_from_trans IN NUMBER,
4986                          p_to_trans   IN NUMBER) IS
4987     Select csh.*
4988     From   CSI_II_RELATIONSHIPS_H csh,
4989            CSI_TRANSACTIONS csit
4990     Where  csit.transaction_id between from_trans and to_trans
4991     And    csit.creation_date < to_date(purge_to_date, 'YYYY/MM/DD HH24:MI:SS')
4992     And    csh.transaction_id = csit.transaction_id;
4993 
4994     l_rel_hist_csr         rel_hist_csr%ROWTYPE;
4995     l_rel_hist_rec_tab     csi_txn_history_purge_pvt.relationship_history_rec_tab;
4996 
4997 
4998 Begin
4999     --
5000     --
5001     Begin
5002       Select object_id
5003       Into   l_table_id
5004       From   csi_object_dictionary
5005       Where  object_name = 'CSI_II_RELATIONSHIPS_H';
5006     Exception
5007       When no_data_found Then
5008         l_table_id := 9;
5009       When others Then
5010         l_table_id := 9;
5011     End;
5012     --
5013     Begin
5014       Select fnd_profile.value('CSI_TXN_HISTORY_PURGE_BATCH_SIZE')
5015       Into   v_batch
5016       From   dual;
5017     Exception
5018       When no_data_found Then
5019         v_batch := 15000;
5020     End;
5021     --
5022     v_start := from_trans;
5023     v_end   := from_trans + v_batch;
5024     --
5025     If v_end > to_trans Then
5026        v_end := to_trans;
5027     End If;
5028     --
5029  Loop
5030    Begin
5031       SAVEPOINT Rel_Archive;
5032       l_ctr := 0;
5033       --
5034       l_rel_hist_rec_tab.relationship_history_id.DELETE;
5035       l_rel_hist_rec_tab.relationship_id.DELETE;
5036       l_rel_hist_rec_tab.transaction_id.DELETE;
5037       l_rel_hist_rec_tab.old_subject_id.DELETE;
5038       l_rel_hist_rec_tab.new_subject_id.DELETE;
5039       l_rel_hist_rec_tab.old_position_reference.DELETE;
5040       l_rel_hist_rec_tab.new_position_reference.DELETE;
5041       l_rel_hist_rec_tab.old_rel_active_start_date.DELETE;
5042       l_rel_hist_rec_tab.new_rel_active_start_date.DELETE;
5043       l_rel_hist_rec_tab.old_rel_active_end_date.DELETE;
5044       l_rel_hist_rec_tab.new_rel_active_end_date.DELETE;
5045       l_rel_hist_rec_tab.old_mandatory_flag.DELETE;
5046       l_rel_hist_rec_tab.new_mandatory_flag.DELETE;
5047       l_rel_hist_rec_tab.old_rel_context.DELETE;
5048       l_rel_hist_rec_tab.new_rel_context.DELETE;
5049       l_rel_hist_rec_tab.old_rel_attribute1.DELETE;
5050       l_rel_hist_rec_tab.new_rel_attribute1.DELETE;
5051       l_rel_hist_rec_tab.old_rel_attribute2.DELETE;
5052       l_rel_hist_rec_tab.new_rel_attribute2.DELETE;
5053       l_rel_hist_rec_tab.old_rel_attribute3.DELETE;
5054       l_rel_hist_rec_tab.new_rel_attribute3.DELETE;
5055       l_rel_hist_rec_tab.old_rel_attribute4.DELETE;
5056       l_rel_hist_rec_tab.new_rel_attribute4.DELETE;
5057       l_rel_hist_rec_tab.old_rel_attribute5.DELETE;
5058       l_rel_hist_rec_tab.new_rel_attribute5.DELETE;
5059       l_rel_hist_rec_tab.old_rel_attribute6.DELETE;
5060       l_rel_hist_rec_tab.new_rel_attribute6.DELETE;
5061       l_rel_hist_rec_tab.old_rel_attribute7.DELETE;
5062       l_rel_hist_rec_tab.new_rel_attribute7.DELETE;
5063       l_rel_hist_rec_tab.old_rel_attribute8.DELETE;
5064       l_rel_hist_rec_tab.new_rel_attribute8.DELETE;
5065       l_rel_hist_rec_tab.old_rel_attribute9.DELETE;
5066       l_rel_hist_rec_tab.new_rel_attribute9.DELETE;
5067       l_rel_hist_rec_tab.old_rel_attribute10.DELETE;
5068       l_rel_hist_rec_tab.new_rel_attribute10.DELETE;
5069       l_rel_hist_rec_tab.old_rel_attribute11.DELETE;
5070       l_rel_hist_rec_tab.new_rel_attribute11.DELETE;
5071       l_rel_hist_rec_tab.old_rel_attribute12.DELETE;
5072       l_rel_hist_rec_tab.new_rel_attribute12.DELETE;
5073       l_rel_hist_rec_tab.old_rel_attribute13.DELETE;
5074       l_rel_hist_rec_tab.new_rel_attribute13.DELETE;
5078       l_rel_hist_rec_tab.new_rel_attribute15.DELETE;
5075       l_rel_hist_rec_tab.old_rel_attribute14.DELETE;
5076       l_rel_hist_rec_tab.new_rel_attribute14.DELETE;
5077       l_rel_hist_rec_tab.old_rel_attribute15.DELETE;
5079       l_rel_hist_rec_tab.rel_full_dump_flag.DELETE;
5080       l_rel_hist_rec_tab.rel_created_by.DELETE;
5081       l_rel_hist_rec_tab.rel_creation_date.DELETE;
5082       l_rel_hist_rec_tab.rel_last_updated_by.DELETE;
5083       l_rel_hist_rec_tab.rel_last_update_date.DELETE;
5084       l_rel_hist_rec_tab.rel_last_update_login.DELETE;
5085       l_rel_hist_rec_tab.rel_object_version_number.DELETE;
5086       l_rel_hist_rec_tab.rel_security_group_id.DELETE;
5087       l_rel_hist_rec_tab.rel_migrated_flag.DELETE;
5088       --
5089 
5090   For i in rel_hist_csr(v_start,v_end)
5091   Loop
5092       --
5093       l_ctr := l_ctr + 1;
5094       --
5095       Select csi_history_archive_s.Nextval
5096       Into l_archive_id_tbl(l_ctr)
5097       From dual;
5098       --
5099       l_rel_hist_rec_tab.relationship_history_id(l_ctr)        :=  i.relationship_history_id;
5100       l_rel_hist_rec_tab.relationship_id(l_ctr)                :=  i.relationship_id;
5101       l_rel_hist_rec_tab.transaction_id(l_ctr)                 :=  i.transaction_id;
5102       l_rel_hist_rec_tab.old_subject_id(l_ctr)                 :=  i.old_subject_id;
5103       l_rel_hist_rec_tab.new_subject_id(l_ctr)                 :=  i.new_subject_id;
5104       l_rel_hist_rec_tab.old_position_reference(l_ctr)         :=  i.old_position_reference;
5105       l_rel_hist_rec_tab.new_position_reference(l_ctr)         :=  i.new_position_reference;
5106       l_rel_hist_rec_tab.old_rel_active_start_date(l_ctr)      :=  i.old_active_start_date;
5107       l_rel_hist_rec_tab.new_rel_active_start_date(l_ctr)      :=  i.new_active_start_date;
5108       l_rel_hist_rec_tab.old_rel_active_end_date(l_ctr)        :=  i.old_active_end_date;
5109       l_rel_hist_rec_tab.new_rel_active_end_date(l_ctr)        :=  i.new_active_end_date;
5110       l_rel_hist_rec_tab.old_mandatory_flag(l_ctr)             :=  i.old_mandatory_flag;
5111       l_rel_hist_rec_tab.new_mandatory_flag(l_ctr)             :=  i.new_mandatory_flag;
5112       l_rel_hist_rec_tab.old_rel_context(l_ctr)	               :=  i.old_context;
5113       l_rel_hist_rec_tab.new_rel_context(l_ctr)	               :=  i.new_context;
5114       l_rel_hist_rec_tab.old_rel_attribute1(l_ctr)	           :=  i.old_attribute1;
5115       l_rel_hist_rec_tab.new_rel_attribute1(l_ctr)	           :=  i.new_attribute1;
5116       l_rel_hist_rec_tab.old_rel_attribute2(l_ctr)	           :=  i.old_attribute2;
5117       l_rel_hist_rec_tab.new_rel_attribute2(l_ctr)	           :=  i.new_attribute2;
5118       l_rel_hist_rec_tab.old_rel_attribute3(l_ctr)	           :=  i.old_attribute3;
5119       l_rel_hist_rec_tab.new_rel_attribute3(l_ctr)	           :=  i.new_attribute3;
5120       l_rel_hist_rec_tab.old_rel_attribute4(l_ctr)	           :=  i.old_attribute4;
5121       l_rel_hist_rec_tab.new_rel_attribute4(l_ctr)	           :=  i.new_attribute4;
5122       l_rel_hist_rec_tab.old_rel_attribute5(l_ctr)	           :=  i.old_attribute5;
5123       l_rel_hist_rec_tab.new_rel_attribute5(l_ctr)	           :=  i.new_attribute5;
5124       l_rel_hist_rec_tab.old_rel_attribute6(l_ctr)	           :=  i.old_attribute6;
5125       l_rel_hist_rec_tab.new_rel_attribute6(l_ctr)	           :=  i.new_attribute6;
5126       l_rel_hist_rec_tab.old_rel_attribute7(l_ctr)	           :=  i.old_attribute7;
5127       l_rel_hist_rec_tab.new_rel_attribute7(l_ctr)	           :=  i.new_attribute7;
5128       l_rel_hist_rec_tab.old_rel_attribute8(l_ctr)	           :=  i.old_attribute8;
5129       l_rel_hist_rec_tab.new_rel_attribute8(l_ctr)	           :=  i.new_attribute8;
5130       l_rel_hist_rec_tab.old_rel_attribute9(l_ctr)	           :=  i.old_attribute9;
5131       l_rel_hist_rec_tab.new_rel_attribute9(l_ctr)	           :=  i.new_attribute9;
5132       l_rel_hist_rec_tab.old_rel_attribute10(l_ctr)	           :=  i.old_attribute10;
5133       l_rel_hist_rec_tab.new_rel_attribute10(l_ctr)	           :=  i.new_attribute10;
5134       l_rel_hist_rec_tab.old_rel_attribute11(l_ctr)      	   :=  i.old_attribute11;
5135       l_rel_hist_rec_tab.new_rel_attribute11(l_ctr)	           :=  i.new_attribute11;
5136       l_rel_hist_rec_tab.old_rel_attribute12(l_ctr)	           :=  i.old_attribute12;
5137       l_rel_hist_rec_tab.new_rel_attribute12(l_ctr)	           :=  i.new_attribute12;
5138       l_rel_hist_rec_tab.old_rel_attribute13(l_ctr)	           :=  i.old_attribute13;
5139       l_rel_hist_rec_tab.new_rel_attribute13(l_ctr)	           :=  i.new_attribute13;
5140       l_rel_hist_rec_tab.old_rel_attribute14(l_ctr)	           :=  i.old_attribute14;
5141       l_rel_hist_rec_tab.new_rel_attribute14(l_ctr)	           :=  i.new_attribute14;
5142       l_rel_hist_rec_tab.old_rel_attribute15(l_ctr)	           :=  i.old_attribute15;
5143       l_rel_hist_rec_tab.new_rel_attribute15(l_ctr)	           :=  i.new_attribute15;
5144       l_rel_hist_rec_tab.rel_full_dump_flag(l_ctr)	           :=  i.full_dump_flag;
5145       l_rel_hist_rec_tab.rel_created_by(l_ctr)                 :=  i.created_by;
5146       l_rel_hist_rec_tab.rel_creation_date(l_ctr)              :=  i.creation_date;
5147       l_rel_hist_rec_tab.rel_last_updated_by(l_ctr)            :=  i.last_updated_by;
5148       l_rel_hist_rec_tab.rel_last_update_date(l_ctr)           :=  i.last_update_date;
5149       l_rel_hist_rec_tab.rel_last_update_login(l_ctr)          :=  i.last_update_login;
5150       l_rel_hist_rec_tab.rel_object_version_number(l_ctr)	   :=  i.object_version_number;
5151       l_rel_hist_rec_tab.rel_security_group_id(l_ctr)	       :=  i.security_group_id;
5152       l_rel_hist_rec_tab.rel_migrated_flag(l_ctr)	           :=  i.migrated_flag;
5153 
5154    End Loop;
5155 
5156       -- get the party history count for the transaction range
5157       l_cnt := l_rel_hist_rec_tab.relationship_history_id.count;
5158       --
5159       Debug('');
5160       Debug('');
5161       Debug('Number of Instance Relationships history records archived:'||to_char(l_cnt));
5162       Debug('');
5163       Debug('');
5164       --
5165       If l_cnt > 0 Then
5166 
5170          (
5167         FORALL i IN 1 .. l_cnt
5168 
5169          Insert Into CSI_HISTORY_ARCHIVE
5171             HISTORY_ARCHIVE_ID
5172            ,OBJECT_ID
5173            ,ENTITY_HISTORY_ID
5174            ,TRANSACTION_ID
5175            ,ENTITY_ID
5176            ,COL_NUM_01
5177            ,COL_NUM_02
5178            ,COL_NUM_37
5179            ,COL_NUM_38
5180            ,COL_NUM_39
5181            ,COL_NUM_40
5182            ,COL_NUM_41
5183            ,COL_CHAR_01
5184            ,COL_CHAR_02
5185            ,COL_CHAR_03
5186            ,COL_CHAR_04
5187            ,COL_CHAR_31
5188            ,COL_CHAR_32
5189            ,COL_CHAR_33
5190            ,COL_CHAR_34
5191            ,COL_CHAR_35
5192            ,COL_CHAR_36
5193            ,COL_CHAR_37
5194            ,COL_CHAR_38
5195            ,COL_CHAR_39
5196            ,COL_CHAR_40
5197            ,COL_CHAR_41
5198            ,COL_CHAR_42
5199            ,COL_CHAR_43
5200            ,COL_CHAR_44
5201            ,COL_CHAR_45
5202            ,COL_CHAR_46
5203            ,COL_CHAR_47
5204            ,COL_CHAR_48
5205            ,COL_CHAR_49
5206            ,COL_CHAR_50
5207            ,COL_CHAR_51
5208            ,COL_CHAR_52
5209            ,COL_CHAR_53
5210            ,COL_CHAR_54
5211            ,COL_CHAR_55
5212            ,COL_CHAR_56
5213            ,COL_CHAR_57
5214            ,COL_CHAR_58
5215            ,COL_CHAR_59
5216            ,COL_CHAR_60
5217            ,COL_CHAR_61
5218            ,COL_CHAR_62
5219            ,COL_CHAR_71
5220            ,COL_CHAR_72
5221            ,COL_DATE_01
5222            ,COL_DATE_02
5223            ,COL_DATE_03
5224            ,COL_DATE_04
5225            ,COL_DATE_11
5226            ,COL_DATE_12
5227            ,CONTEXT
5228            ,ATTRIBUTE1
5229            ,ATTRIBUTE2
5230            ,ATTRIBUTE3
5231            ,ATTRIBUTE4
5232            ,ATTRIBUTE5
5233            ,ATTRIBUTE6
5234            ,ATTRIBUTE7
5235            ,ATTRIBUTE8
5236            ,ATTRIBUTE9
5237            ,ATTRIBUTE10
5238            ,ATTRIBUTE11
5239            ,ATTRIBUTE12
5240            ,ATTRIBUTE13
5241            ,ATTRIBUTE14
5242            ,ATTRIBUTE15
5243            ,CREATED_BY
5244            ,CREATION_DATE
5245            ,LAST_UPDATED_BY
5246            ,LAST_UPDATE_DATE
5247            ,LAST_UPDATE_LOGIN
5248            ,OBJECT_VERSION_NUMBER
5249            ,SECURITY_GROUP_ID
5250            )
5251            Values
5252            (
5253            l_archive_id_tbl(i),
5254            l_table_id,
5255            l_rel_hist_rec_tab.relationship_history_id(i),
5256            l_rel_hist_rec_tab.transaction_id(i),
5257            l_rel_hist_rec_tab.relationship_id(i),
5258            l_rel_hist_rec_tab.old_subject_id(i),
5259            l_rel_hist_rec_tab.new_subject_id(i),
5260            l_rel_hist_rec_tab.rel_created_by(i),
5261            l_rel_hist_rec_tab.rel_last_updated_by(i),
5262            l_rel_hist_rec_tab.rel_last_update_login(i),
5263            l_rel_hist_rec_tab.rel_object_version_number(i), -- obj_ver_num
5264            l_rel_hist_rec_tab.rel_security_group_id(i), -- sec_grp_id
5265            l_rel_hist_rec_tab.old_position_reference(i),
5266            l_rel_hist_rec_tab.new_position_reference(i),
5267            l_rel_hist_rec_tab.old_mandatory_flag(i),
5268            l_rel_hist_rec_tab.new_mandatory_flag(i),
5269            l_rel_hist_rec_tab.old_rel_context(i),
5270            l_rel_hist_rec_tab.new_rel_context(i),
5271            l_rel_hist_rec_tab.old_rel_attribute1(i),
5272            l_rel_hist_rec_tab.new_rel_attribute1(i),
5273            l_rel_hist_rec_tab.old_rel_attribute2(i),
5274            l_rel_hist_rec_tab.new_rel_attribute2(i),
5275            l_rel_hist_rec_tab.old_rel_attribute3(i),
5276            l_rel_hist_rec_tab.new_rel_attribute3(i),
5277            l_rel_hist_rec_tab.old_rel_attribute4(i),
5278            l_rel_hist_rec_tab.new_rel_attribute4(i),
5279            l_rel_hist_rec_tab.old_rel_attribute5(i),
5280            l_rel_hist_rec_tab.new_rel_attribute5(i),
5281            l_rel_hist_rec_tab.old_rel_attribute6(i),
5282            l_rel_hist_rec_tab.new_rel_attribute6(i),
5283            l_rel_hist_rec_tab.old_rel_attribute7(i),
5284            l_rel_hist_rec_tab.new_rel_attribute7(i),
5285            l_rel_hist_rec_tab.old_rel_attribute8(i),
5286            l_rel_hist_rec_tab.new_rel_attribute8(i),
5287            l_rel_hist_rec_tab.old_rel_attribute9(i),
5288            l_rel_hist_rec_tab.new_rel_attribute9(i),
5289            l_rel_hist_rec_tab.old_rel_attribute10(i),
5290            l_rel_hist_rec_tab.new_rel_attribute10(i),
5291            l_rel_hist_rec_tab.old_rel_attribute11(i),
5292            l_rel_hist_rec_tab.new_rel_attribute11(i),
5293            l_rel_hist_rec_tab.old_rel_attribute12(i),
5294            l_rel_hist_rec_tab.new_rel_attribute12(i),
5295            l_rel_hist_rec_tab.old_rel_attribute13(i),
5296            l_rel_hist_rec_tab.new_rel_attribute13(i),
5297            l_rel_hist_rec_tab.old_rel_attribute14(i),
5298            l_rel_hist_rec_tab.new_rel_attribute14(i),
5299            l_rel_hist_rec_tab.old_rel_attribute15(i),
5300            l_rel_hist_rec_tab.new_rel_attribute15(i),
5301            l_rel_hist_rec_tab.rel_full_dump_flag(i), --'N', dump_flag
5302            l_rel_hist_rec_tab.rel_migrated_flag(i), -- mig_flag
5303            l_rel_hist_rec_tab.old_rel_active_start_date(i),
5304            l_rel_hist_rec_tab.new_rel_active_start_date(i),
5305            l_rel_hist_rec_tab.old_rel_active_end_date(i),
5306            l_rel_hist_rec_tab.new_rel_active_end_date(i),
5307            l_rel_hist_rec_tab.rel_creation_date(i),
5308            l_rel_hist_rec_tab.rel_last_update_date(i),
5309            null,
5310            null,
5311            null,
5315            null,
5312            null,
5313            null,
5314            null,
5316            null,
5317            null,
5318            null,
5319            null,
5320            null,
5321            null,
5322            null,
5323            null,
5324            null,
5325            l_user_id,
5326            sysdate,
5327            l_user_id,
5328            sysdate,
5329            l_login_id,
5330            1,
5331            null
5332            );
5333 
5334          -- Purge the corresonding Archive data from the Instance Rel. history tables
5335 
5336             FORALL i IN 1 .. l_cnt
5337 
5338                Delete From CSI_II_RELATIONSHIPS_H
5339                Where relationship_history_id = l_rel_hist_rec_tab.relationship_history_id(i);
5340 
5341        End If; -- if l_cnt > 0
5342        --
5343        Exit When from_trans = to_trans;
5344        Exit When v_end = to_trans;
5345 
5346      v_start := v_end + 1;
5347      v_end   := v_start + v_batch;
5348      --
5349      --
5350 	 If v_start > to_trans Then
5351 	    v_start := to_trans;
5352 	 End If;
5353 	 --
5354 	 If v_end > to_trans then
5355 	    v_end := to_trans;
5356 	 End If;
5357      --
5358      Commit;
5359      --
5360    Exception
5361       when others then
5362          Debug(substr(sqlerrm,1,255));
5363          ROLLBACK to Rel_Archive;
5364    End;
5365  End Loop; -- Local Batch Loop
5366  Commit;
5367    --
5368 END; -- Procedure InstRels_Archive
5369 
5370 
5371 --
5372 -- This program is used to archive the Operating units history. It accepts from and to transactions
5373 -- as the input parameters.
5374 --
5375 
5376 PROCEDURE Systems_archive( errbuf       OUT NOCOPY VARCHAR2,
5377                            retcode      OUT NOCOPY NUMBER,
5378                            from_trans   IN  NUMBER,
5379                            to_trans     IN  NUMBER,
5380                            purge_to_date IN VARCHAR2 )
5381 IS
5382 
5383     l_archive_id      NUMBER;
5384     l_ctr             NUMBER := 0;
5385     l_cnt             NUMBER;
5386     l_table_id        NUMBER;
5387     l_user_id         NUMBER := FND_GLOBAL.USER_ID;
5388     l_login_id        NUMBER := FND_GLOBAL.CONC_LOGIN_ID;
5389     v_batch           NUMBER := 15000;
5390     v_start           NUMBER;
5391     v_end             NUMBER;
5392 
5393     Type NUMLIST IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
5394     l_archive_id_tbl   NUMLIST;
5395 
5396     Cursor sys_hist_csr (p_from_trans IN NUMBER,
5397                          p_to_trans   IN NUMBER) IS
5398     Select csh.*
5399     From   CSI_SYSTEMS_H csh,
5400            CSI_TRANSACTIONS csit
5401     Where  csit.transaction_id between from_trans and to_trans
5402     And    csit.creation_date < to_date(purge_to_date, 'YYYY/MM/DD HH24:MI:SS')
5403     And    csh.transaction_id = csit.transaction_id;
5404 
5405     l_sys_hist_csr         sys_hist_csr%ROWTYPE;
5406     l_sys_hist_rec_tab     csi_txn_history_purge_pvt.system_history_rec_tab;
5407 
5408 
5409 Begin
5410     --
5411     --
5412     Begin
5413       Select object_id
5414       Into   l_table_id
5415       From   csi_object_dictionary
5416       Where  object_name = 'CSI_SYSTEMS_H';
5417     Exception
5418       When no_data_found Then
5419         l_table_id := 10;
5420       When others Then
5421         l_table_id := 10;
5422     End;
5423     --
5424     Begin
5425       Select fnd_profile.value('CSI_TXN_HISTORY_PURGE_BATCH_SIZE')
5426       Into   v_batch
5427       From   dual;
5428     Exception
5429       When no_data_found Then
5430         v_batch := 15000;
5431     End;
5432     --
5433     v_start := from_trans;
5434     v_end   := from_trans + v_batch;
5435     --
5436     If v_end > to_trans Then
5437        v_end := to_trans;
5438     End If;
5439     --
5440  Loop
5441    Begin
5442       SAVEPOINT System_Archive;
5443       l_ctr := 0;
5444       --
5445       l_sys_hist_rec_tab.system_history_id.DELETE;
5446       l_sys_hist_rec_tab.system_id.DELETE;
5447       l_sys_hist_rec_tab.transaction_id.DELETE;
5448       l_sys_hist_rec_tab.old_customer_id.DELETE;
5449       l_sys_hist_rec_tab.new_customer_id.DELETE;
5450       l_sys_hist_rec_tab.old_system_type_code.DELETE;
5451       l_sys_hist_rec_tab.new_system_type_code.DELETE;
5452       l_sys_hist_rec_tab.old_system_number.DELETE;
5453       l_sys_hist_rec_tab.new_system_number.DELETE;
5454       l_sys_hist_rec_tab.old_parent_system_id.DELETE;
5455       l_sys_hist_rec_tab.new_parent_system_id.DELETE;
5456       l_sys_hist_rec_tab.old_ship_to_contact_id.DELETE;
5457       l_sys_hist_rec_tab.new_ship_to_contact_id.DELETE;
5458       l_sys_hist_rec_tab.old_bill_to_contact_id.DELETE;
5459       l_sys_hist_rec_tab.new_bill_to_contact_id.DELETE;
5460       l_sys_hist_rec_tab.old_technical_contact_id.DELETE;
5461       l_sys_hist_rec_tab.new_technical_contact_id.DELETE;
5462       l_sys_hist_rec_tab.old_service_admin_contact_id.DELETE;
5463       l_sys_hist_rec_tab.new_service_admin_contact_id.DELETE;
5464       l_sys_hist_rec_tab.old_ship_to_site_use_id.DELETE;
5465       l_sys_hist_rec_tab.new_ship_to_site_use_id.DELETE;
5466       l_sys_hist_rec_tab.old_install_site_use_id.DELETE;
5467       l_sys_hist_rec_tab.new_install_site_use_id.DELETE;
5468       l_sys_hist_rec_tab.old_bill_to_site_use_id.DELETE;
5469       l_sys_hist_rec_tab.new_bill_to_site_use_id.DELETE;
5470       l_sys_hist_rec_tab.old_coterminate_day_month.DELETE;
5471       l_sys_hist_rec_tab.new_coterminate_day_month.DELETE;
5472       l_sys_hist_rec_tab.old_sys_active_start_date.DELETE;
5473       l_sys_hist_rec_tab.new_sys_active_start_date.DELETE;
5477       l_sys_hist_rec_tab.new_autocreated_from_system.DELETE;
5474       l_sys_hist_rec_tab.old_sys_active_end_date.DELETE;
5475       l_sys_hist_rec_tab.new_sys_active_end_date.DELETE;
5476       l_sys_hist_rec_tab.old_autocreated_from_system.DELETE;
5478       l_sys_hist_rec_tab.old_config_system_type.DELETE;
5479       l_sys_hist_rec_tab.new_config_system_type.DELETE;
5480       l_sys_hist_rec_tab.old_name.DELETE;
5481       l_sys_hist_rec_tab.new_name.DELETE;
5482       l_sys_hist_rec_tab.old_sys_description.DELETE;
5483       l_sys_hist_rec_tab.new_sys_description.DELETE;
5484       l_sys_hist_rec_tab.old_sys_context.DELETE;
5485       l_sys_hist_rec_tab.new_sys_context.DELETE;
5486       l_sys_hist_rec_tab.old_sys_attribute1.DELETE;
5487       l_sys_hist_rec_tab.new_sys_attribute1.DELETE;
5488       l_sys_hist_rec_tab.old_sys_attribute2.DELETE;
5489       l_sys_hist_rec_tab.new_sys_attribute2.DELETE;
5490       l_sys_hist_rec_tab.old_sys_attribute3.DELETE;
5491       l_sys_hist_rec_tab.new_sys_attribute3.DELETE;
5492       l_sys_hist_rec_tab.old_sys_attribute4.DELETE;
5493       l_sys_hist_rec_tab.new_sys_attribute4.DELETE;
5494       l_sys_hist_rec_tab.old_sys_attribute5.DELETE;
5495       l_sys_hist_rec_tab.new_sys_attribute5.DELETE;
5496       l_sys_hist_rec_tab.old_sys_attribute6.DELETE;
5497       l_sys_hist_rec_tab.new_sys_attribute6.DELETE;
5498       l_sys_hist_rec_tab.old_sys_attribute7.DELETE;
5499       l_sys_hist_rec_tab.new_sys_attribute7.DELETE;
5500       l_sys_hist_rec_tab.old_sys_attribute8.DELETE;
5501       l_sys_hist_rec_tab.new_sys_attribute8.DELETE;
5502       l_sys_hist_rec_tab.old_sys_attribute9.DELETE;
5503       l_sys_hist_rec_tab.new_sys_attribute9.DELETE;
5504       l_sys_hist_rec_tab.old_sys_attribute10.DELETE;
5505       l_sys_hist_rec_tab.new_sys_attribute10.DELETE;
5506       l_sys_hist_rec_tab.old_sys_attribute11.DELETE;
5507       l_sys_hist_rec_tab.new_sys_attribute11.DELETE;
5508       l_sys_hist_rec_tab.old_sys_attribute12.DELETE;
5509       l_sys_hist_rec_tab.new_sys_attribute12.DELETE;
5510       l_sys_hist_rec_tab.old_sys_attribute13.DELETE;
5511       l_sys_hist_rec_tab.new_sys_attribute13.DELETE;
5512       l_sys_hist_rec_tab.old_sys_attribute14.DELETE;
5513       l_sys_hist_rec_tab.new_sys_attribute14.DELETE;
5514       l_sys_hist_rec_tab.old_sys_attribute15.DELETE;
5515       l_sys_hist_rec_tab.new_sys_attribute15.DELETE;
5516       l_sys_hist_rec_tab.sys_full_dump_flag.DELETE;
5517       l_sys_hist_rec_tab.sys_created_by.DELETE;
5518       l_sys_hist_rec_tab.sys_creation_date.DELETE;
5519       l_sys_hist_rec_tab.sys_last_updated_by.DELETE;
5520       l_sys_hist_rec_tab.sys_last_update_date.DELETE;
5521       l_sys_hist_rec_tab.sys_last_update_login.DELETE;
5522       l_sys_hist_rec_tab.sys_object_version_number.DELETE;
5523       l_sys_hist_rec_tab.sys_security_group_id.DELETE;
5524       l_sys_hist_rec_tab.sys_migrated_flag.DELETE;
5525       l_sys_hist_rec_tab.old_sys_operating_unit_id.DELETE;
5526       l_sys_hist_rec_tab.new_sys_operating_unit_id.DELETE;
5527       --
5528 
5529   For i in sys_hist_csr(v_start,v_end)
5530   Loop
5531       --
5532       l_ctr := l_ctr + 1;
5533       --
5534       Select csi_history_archive_s.Nextval
5535       Into l_archive_id_tbl(l_ctr)
5536       From dual;
5537       --
5538       l_sys_hist_rec_tab.system_history_id(l_ctr)              :=  i.system_history_id;
5539       l_sys_hist_rec_tab.system_id(l_ctr)                      :=  i.system_id;
5540       l_sys_hist_rec_tab.transaction_id(l_ctr)                 :=  i.transaction_id;
5541       l_sys_hist_rec_tab.old_customer_id(l_ctr)                :=  i.old_customer_id;
5542       l_sys_hist_rec_tab.new_customer_id(l_ctr)                :=  i.new_customer_id;
5543       l_sys_hist_rec_tab.old_system_type_code(l_ctr)           :=  i.old_system_type_code;
5544       l_sys_hist_rec_tab.new_system_type_code(l_ctr)           :=  i.new_system_type_code;
5545       l_sys_hist_rec_tab.old_system_number(l_ctr)              :=  i.old_system_number;
5546       l_sys_hist_rec_tab.new_system_number(l_ctr)              :=  i.new_system_number;
5547       l_sys_hist_rec_tab.old_parent_system_id(l_ctr)           :=  i.old_parent_system_id;
5548       l_sys_hist_rec_tab.new_parent_system_id(l_ctr)           :=  i.new_parent_system_id;
5549       l_sys_hist_rec_tab.old_ship_to_contact_id(l_ctr)         :=  i.old_ship_to_contact_id;
5550       l_sys_hist_rec_tab.new_ship_to_contact_id(l_ctr)         :=  i.new_ship_to_contact_id;
5551       l_sys_hist_rec_tab.old_bill_to_contact_id(l_ctr)         :=  i.old_bill_to_contact_id;
5552       l_sys_hist_rec_tab.new_bill_to_contact_id(l_ctr)         :=  i.new_bill_to_contact_id;
5553       l_sys_hist_rec_tab.old_technical_contact_id(l_ctr)       :=  i.old_technical_contact_id;
5554       l_sys_hist_rec_tab.new_technical_contact_id(l_ctr)       :=  i.new_technical_contact_id;
5555       l_sys_hist_rec_tab.old_service_admin_contact_id(l_ctr)   :=  i.old_service_admin_contact_id;
5556       l_sys_hist_rec_tab.new_service_admin_contact_id(l_ctr)   :=  i.new_service_admin_contact_id;
5557       l_sys_hist_rec_tab.old_ship_to_site_use_id(l_ctr)        :=  i.old_ship_to_site_use_id;
5558       l_sys_hist_rec_tab.new_ship_to_site_use_id(l_ctr)        :=  i.new_ship_to_site_use_id;
5559       l_sys_hist_rec_tab.old_install_site_use_id(l_ctr)        :=  i.old_install_site_use_id;
5560       l_sys_hist_rec_tab.new_install_site_use_id(l_ctr)        :=  i.new_install_site_use_id;
5561       l_sys_hist_rec_tab.old_bill_to_site_use_id(l_ctr)        :=  i.old_bill_to_site_use_id;
5562       l_sys_hist_rec_tab.new_bill_to_site_use_id(l_ctr)        :=  i.new_bill_to_site_use_id;
5563       l_sys_hist_rec_tab.old_coterminate_day_month(l_ctr)      :=  i.old_coterminate_day_month;
5564       l_sys_hist_rec_tab.new_coterminate_day_month(l_ctr)      :=  i.new_coterminate_day_month;
5565       l_sys_hist_rec_tab.old_sys_active_start_date(l_ctr)      :=  i.old_start_date_active;
5566       l_sys_hist_rec_tab.new_sys_active_start_date(l_ctr)      :=  i.new_start_date_active;
5567       l_sys_hist_rec_tab.old_sys_active_end_date(l_ctr)        :=  i.old_end_date_active;
5568       l_sys_hist_rec_tab.new_sys_active_end_date(l_ctr)        :=  i.new_end_date_active;
5572       l_sys_hist_rec_tab.new_config_system_type(l_ctr)         :=  i.new_config_system_type;
5569       l_sys_hist_rec_tab.old_autocreated_from_system(l_ctr)    :=  i.old_autocreated_from_system;
5570       l_sys_hist_rec_tab.new_autocreated_from_system(l_ctr)    :=  i.new_autocreated_from_system;
5571       l_sys_hist_rec_tab.old_config_system_type(l_ctr)         :=  i.old_config_system_type;
5573       l_sys_hist_rec_tab.old_name(l_ctr)                       :=  i.old_name;
5574       l_sys_hist_rec_tab.new_name(l_ctr)                       :=  i.new_name;
5575       l_sys_hist_rec_tab.old_sys_description(l_ctr)            :=  i.old_description;
5576       l_sys_hist_rec_tab.new_sys_description(l_ctr)            :=  i.new_description;
5577       l_sys_hist_rec_tab.old_sys_context(l_ctr)	               :=  i.old_context;
5578       l_sys_hist_rec_tab.new_sys_context(l_ctr)	               :=  i.new_context;
5579       l_sys_hist_rec_tab.old_sys_attribute1(l_ctr)	           :=  i.old_attribute1;
5580       l_sys_hist_rec_tab.new_sys_attribute1(l_ctr)	           :=  i.new_attribute1;
5581       l_sys_hist_rec_tab.old_sys_attribute2(l_ctr)	           :=  i.old_attribute2;
5582       l_sys_hist_rec_tab.new_sys_attribute2(l_ctr)	           :=  i.new_attribute2;
5583       l_sys_hist_rec_tab.old_sys_attribute3(l_ctr)	           :=  i.old_attribute3;
5584       l_sys_hist_rec_tab.new_sys_attribute3(l_ctr)	           :=  i.new_attribute3;
5585       l_sys_hist_rec_tab.old_sys_attribute4(l_ctr)	           :=  i.old_attribute4;
5586       l_sys_hist_rec_tab.new_sys_attribute4(l_ctr)	           :=  i.new_attribute4;
5587       l_sys_hist_rec_tab.old_sys_attribute5(l_ctr)	           :=  i.old_attribute5;
5588       l_sys_hist_rec_tab.new_sys_attribute5(l_ctr)	           :=  i.new_attribute5;
5589       l_sys_hist_rec_tab.old_sys_attribute6(l_ctr)	           :=  i.old_attribute6;
5590       l_sys_hist_rec_tab.new_sys_attribute6(l_ctr)	           :=  i.new_attribute6;
5591       l_sys_hist_rec_tab.old_sys_attribute7(l_ctr)	           :=  i.old_attribute7;
5592       l_sys_hist_rec_tab.new_sys_attribute7(l_ctr)	           :=  i.new_attribute7;
5593       l_sys_hist_rec_tab.old_sys_attribute8(l_ctr)	           :=  i.old_attribute8;
5594       l_sys_hist_rec_tab.new_sys_attribute8(l_ctr)	           :=  i.new_attribute8;
5595       l_sys_hist_rec_tab.old_sys_attribute9(l_ctr)	           :=  i.old_attribute9;
5596       l_sys_hist_rec_tab.new_sys_attribute9(l_ctr)	           :=  i.new_attribute9;
5597       l_sys_hist_rec_tab.old_sys_attribute10(l_ctr)	           :=  i.old_attribute10;
5598       l_sys_hist_rec_tab.new_sys_attribute10(l_ctr)	           :=  i.new_attribute10;
5599       l_sys_hist_rec_tab.old_sys_attribute11(l_ctr)   	       :=  i.old_attribute11;
5600       l_sys_hist_rec_tab.new_sys_attribute11(l_ctr)	           :=  i.new_attribute11;
5601       l_sys_hist_rec_tab.old_sys_attribute12(l_ctr)	           :=  i.old_attribute12;
5602       l_sys_hist_rec_tab.new_sys_attribute12(l_ctr)	           :=  i.new_attribute12;
5603       l_sys_hist_rec_tab.old_sys_attribute13(l_ctr)	           :=  i.old_attribute13;
5604       l_sys_hist_rec_tab.new_sys_attribute13(l_ctr)	           :=  i.new_attribute13;
5605       l_sys_hist_rec_tab.old_sys_attribute14(l_ctr)	           :=  i.old_attribute14;
5606       l_sys_hist_rec_tab.new_sys_attribute14(l_ctr)	           :=  i.new_attribute14;
5607       l_sys_hist_rec_tab.old_sys_attribute15(l_ctr)	           :=  i.old_attribute15;
5608       l_sys_hist_rec_tab.new_sys_attribute15(l_ctr)	           :=  i.new_attribute15;
5609       l_sys_hist_rec_tab.sys_full_dump_flag(l_ctr)	           :=  i.full_dump_flag;
5610       l_sys_hist_rec_tab.sys_created_by(l_ctr)                 :=  i.created_by;
5611       l_sys_hist_rec_tab.sys_creation_date(l_ctr)              :=  i.creation_date;
5612       l_sys_hist_rec_tab.sys_last_updated_by(l_ctr)            :=  i.last_updated_by;
5613       l_sys_hist_rec_tab.sys_last_update_date(l_ctr)           :=  i.last_update_date;
5614       l_sys_hist_rec_tab.sys_last_update_login(l_ctr)          :=  i.last_update_login;
5615       l_sys_hist_rec_tab.sys_object_version_number(l_ctr)      :=  i.object_version_number;
5616       l_sys_hist_rec_tab.sys_security_group_id(l_ctr)	       :=  i.security_group_id;
5617       l_sys_hist_rec_tab.sys_migrated_flag(l_ctr)	           :=  i.migrated_flag;
5618       l_sys_hist_rec_tab.old_sys_operating_unit_id(l_ctr)      :=  i.old_operating_unit_id;
5619       l_sys_hist_rec_tab.new_sys_operating_unit_id(l_ctr)      :=  i.new_operating_unit_id;
5620 
5621    End Loop;
5622 
5623       -- get the party history count for the transaction range
5624       l_cnt := l_sys_hist_rec_tab.system_history_id.count;
5625       --
5626       Debug('');
5627       Debug('');
5628       Debug('Number of System history records archived:'||to_char(l_cnt));
5629       Debug('');
5630       Debug('');
5631       --
5632       If l_cnt > 0 Then
5633 
5634         FORALL i IN 1 .. l_cnt
5635 
5636          Insert Into CSI_HISTORY_ARCHIVE
5637          (
5638             HISTORY_ARCHIVE_ID
5639            ,OBJECT_ID
5640            ,ENTITY_HISTORY_ID
5641            ,TRANSACTION_ID
5642            ,ENTITY_ID
5643            ,COL_NUM_01
5644            ,COL_NUM_02
5645            ,COL_NUM_03
5646            ,COL_NUM_04
5647            ,COL_NUM_05
5648            ,COL_NUM_06
5649            ,COL_NUM_07
5650            ,COL_NUM_08
5651            ,COL_NUM_09
5652            ,COL_NUM_10
5653            ,COL_NUM_11
5654            ,COL_NUM_12
5655            ,COL_NUM_13
5656            ,COL_NUM_14
5657            ,COL_NUM_15
5658            ,COL_NUM_16
5659            ,COL_NUM_17
5660            ,COL_NUM_18
5661            ,COL_NUM_19
5662            ,COL_NUM_20
5663            ,COL_NUM_21
5664            ,COL_NUM_22
5665            ,COL_NUM_37
5666            ,COL_NUM_38
5667            ,COL_NUM_39
5668            ,COL_NUM_40
5669            ,COL_NUM_41
5670            ,COL_CHAR_01
5671            ,COL_CHAR_02
5672            ,COL_CHAR_03
5673            ,COL_CHAR_04
5674            ,COL_CHAR_05
5675            ,COL_CHAR_06
5679            ,COL_CHAR_10
5676            ,COL_CHAR_07
5677            ,COL_CHAR_08
5678            ,COL_CHAR_09
5680            ,COL_CHAR_11
5681            ,COL_CHAR_12
5682            ,COL_CHAR_31
5683            ,COL_CHAR_32
5684            ,COL_CHAR_33
5685            ,COL_CHAR_34
5686            ,COL_CHAR_35
5687            ,COL_CHAR_36
5688            ,COL_CHAR_37
5689            ,COL_CHAR_38
5690            ,COL_CHAR_39
5691            ,COL_CHAR_40
5692            ,COL_CHAR_41
5693            ,COL_CHAR_42
5694            ,COL_CHAR_43
5695            ,COL_CHAR_44
5696            ,COL_CHAR_45
5697            ,COL_CHAR_46
5698            ,COL_CHAR_47
5699            ,COL_CHAR_48
5700            ,COL_CHAR_49
5701            ,COL_CHAR_50
5702            ,COL_CHAR_51
5703            ,COL_CHAR_52
5704            ,COL_CHAR_53
5705            ,COL_CHAR_54
5706            ,COL_CHAR_55
5707            ,COL_CHAR_56
5708            ,COL_CHAR_57
5709            ,COL_CHAR_58
5710            ,COL_CHAR_59
5711            ,COL_CHAR_60
5712            ,COL_CHAR_61
5713            ,COL_CHAR_62
5714            ,COL_CHAR_71
5715            ,COL_CHAR_72
5716            ,COL_DATE_01
5717            ,COL_DATE_02
5718            ,COL_DATE_03
5719            ,COL_DATE_04
5720            ,COL_DATE_11
5721            ,COL_DATE_12
5722            ,CONTEXT
5723            ,ATTRIBUTE1
5724            ,ATTRIBUTE2
5725            ,ATTRIBUTE3
5726            ,ATTRIBUTE4
5727            ,ATTRIBUTE5
5728            ,ATTRIBUTE6
5729            ,ATTRIBUTE7
5730            ,ATTRIBUTE8
5731            ,ATTRIBUTE9
5732            ,ATTRIBUTE10
5733            ,ATTRIBUTE11
5734            ,ATTRIBUTE12
5735            ,ATTRIBUTE13
5736            ,ATTRIBUTE14
5737            ,ATTRIBUTE15
5738            ,CREATED_BY
5739            ,CREATION_DATE
5740            ,LAST_UPDATED_BY
5741            ,LAST_UPDATE_DATE
5742            ,LAST_UPDATE_LOGIN
5743            ,OBJECT_VERSION_NUMBER
5744            ,SECURITY_GROUP_ID
5745            )
5746            Values
5747            (
5748            l_archive_id_tbl(i),
5749            l_table_id,
5750            l_sys_hist_rec_tab.system_history_id(i),
5751            l_sys_hist_rec_tab.transaction_id(i),
5752            l_sys_hist_rec_tab.system_id(i),
5753            l_sys_hist_rec_tab.old_customer_id(i),
5754            l_sys_hist_rec_tab.new_customer_id(i),
5755            l_sys_hist_rec_tab.old_parent_system_id(i),
5756            l_sys_hist_rec_tab.new_parent_system_id(i),
5757            l_sys_hist_rec_tab.old_bill_to_contact_id(i),
5758            l_sys_hist_rec_tab.new_bill_to_contact_id(i),
5759            l_sys_hist_rec_tab.old_ship_to_contact_id(i),
5760            l_sys_hist_rec_tab.new_ship_to_contact_id(i),
5761            l_sys_hist_rec_tab.old_technical_contact_id(i),
5762            l_sys_hist_rec_tab.new_technical_contact_id(i),
5763            l_sys_hist_rec_tab.old_service_admin_contact_id(i),
5764            l_sys_hist_rec_tab.new_service_admin_contact_id(i),
5765            l_sys_hist_rec_tab.old_ship_to_site_use_id(i),
5766            l_sys_hist_rec_tab.new_ship_to_site_use_id(i),
5767            l_sys_hist_rec_tab.old_install_site_use_id(i),
5768            l_sys_hist_rec_tab.new_install_site_use_id(i),
5769            l_sys_hist_rec_tab.old_bill_to_site_use_id(i),
5770            l_sys_hist_rec_tab.new_bill_to_site_use_id(i),
5771            l_sys_hist_rec_tab.old_autocreated_from_system(i),
5772            l_sys_hist_rec_tab.new_autocreated_from_system(i),
5773            l_sys_hist_rec_tab.old_sys_operating_unit_id(i),
5774            l_sys_hist_rec_tab.new_sys_operating_unit_id(i),
5775            l_sys_hist_rec_tab.sys_created_by(i),
5776            l_sys_hist_rec_tab.sys_last_updated_by(i),
5777            l_sys_hist_rec_tab.sys_last_update_login(i),
5778 	   l_sys_hist_rec_tab.sys_object_version_number(i), -- obj_ver_num
5779            l_sys_hist_rec_tab.sys_security_group_id(i), -- sec_grp_id
5780            l_sys_hist_rec_tab.old_system_type_code(i),
5781            l_sys_hist_rec_tab.new_system_type_code(i),
5782            l_sys_hist_rec_tab.old_system_number(i),
5783            l_sys_hist_rec_tab.new_system_number(i),
5784            l_sys_hist_rec_tab.old_coterminate_day_month(i),
5785            l_sys_hist_rec_tab.new_coterminate_day_month(i),
5786            l_sys_hist_rec_tab.old_config_system_type(i),
5787            l_sys_hist_rec_tab.new_config_system_type(i),
5788            l_sys_hist_rec_tab.old_name(i),
5789            l_sys_hist_rec_tab.new_name(i),
5790            l_sys_hist_rec_tab.old_sys_description(i),
5791            l_sys_hist_rec_tab.new_sys_description(i),
5792            l_sys_hist_rec_tab.old_sys_context(i),
5793            l_sys_hist_rec_tab.new_sys_context(i),
5794            l_sys_hist_rec_tab.old_sys_attribute1(i),
5795            l_sys_hist_rec_tab.new_sys_attribute1(i),
5796            l_sys_hist_rec_tab.old_sys_attribute2(i),
5797            l_sys_hist_rec_tab.new_sys_attribute2(i),
5798            l_sys_hist_rec_tab.old_sys_attribute3(i),
5799            l_sys_hist_rec_tab.new_sys_attribute3(i),
5800            l_sys_hist_rec_tab.old_sys_attribute4(i),
5801            l_sys_hist_rec_tab.new_sys_attribute4(i),
5802            l_sys_hist_rec_tab.old_sys_attribute5(i),
5803            l_sys_hist_rec_tab.new_sys_attribute5(i),
5804            l_sys_hist_rec_tab.old_sys_attribute6(i),
5805            l_sys_hist_rec_tab.new_sys_attribute6(i),
5806            l_sys_hist_rec_tab.old_sys_attribute7(i),
5807            l_sys_hist_rec_tab.new_sys_attribute7(i),
5808            l_sys_hist_rec_tab.old_sys_attribute8(i),
5809            l_sys_hist_rec_tab.new_sys_attribute8(i),
5810            l_sys_hist_rec_tab.old_sys_attribute9(i),
5811            l_sys_hist_rec_tab.new_sys_attribute9(i),
5815            l_sys_hist_rec_tab.new_sys_attribute11(i),
5812            l_sys_hist_rec_tab.old_sys_attribute10(i),
5813            l_sys_hist_rec_tab.new_sys_attribute10(i),
5814            l_sys_hist_rec_tab.old_sys_attribute11(i),
5816            l_sys_hist_rec_tab.old_sys_attribute12(i),
5817            l_sys_hist_rec_tab.new_sys_attribute12(i),
5818            l_sys_hist_rec_tab.old_sys_attribute13(i),
5819            l_sys_hist_rec_tab.new_sys_attribute13(i),
5820            l_sys_hist_rec_tab.old_sys_attribute14(i),
5821            l_sys_hist_rec_tab.new_sys_attribute14(i),
5822            l_sys_hist_rec_tab.old_sys_attribute15(i),
5823            l_sys_hist_rec_tab.new_sys_attribute15(i),
5824            l_sys_hist_rec_tab.sys_full_dump_flag(i), --'N', dump_flag
5825            l_sys_hist_rec_tab.sys_migrated_flag(i), -- mig_flag
5826            l_sys_hist_rec_tab.old_sys_active_start_date(i),
5827            l_sys_hist_rec_tab.new_sys_active_start_date(i),
5828            l_sys_hist_rec_tab.old_sys_active_end_date(i),
5829            l_sys_hist_rec_tab.new_sys_active_end_date(i),
5830            l_sys_hist_rec_tab.sys_creation_date(i),
5831            l_sys_hist_rec_tab.sys_last_update_date(i),
5832            null,
5833            null,
5834            null,
5835            null,
5836            null,
5837            null,
5838            null,
5839            null,
5840            null,
5841            null,
5842            null,
5843            null,
5844            null,
5845            null,
5846            null,
5847            null,
5848            l_user_id,
5849            sysdate,
5850            l_user_id,
5851            sysdate,
5852            l_login_id,
5853            1,
5854            null
5855            );
5856 
5857          -- Purge the corresonding Archive data from the Systems history tables
5858 
5859             FORALL i IN 1 .. l_cnt
5860 
5861                Delete From CSI_SYSTEMS_H
5862                Where system_history_id = l_sys_hist_rec_tab.system_history_id(i);
5863 
5864 
5865        End If; -- if l_cnt > 0
5866        --
5867        Exit When from_trans = to_trans;
5868        Exit When v_end = to_trans;
5869 
5870      v_start := v_end + 1;
5871      v_end   := v_start + v_batch;
5872      --
5873      --
5874 	 If v_start > to_trans Then
5875 	    v_start := to_trans;
5876 	 End If;
5877 	 --
5878 	 If v_end > to_trans then
5879 	    v_end := to_trans;
5880 	 End If;
5881      --
5882      Commit;
5883      --
5884    Exception
5885       when others then
5886          Debug(substr(sqlerrm,1,255));
5887          ROLLBACK to System_Archive;
5888    End;
5889  End Loop; -- Local Batch Loop
5890  Commit;
5891    --
5892 END; -- Procedure Systems_Archive
5893 
5894 
5895 Procedure Record_count( From_trans IN  NUMBER,
5896                         To_trans   IN  NUMBER,
5897                         Purge_to_date IN VARCHAR2,
5898                         Recs_count OUT NOCOPY NUMBER )
5899 IS
5900 
5901   l_temp   NUMBER;
5902   l_temp1  NUMBER;
5903   l_temp2  NUMBER;
5904   l_temp3  NUMBER;
5905   l_temp4  NUMBER;
5906   l_temp5  NUMBER;
5907   l_temp6  NUMBER;
5908   l_temp7  NUMBER;
5909   l_temp8  NUMBER;
5910   l_temp9  NUMBER;
5911 
5912 Begin
5913   --
5914   Begin
5915     Select COUNT(*)
5916     Into   l_temp
5917     From   CSI_ITEM_INSTANCES_H csh,
5918            CSI_TRANSACTIONS csit
5919     Where  csit.transaction_id between From_trans and To_trans
5920     And    csit.creation_date < to_date(purge_to_date, 'YYYY/MM/DD HH24:MI:SS')
5921     And    csh.transaction_id = csit.transaction_id;
5922   Exception
5923     When Others Then
5924     Null;
5925   End;
5926   --
5927   --
5928   Begin
5929     Select COUNT(*)
5930     Into   l_temp1
5931     From   CSI_I_PARTIES_H csh,
5932            CSI_TRANSACTIONS csit
5933     Where  csit.transaction_id between From_trans and To_trans
5934     And    csit.creation_date < to_date(purge_to_date, 'YYYY/MM/DD HH24:MI:SS')
5935     And    csh.transaction_id = csit.transaction_id;
5936   Exception
5937     When Others Then
5938     Null;
5939   End;
5940   --
5941   --
5942   Begin
5943     Select COUNT(*)
5944     Into   l_temp2
5945     From   CSI_IP_ACCOUNTS_H csh,
5946            CSI_TRANSACTIONS csit
5947     Where  csit.transaction_id between From_trans and To_trans
5948     And    csit.creation_date < to_date(purge_to_date, 'YYYY/MM/DD HH24:MI:SS')
5949     And    csh.transaction_id = csit.transaction_id;
5950   Exception
5951     When Others Then
5952     Null;
5953   End;
5954   --
5955   --
5956   Begin
5957     Select COUNT(*)
5958     Into   l_temp3
5959     From   CSI_I_ORG_ASSIGNMENTS_H csh,
5960            CSI_TRANSACTIONS csit
5961     Where  csit.transaction_id between From_trans and To_trans
5962     And    csit.creation_date < to_date(purge_to_date, 'YYYY/MM/DD HH24:MI:SS')
5963     And    csh.transaction_id = csit.transaction_id;
5964   Exception
5965     When Others Then
5966     Null;
5967   End;
5968   --
5969   --
5970   Begin
5971     Select COUNT(*)
5972     Into   l_temp4
5973     From   CSI_IEA_VALUES_H csh,
5974            CSI_TRANSACTIONS csit
5975     Where  csit.transaction_id between From_trans and To_trans
5976     And    csit.creation_date < to_date(purge_to_date, 'YYYY/MM/DD HH24:MI:SS')
5977     And    csh.transaction_id = csit.transaction_id;
5978   Exception
5979     When Others Then
5980     Null;
5981   End;
5982   --
5983   --
5984   Begin
5985     Select COUNT(*)
5986     Into   l_temp5
5990     And    csit.creation_date < to_date(purge_to_date, 'YYYY/MM/DD HH24:MI:SS')
5987     From   CSI_I_PRICING_ATTRIBS_H csh,
5988            CSI_TRANSACTIONS csit
5989     Where  csit.transaction_id between From_trans and To_trans
5991     And    csh.transaction_id = csit.transaction_id;
5992   Exception
5993     When Others Then
5994     Null;
5995   End;
5996   --
5997   --
5998   Begin
5999     Select COUNT(*)
6000     Into   l_temp6
6001     From   CSI_I_ASSETS_H csh,
6002            CSI_TRANSACTIONS csit
6003     Where  csit.transaction_id between From_trans and To_trans
6004     And    csit.creation_date < to_date(purge_to_date, 'YYYY/MM/DD HH24:MI:SS')
6005     And    csh.transaction_id = csit.transaction_id;
6006   Exception
6007     When Others Then
6008     Null;
6009   End;
6010   --
6011   --
6012   Begin
6013     Select COUNT(*)
6014     Into   l_temp7
6015     From   CSI_I_VERSION_LABELS_H csh,
6016            CSI_TRANSACTIONS csit
6017     Where  csit.transaction_id between From_trans and To_trans
6018     And    csit.creation_date < to_date(purge_to_date, 'YYYY/MM/DD HH24:MI:SS')
6019     And    csh.transaction_id = csit.transaction_id;
6020   Exception
6021     When Others Then
6022     Null;
6023   End;
6024   --
6025   --
6026   Begin
6027     Select COUNT(*)
6028     Into   l_temp8
6029     From   CSI_II_RELATIONSHIPS_H csh,
6030            CSI_TRANSACTIONS csit
6031     Where  csit.transaction_id between From_trans and To_trans
6032     And    csit.creation_date < to_date(purge_to_date, 'YYYY/MM/DD HH24:MI:SS')
6033     And    csh.transaction_id = csit.transaction_id;
6034   Exception
6035     When Others Then
6036     Null;
6037   End;
6038   --
6039   --
6040   Begin
6041     Select COUNT(*)
6042     Into   l_temp9
6043     From   CSI_SYSTEMS_H csh,
6044            CSI_TRANSACTIONS csit
6045     Where  csit.transaction_id between From_trans and To_trans
6046     And    csit.creation_date < to_date(purge_to_date, 'YYYY/MM/DD HH24:MI:SS')
6047     And    csh.transaction_id = csit.transaction_id;
6048   Exception
6049     When Others Then
6050     Null;
6051   End;
6052   --
6053   Recs_Count := l_temp+l_temp1+l_temp2+l_temp3+l_temp4+l_temp5+l_temp6+l_temp7+l_temp8+l_temp9;
6054 
6055 End;
6056 
6057 END CSI_TXN_HISTORY_PURGE_PVT;