DBA Data[Home] [Help]

PACKAGE BODY: APPS.PA_PURGE_CAPITAL

Source


1 PACKAGE BODY PA_Purge_Capital AS
2 /* $Header: PAXGCPPB.pls 120.3 2008/01/22 13:43:54 rthumma ship $ */
3 
4     l_commit_size     NUMBER ;
5     l_err_stage       VARCHAR2(500);
6 
7     -- This procedure is called from the main purge program. The
8     -- parameters passed to this procedure are as follows
9 
10 /*  * p_purge_batch_id		-> Purge batch Id
11     * p_project_id		-> Project Id
12     * p_purge_release		-> The release during which it is purged
13     * p_archive_flag		-> This flag will indicate if the  records need to be archived
14 				   before they are purged.
15     * p_txn_to_date		-> Date through which the transactions need to be purged. This
16                                    value will be NULL if the purge batch is for closed projects.
17     * p_commit_size		-> The maximum number of records that can be allowed to remain
18 				   uncommited. If the number of records processed goes beyond
19                                    this number then the process is commited.
20 */
21 
22 
23 
24 PROCEDURE PA_Capital_Main_Purge (p_purge_batch_id	in NUMBER,
25 				 p_project_id		in NUMBER,
26 				 p_purge_release	in VARCHAR2,
27 				 p_txn_to_date		in DATE,
28 				 p_archive_flag		in VARCHAR2,
29 				 p_commit_size		in NUMBER,
30 				 p_err_stack		in OUT NOCOPY VARCHAR2,
31 				 p_err_stage		in OUT NOCOPY VARCHAR2,
32 				 p_err_code		in OUT NOCOPY VARCHAR2) IS
33 
34   l_old_err_stack      VARCHAR2(2000);
35 
36   BEGIN
37 
38     p_err_code := 0;
39 
40     l_old_err_stack := p_err_stack;
41 
42     p_err_stack := p_err_stack || ' ->Before call to purge the data ';
43 
44     -- Call the procedure to delete Project Asset Line Details
45 
46     pa_debug.debug('*-> About to purge Asset Line Details ') ;
47 
48     l_err_stage := 'Before calling PA_Purge_Capital.PA_MC_AsstLinDtls';
49 
50     PA_Purge_Capital.PA_MC_AsstLinDtls(p_purge_batch_id    => p_purge_batch_id,
51                                        p_project_id        => p_project_id,
52                                        p_txn_to_date       => p_txn_to_date,
53                                        p_purge_release     => p_purge_release,
54                                        p_archive_flag      => p_archive_flag,
55                                        p_commit_size       => p_commit_size,
56                                        p_err_code          => p_err_code,
57                                        p_err_stack         => p_err_stack,
58                                        p_err_stage         => p_err_stage) ;
59 
60     l_err_stage := 'Before calling PA_Purge_Capital.PA_AsstLineDtls';
61 
62     IF p_err_code = 0 then
63       PA_Purge_Capital.PA_AsstLineDtls(p_purge_batch_id  => p_purge_batch_id,
64                                        p_project_id      => p_project_id,
65                                        p_txn_to_date     => p_txn_to_date,
66                                        p_purge_release   => p_purge_release,
67                                        p_archive_flag    => p_archive_flag,
68                                        p_commit_size     => p_commit_size,
69                                        p_err_code        => p_err_code,
70                                        p_err_stack       => p_err_stack,
71                                        p_err_stage       => p_err_stage) ;
72     End IF;
73 
74     IF p_err_code = 0 THEN
75        p_err_stack := l_old_err_stack;
76     End IF;
77 
78 EXCEPTION
79   WHEN OTHERS THEN
80     p_err_code := -1;
81     p_err_stage := to_char(SQLCODE);
82     FND_MSG_PUB.Add_Exc_Msg(
83             p_pkg_name        => 'PA_PURGE_CAPITAL',
84             p_procedure_name  => 'PA_CAPITAL_MAIN_PURGE'||'-'||l_err_stage,
85             p_error_text      => 'ORA-'||LPAD(substr(p_err_stage,2),5,'0'));
86 
87     RAISE ;
88 
89 END PA_Capital_Main_Purge ;
90 
91 
92 
93 /********** Procedure Rearchitured bug 36137398 ***********/
94 
95 PROCEDURE PA_MC_AsstLinDtls (p_purge_batch_id	IN NUMBER,
96 	                     p_project_id       IN NUMBER,
97 			     p_txn_to_date	IN DATE,
98 			     p_purge_release	IN VARCHAR2,
99 			     p_archive_flag	IN VARCHAR2,
100 			     p_commit_size	IN NUMBER,
101 			     p_err_code		IN OUT NOCOPY NUMBER,
102 			     p_err_stack        IN OUT NOCOPY VARCHAR2,
103 			     p_err_stage	IN OUT NOCOPY VARCHAR2)    IS
104 
105   l_old_err_stack       VARCHAR2(2000);
106   NoOfRecordsIns        NUMBER;
107   NoOfRecordsDel        NUMBER;
108 
109   l_sob            		   PA_PLSQL_DATATYPES.Num15TabTyp;
110   l_asset_line_uniq_id 	   PA_PLSQL_DATATYPES.Num15TabTyp;
111   l_asset_line_id		   PA_PLSQL_DATATYPES.Num15TabTyp;
112   l_cip_cost			   PA_PLSQL_DATATYPES.Num15TabTyp;
113   l_cur_code		       PA_PLSQL_DATATYPES.Char30TabTyp;
114   l_exc_rate			   PA_PLSQL_DATATYPES.Num15TabTyp;
115   l_conv_date			   PA_PLSQL_DATATYPES.DateTabTyp;
116 
117 CURSOR c_ast_ln_det_ar Is
118 SELECT   pmald.Set_Of_Books_Id,
119               pmald.Proj_Asset_Line_Dtl_Uniq_Id,
120               pmald.Project_Asset_Line_Detail_Id,
121               pmald.Cip_Cost,
122               pmald.Currency_Code,
123               pmald.Exchange_Rate,
124               pmald.Conversion_Date
125         FROM
126               PA_Expenditure_Items_All pei ,
127               PA_Project_Asset_Line_Details pald,
128               pa_implementations_all pia ,
129               -- gl_mc_reporting_options gmc ,
130               GL_ALC_LEDGER_RSHIPS_V gmc, -- R12 Ledger changes
131               PA_MC_Prj_Ast_Line_Dtls pmald
132       WHERE
133              pald.proj_asset_line_dtl_uniq_id = pmald.proj_asset_line_dtl_uniq_id
134         AND  pald.Expenditure_Item_id = pei.Expenditure_Item_id
135         AND  pei.project_id = p_project_id
136         AND  NVL(pia.ORG_ID,-99) = NVL(pei.ORG_ID,-99)
137         AND  gmc.SOURCE_LEDGER_ID = pia.SET_OF_BOOKS_ID
138         AND  gmc.APPLICATION_ID  = 275
139         AND  gmc.Org_Id  = pia.ORG_ID
140         AND  pmald.SET_OF_BOOKS_ID = gmc.LEDGER_ID;
141 
142   BEGIN
143 
144     p_err_code := 0;
145 
146     l_old_err_stack := p_err_stack;
147 
148     p_err_stack := p_err_stack || ' ->Before insert into PA_MC_PRJ_AST_LINE_DETS_AR' ;
149 
150     Open c_ast_ln_det_ar;
151 
152 	LOOP
153 
154         l_commit_size := p_commit_size;  /* -- Bug#6609009 -- */
155 
156 	  IF p_archive_flag = 'Y' THEN
157         -- If archive option is selected then the records are inserted into the archive tables
158         -- before being purged. The where condition is such that only the it inserts half the
159         -- no. of records specified in the commit size.
160         l_commit_size := p_commit_size / 2 ;
161 	  End If;
162 
163 	l_commit_size := NVL(l_commit_size,1000); /* -- Bug#6609009 -- */
164 
165 	  FETCH c_ast_ln_det_ar bulk collect into
166 			  l_sob            		   ,
167 			  l_asset_line_uniq_id 	   ,
168 			  l_asset_line_id		   ,
169 			  l_cip_cost			   ,
170 			  l_cur_code		       ,
171 			  l_exc_rate			   ,
172 			  l_conv_date
173 	  LIMIT l_commit_size;
174 
175 	  If l_sob.count <> 0 Then
176 
177 			  l_err_stage := 'Before Inserting into PA_MC_PRJ_AST_LN_DET_AR table';
178 
179 			  IF p_archive_flag = 'Y'  THEN
180 
181 				FORALL i in 1..l_sob.count
182 					INSERT INTO PA_MC_PRJ_AST_LN_DET_AR
183 					( Set_Of_Books_Id,
184 					  Proj_Asset_Line_Dtl_Uniq_Id,
185 					  Project_Asset_Line_Detail_Id,
186 					  Cip_Cost,
187 					  Currency_Code,
188 					  Exchange_Rate,
189 					  Conversion_Date,
190 					  Purge_Release,
191 					  Purge_Batch_Id ,
192 					  Purge_Project_Id)
193 					  VALUES(
194 					  l_sob(i)            		   ,
195 					  l_asset_line_uniq_id(i) 	   ,
196 					  l_asset_line_id(i)		   ,
197 					  l_cip_cost(i)			   ,
198 					  l_cur_code(i)		       ,
199 					  l_exc_rate(i)			   ,
200 					  l_conv_date(i)			   ,
201 					  P_Purge_Release,
202 					  P_Purge_Batch_Id,
203 					  p_project_id
204 					  );
205 
206 				NoOfRecordsIns := l_sob.count ;
207 
208 			  End If;
209 
210 			  FORALL i in 1..l_sob.count
211 					Delete From PA_MC_Prj_Ast_line_Dtls
212 					 Where SET_OF_BOOKS_ID = l_sob(i)
213 					   And PROJ_ASSET_LINE_DTL_UNIQ_ID = l_asset_line_uniq_id(i);
214 
215 			  NoOfRecordsDel := l_sob.count ;
216 
217 
218 
219 			  -- After "deleting" or "deleting and inserting" a set of records
220 			  -- the transaction is commited. This also creates a record in the
221 			  -- Pa_Purge_Project_details which will show the no. of records
222 			  -- that are purged from each table.
223 
224 			  l_err_stage := 'Before Calling PA_Purge.CommitProcess';
225 
226 			  PA_Purge.CommitProcess(p_purge_batch_id,
227 									 p_project_id,
228 									 'PA_MC_Prj_Ast_line_Dtls',
229 									 NoOfRecordsIns,
230 									 NoOfRecordsDel,
231 									 p_err_code,
232 									 p_err_stack,
233 									 p_err_stage);
234 
235 
236 	   End If;
237 
238 	   IF c_ast_ln_det_ar%NOTFOUND and l_sob.count = 0 THEN
239 		  EXIT;
240 	   END IF;
241 
242 	   l_sob.delete;
243 	   l_asset_line_uniq_id.delete;
244 	   l_asset_line_id.delete;
245 	   l_cip_cost.delete;
246 	   l_cur_code.delete;
247 	   l_exc_rate.delete;
248 	   l_conv_date.delete;
249 
250 
251 
252     END LOOP ;
253 
254 	Close c_ast_ln_det_ar;
255 
256     p_err_stack    := l_old_err_stack ;
257 
258 EXCEPTION
259   WHEN OTHERS THEN
260     p_err_code := -1;
261     p_err_stage := to_char(SQLCODE);
262     FND_MSG_PUB.Add_Exc_Msg(
263             p_pkg_name        => 'PA_PURGE_CAPITAL',
264             p_procedure_name  => 'PA_MC_AsstLinDtls'||'-'||l_err_stage,
265             p_error_text      => 'ORA-'||LPAD(substr(p_err_stage,2),5,'0'));
266 
267     RAISE ;
268 
269 END PA_MC_AsstLinDtls;
270 
271 
272 
273 /************************************/
274 
275 /* Commenting Out below Procedure By Re-Architecturing as above
276 Bug 3613739
277 
278 PROCEDURE PA_MC_AsstLinDtls (p_purge_batch_id	IN NUMBER,
279 	                     p_project_id       IN NUMBER,
280 			     p_txn_to_date	IN DATE,
281 			     p_purge_release	IN VARCHAR2,
282 			     p_archive_flag	IN VARCHAR2,
283 			     p_commit_size	IN NUMBER,
284 			     p_err_code		IN OUT NUMBER,
285 			     p_err_stack        IN OUT VARCHAR2,
286 			     p_err_stage	IN OUT VARCHAR2)    IS
287 
288   l_old_err_stack       VARCHAR2(2000);
289   NoOfRecordsIns        NUMBER;
290   NoOfRecordsDel        NUMBER;
291 
292   BEGIN
293 
294     p_err_code := 0;
295 
296     l_old_err_stack := p_err_stack;
297 
298     p_err_stack := p_err_stack || ' ->Before insert into PA_MC_PRJ_AST_LINE_DETS_AR' ;
299 
300     LOOP
301 
302       IF p_archive_flag = 'Y' THEN
303         -- If archive option is selected then the records are inserted into the archive tables
304         -- before being purged. The where condition is such that only the it inserts half the
305         -- no. of records specified in the commit size.
306 
307         l_commit_size := p_commit_size / 2 ;
308 
309         l_err_stage := 'Before Inserting into PA_MC_PRJ_AST_LN_DET_AR table';
310 
311         INSERT INTO PA_MC_PRJ_AST_LN_DET_AR
312         ( Set_Of_Books_Id,
313           Proj_Asset_Line_Dtl_Uniq_Id,
314           Project_Asset_Line_Detail_Id,
315           Cip_Cost,
316           Currency_Code,
317           Exchange_Rate,
318           Conversion_Date,
319           Purge_Release,
320           Purge_Batch_Id ,
321           Purge_Project_Id)
322         SELECT
323               pmald.Set_Of_Books_Id,
324               pmald.Proj_Asset_Line_Dtl_Uniq_Id,
325               pmald.Project_Asset_Line_Detail_Id,
326               pmald.Cip_Cost,
327               pmald.Currency_Code,
328               pmald.Exchange_Rate,
329               pmald.Conversion_Date,
330               p_purge_release,
331               p_purge_batch_id,
332               p_project_id
333         FROM
334               PA_MC_Prj_Ast_Line_Dtls pmald,
335               PA_Project_Asset_Line_Details pald,
336               PA_Expenditure_Items_All pei
337         WHERE
338              pald.proj_asset_line_dtl_uniq_id = pmald.proj_asset_line_dtl_uniq_id
339         AND  pald.Expenditure_Item_id = pei.Expenditure_Item_id
340         AND  pei.project_id = p_project_id
341         AND  rownum < l_commit_size ;
342         ---- Commented for the bug#2385541
343         ---- NoOfRecordsIns := nvl(NoOfRecordsIns, 0) + SQL%ROWCOUNT ;
344         NoOfRecordsIns := SQL%ROWCOUNT ; --- Added for the bug#2385541
345 
346         IF SQL%ROWCOUNT > 0 THEN
347           -- We have a seperate delete statement if the archive option is
348           -- selected because if archive option is selected the the records
349           -- being purged will be those records which are already archived.
350 
351           l_err_stage := 'Before Deleting from PA_MC_Prj_Ast_line_Dtls table after Archive';
352 
353           DELETE FROM PA_MC_Prj_Ast_line_Dtls pmald
354           WHERE (pmald.Proj_Asset_Line_Dtl_Uniq_Id) in
355                                           ( SELECT pmaldar.Proj_Asset_Line_Dtl_Uniq_Id
356                                             FROM   PA_MC_PRJ_AST_LN_DET_AR pmaldar,
357                                                    PA_Project_Asset_Line_Details pald,
358                                                    PA_Expenditure_Items_All pei
359                                             WHERE
360                                                    pald.Proj_Asset_Line_Dtl_Uniq_Id =
361                                                    pmaldar.Proj_Asset_Line_Dtl_Uniq_Id
362                                             AND    pald.Expenditure_Item_id = pei.Expenditure_Item_id
363                                             AND    pei.project_id = p_project_id);
364 
365           NoOfRecordsDel := SQL%ROWCOUNT ;  ----- Added for the bug#2385541
366 
367         End IF ;
368 
369       ELSE
370 
371         l_commit_size := p_commit_size ;
372 
373         -- If the archive option is not selected then the delete will
374         -- be based on the commit size.
375 
376         l_err_stage := 'Before Deleting from PA_MC_Prj_Ast_line_Dtls table ';
377 
378         DELETE FROM PA_MC_Prj_Ast_line_Dtls pmald
379         WHERE Exists  ---- Bug 3613739 proj_asset_line_dtl_uniq_id IN
380               (SELECT proj_asset_line_dtl_uniq_id
381                FROM   PA_Project_Asset_Line_Details pald,
382                       PA_Expenditure_Items_All pei
383                WHERE  pald.Expenditure_Item_id = pei.Expenditure_Item_id
384 			   AND pmald.proj_asset_line_dtl_uniq_id =  pald.proj_asset_line_dtl_uniq_id -- Bug 3613739
385                AND    pei.project_id = p_project_id)
386         AND  rownum < l_commit_size ;
387         --- Commented for the bug#2385541
388         --- NoOfRecordsDel := nvl(NoOfRecordsDel, 0) + SQL%ROWCOUNT ;
389         NoOfRecordsDel := SQL%ROWCOUNT ;   --- Added for the bug#2385541
390 
391       End IF ;
392 
393       IF SQL%ROWCOUNT = 0 then
394         -- Once the SqlCount becomes 0, which means that there are
395         -- no more records to be purged then we exit the loop.
396 
397         EXIT ;
398 
399       ELSE
400         -- After "deleting" or "deleting and inserting" a set of records
401         -- the transaction is commited. This also creates a record in the
402         -- Pa_Purge_Project_details which will show the no. of records
403         -- that are purged from each table.
404 
405         l_err_stage := 'Before Calling PA_Purge.CommitProcess';
406 
407         PA_Purge.CommitProcess(	p_purge_batch_id,
408                                 p_project_id,
409                                 'PA_MC_Prj_Ast_line_Dtls',
410                                 NoOfRecordsIns,
411                                 NoOfRecordsDel,
412                                 p_err_code,
413                                 p_err_stack,
414                                 p_err_stage) ;
415 
416       End IF ;
417 
418     END LOOP ;
419 
420     p_err_stack    := l_old_err_stack ;
421 
422 EXCEPTION
423   WHEN OTHERS THEN
424     p_err_code := -1;
425     p_err_stage := to_char(SQLCODE);
426     FND_MSG_PUB.Add_Exc_Msg(
427             p_pkg_name        => 'PA_PURGE_CAPITAL',
428             p_procedure_name  => 'PA_MC_AsstLinDtls'||'-'||l_err_stage,
429             p_error_text      => 'ORA-'||LPAD(substr(p_err_stage,2),5,'0'));
430 
431     RAISE ;
432 
433 END PA_MC_AsstLinDtls ;
434 
435 Bug 3613739
436 */
437 
438 
439 
440 PROCEDURE PA_AsstLineDtls (p_purge_batch_id	IN NUMBER,
441 	                   p_project_id		IN NUMBER,
442 			   p_txn_to_date	IN DATE,
443 			   p_purge_release	IN VARCHAR2,
444 			   p_archive_flag	IN VARCHAR2,
445 			   p_commit_size	IN NUMBER,
446 			   p_err_code		IN OUT NOCOPY NUMBER,
447 			   p_err_stack		IN OUT NOCOPY VARCHAR2,
448 			   p_err_stage		IN OUT NOCOPY VARCHAR2)    IS
449 
450   l_old_err_stack       VARCHAR2(2000);
451   NoOfRecordsIns        NUMBER;
452   NoOfRecordsDel        NUMBER;
453 
454   BEGIN
455 
456     p_err_code := 0;
457 
458     l_old_err_stack := p_err_stack;
459 
460     p_err_stack := p_err_stack || ' ->Before insert into PA_PRJ_ASSET_LN_DETS_AR' ;
461 
462     LOOP
463 
464       IF p_archive_flag = 'Y' THEN
465         -- If archive option is selected then the records are inserted into the archive tables
466         -- before being purged. The where condition is such that only the it inserts half the
467         -- no. of records specified in the commit size.
468 
469         l_commit_size := p_commit_size / 2 ;
470 
471         l_err_stage := 'Before Inserting into PA_PRJ_ASSET_LN_DETS_AR table';
472 
473         INSERT INTO PA_PRJ_ASSET_LN_DETS_AR
474         ( Expenditure_Item_Id,
475           Line_Num,
476           Project_Asset_Line_Detail_Id,
477           Cip_Cost,
478           Reversed_Flag,
479           Last_Update_Date,
480           Last_Updated_By,
481           Created_By,
482           Creation_Date,
483           Last_Update_Login,
484           Request_Id,
485           Program_Application_Id,
486           Program_Id,
487           Program_Update_Date,
488           Purge_Release,
489           Purge_Batch_Id,
490           Purge_Project_id,
491 	  PROJ_ASSET_LINE_DTL_UNIQ_ID) /* Bug#2385541  */
492         SELECT
493               pald.Expenditure_Item_Id,
494               pald.Line_Num,
495               pald.Project_Asset_Line_Detail_Id,
496               pald.Cip_Cost,
497               pald.Reversed_Flag,
498               pald.Last_Update_Date,
499               pald.Last_Updated_By,
500               pald.Created_By,
501               pald.Creation_Date,
502               pald.Last_Update_Login,
503               pald.Request_Id,
504               pald.Program_Application_Id,
505               pald.Program_Id,
506               pald.Program_Update_Date,
507               p_purge_release,
508               p_purge_batch_id,
509               p_project_id,
510 	      pald.PROJ_ASSET_LINE_DTL_UNIQ_ID  /* Bug#2385541 */
511         FROM
512               PA_Project_Asset_Line_Details pald,
513               PA_Expenditure_Items_All pei
514         WHERE
515              pald.Expenditure_Item_id = pei.Expenditure_Item_id
516         AND  pei.project_id = p_project_id
517         AND  rownum < l_commit_size ;
518     /* Commented for the bug#2385541
519         NoOfRecordsIns := nvl(NoOfRecordsIns, 0) + SQL%ROWCOUNT ;   */
520         NoOfRecordsIns := SQL%ROWCOUNT ;  /* Added for the bug#2385541 */
521 
522         IF SQL%ROWCOUNT > 0 THEN
523           -- We have a seperate delete statement if the archive option is
524           -- selected because if archive option is selected the the records
525           -- being purged will be those records which are already archived.
526 
527           l_err_stage := 'Before Deleting from PA_Project_Asset_line_Details table after Archive';
528 /* Bug#2405839: Purge process is not deleting the asset line details since, checking for
529    pald.Project_Asset_Line_Detail_Id in pald1.Proj_Asset_Line_Dtl_Uniq_Id.
530    Commented the delete statement and added the modified delete statement below.
531 
532           DELETE FROM PA_Project_Asset_line_Details pald
533           WHERE (pald.Project_Asset_Line_Detail_Id) IN
534                   ( SELECT pald1.Proj_Asset_Line_Dtl_Uniq_Id
535                     FROM PA_Project_Asset_line_Details pald1,
536                          PA_PRJ_ASSET_LN_DETS_AR paldar,
537                          PA_Expenditure_Items_All pei
538                     WHERE
539                          pald1.Project_Asset_Line_Detail_Id = paldar.Project_Asset_Line_Detail_Id
540                     AND  paldar.Expenditure_Item_Id = pei.Expenditure_Item_Id
541                     and  pei.project_id = p_project_id ) ;
542 */
543         DELETE FROM PA_Project_Asset_line_Details pald
544         WHERE (pald.PROJ_ASSET_LINE_DTL_UNIQ_ID) IN
545                 ( SELECT paldar.PROJ_ASSET_LINE_DTL_UNIQ_ID
546                   FROM PA_Project_Asset_line_Details pald1,
547                        PA_PRJ_ASSET_LN_DETS_AR paldar
548                  WHERE
549                        pald1.PROJ_ASSET_LINE_DTL_UNIQ_ID = paldar.PROJ_ASSET_LINE_DTL_UNIQ_ID
550                   AND  paldar.Purge_project_id = p_project_id
551                   AND  pald1.Project_Asset_Line_Detail_Id = paldar.Project_Asset_Line_Detail_Id) ;
552 
553 
554            NoOfRecordsDel := SQL%ROWCOUNT ;  /* Added for the bug#2385541 */
555 
556         End IF ;
557 
558       ELSE
559 
560         l_commit_size := p_commit_size ;
561 
562         -- If the archive option is not selected then the delete will
563         -- be based on the commit size.
564 
565         l_err_stage := 'Before Deleting from PA_Project_Asset_line_Details table ';
566 
567         DELETE FROM PA_Project_Asset_line_Details pald
568         WHERE Expenditure_Item_Id in (SELECT pei.Expenditure_Item_Id
569                                       FROM   PA_Expenditure_Items_All pei
570                                       WHERE  pei.project_id = p_project_id)
571         AND  rownum < l_commit_size ;
572         /* Commented for the Bug#2385541
573         NoOfRecordsDel := nvl(NoOfRecordsDel, 0) + SQL%ROWCOUNT ;   */
574         NoOfRecordsDel := SQL%ROWCOUNT ;  /* Added for the bug#2385541 */
575 
576       End IF ;
577 
578       IF SQL%ROWCOUNT = 0 then
579         -- Once the SqlCount becomes 0, which means that there are
580         -- no more records to be purged then we exit the loop.
581 
582         EXIT ;
583 
584       ELSE
585         -- After "deleting" or "deleting and inserting" a set of records
586         -- the transaction is commited. This also creates a record in the
587         -- Pa_Purge_Project_details which will show the no. of records
588         -- that are purged from each table.
589 
590         l_err_stage := 'Before Calling PA_Purge.CommitProcess';
591 
592         PA_Purge.CommitProcess(	p_purge_batch_id,
593                                 p_project_id,
594                                 'PA_Project_Asset_line_Details',
595                                 NoOfRecordsIns,
596                                 NoOfRecordsDel,
597                                 p_err_code,
598                                 p_err_stack,
599                                 p_err_stage) ;
600 
601       End IF ;
602 
603     END LOOP ;
604 
605     p_err_stack    := l_old_err_stack ;
606 
607 EXCEPTION
608   WHEN OTHERS THEN
609     p_err_code := -1;
610     p_err_stage := to_char(SQLCODE);
611     FND_MSG_PUB.Add_Exc_Msg(
612             p_pkg_name        => 'PA_PURGE_CAPITAL',
613             p_procedure_name  => 'PA_AsstLineDtls'||'-'||l_err_stage,
614             p_error_text      => 'ORA-'||LPAD(substr(p_err_stage,2),5,'0'));
615 
616     RAISE ;
617 
618 END PA_AsstLineDtls ;
619 
620 END PA_Purge_Capital;