DBA Data[Home] [Help]

PACKAGE BODY: APPS.OKC_OIE_PVT

Source


1 PACKAGE BODY OKC_OIE_PVT AS
2 /* $Header: OKCSOIEB.pls 120.1 2005/07/15 09:14:19 parkumar noship $ */
3 
4 	l_debug VARCHAR2(1) := NVL(FND_PROFILE.VALUE('AFLOG_ENABLED'),'N');
5 
6   /************************ HAND-CODED *********************************/
7   FUNCTION Validate_Attributes ( p_oiev_rec IN oiev_rec_type) RETURN VARCHAR2;
8   G_SQLERRM_TOKEN    CONSTANT VARCHAR2(200) := 'SQLerrm';
9   G_SQLCODE_TOKEN    CONSTANT VARCHAR2(200) := 'SQLcode';
10   G_NO_PARENT_RECORD CONSTANT VARCHAR2(200) := 'OKC_NO_PARENT_RECORD';
11   G_UNEXPECTED_ERROR CONSTANT VARCHAR2(200) := 'OKC_CONTRACTS_UNEXPECTED_ERROR';
12   G_VIEW             CONSTANT VARCHAR2(200) := 'OKC_OPERATION_INSTANCES_V';
13   G_EXCEPTION_HALT_VALIDATION exception;
14 
15   -- Start of comments
16   --
17   -- Procedure Name  : validate_cop_id
18   -- Description     :
19   -- Business Rules  :
20   -- Parameters      :
21   -- Version         : 1.0
22   -- End of comments
23   PROCEDURE validate_cop_id(x_return_status OUT NOCOPY   VARCHAR2,
24                             p_oiev_rec      IN    oiev_rec_type) is
25 	 l_dummy_var   VARCHAR2(1) := '?';
26       CURSOR l_copv_csr (p_cop_id IN NUMBER) IS
27       SELECT 'x'
28         FROM okc_class_operations
29        WHERE id = p_cop_id;
30   Begin
31 
32     IF (l_debug = 'Y') THEN
33        okc_debug.Set_Indentation('OKC_OIE_PVT');
34        okc_debug.log('100: Entered validate_cop_id', 2);
35     END IF;
36 
37     -- initialize return status
38     x_return_status := OKC_API.G_RET_STS_SUCCESS;
39 
40     -- check that data exists
41     If (p_oiev_rec.cop_id = OKC_API.G_MISS_NUM or
42 	   p_oiev_rec.cop_id IS NULL)
43     Then
44   	  OKC_API.SET_MESSAGE(p_app_name		=> g_app_name,
45 					  p_msg_name		=> g_required_value,
46 					  p_token1		=> g_col_name_token,
47 					  p_token1_value	=> 'Class Operation Id');
48 	   -- notify caller of an error
49         x_return_status := OKC_API.G_RET_STS_ERROR;
50 
51 	   -- halt validation
52 	   raise G_EXCEPTION_HALT_VALIDATION;
53     End If;
54 
55     -- Check foreign key
56     Open l_copv_csr(p_oiev_rec.cop_id);
57     Fetch l_copv_csr into l_dummy_var;
58     Close l_copv_csr;
59 
60     -- if l_dummy_var still set to default, data was not found
61     If (l_dummy_var = '?') Then
62     	  OKC_API.SET_MESSAGE(
63 				    p_app_name      => g_app_name,
64 				    p_msg_name      => g_no_parent_record,
65 				    p_token1        => g_col_name_token,
66 				    p_token1_value  => 'Class Operation Id',
67 				    p_token2        => g_child_table_token,
68 				    p_token2_value  => G_VIEW,
69 				    p_token3        => g_parent_table_token,
70 				    p_token3_value  => 'OKC_CLASS_OPERATIONS_V');
71 	  -- notify caller of an error
72 	  x_return_status := OKC_API.G_RET_STS_ERROR;
73     End If;
74 
75  IF (l_debug = 'Y') THEN
76     okc_debug.log('200: Exiting validate_cop_id', 2);
77     okc_debug.Reset_Indentation;
78  END IF;
79 
80   exception
81     when G_EXCEPTION_HALT_VALIDATION then
82 
83     IF (l_debug = 'Y') THEN
84        okc_debug.log('300: Exiting validate_cop_id:G_EXCEPTION_HALT_VALIDATION Exception', 2);
85        okc_debug.Reset_Indentation;
86     END IF;
87 
88       -- no processing necessary; validation can continue with next column
89       null;
90 
91     when OTHERS then
92 
93     IF (l_debug = 'Y') THEN
94        okc_debug.log('400: Exiting validate_cop_id:OTHERS Exception', 2);
95        okc_debug.Reset_Indentation;
96     END IF;
97 
98 	  -- store SQL error message on message stack
99   	  OKC_API.SET_MESSAGE(p_app_name		=> g_app_name,
100 					  p_msg_name		=> g_unexpected_error,
101 					  p_token1		=> g_sqlcode_token,
102 					  p_token1_value	=> sqlcode,
103 					  p_token2		=> g_sqlerrm_token,
104 					  p_token2_value	=> sqlerrm);
105 	   -- notify caller of an error as UNEXPETED error
106         x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
107 
108   End validate_cop_id;
109 
110   -- Start of comments
111   --
112   -- Procedure Name  : validate_target_chr_id
113   -- Description     :
114   -- Business Rules  :
115   -- Parameters      :
116   -- Version         : 1.0
117   -- End of comments
118   PROCEDURE validate_target_chr_id(x_return_status OUT NOCOPY   VARCHAR2,
119                                    p_oiev_rec      IN    oiev_rec_type) is
120 
121     l_dummy_var   VARCHAR2(1) := '?';
122     Cursor l_chrv_csr Is
123   	  select 'x'
124 	  from OKC_K_HEADERS_B
125   	  where id = p_oiev_rec.target_chr_id;
126 
127   Begin
128 
129     IF (l_debug = 'Y') THEN
130        okc_debug.Set_Indentation('OKC_OIE_PVT');
131        okc_debug.log('500: Entered validate_target_chr_id', 2);
132     END IF;
133 
134     -- initialize return status
135     x_return_status := OKC_API.G_RET_STS_SUCCESS;
136 
137     -- enforce foreign key (target_chr_id is optional)
138     If (p_oiev_rec.target_chr_id <> OKC_API.G_MISS_NUM and
139   	   p_oiev_rec.target_chr_id IS NOT NULL)
140     Then
141        Open l_chrv_csr;
142        Fetch l_chrv_csr Into l_dummy_var;
143        Close l_chrv_csr;
144        -- if l_dummy_var still set to default, data was not found
145        If (l_dummy_var = '?') Then
146   	     OKC_API.SET_MESSAGE(p_app_name		=> g_app_name,
147 				          p_msg_name		=> g_no_parent_record,
148 					     p_token1		=> g_col_name_token,
149 					     p_token1_value	=> 'Target Contract Id',
150 					     p_token2		=> g_child_table_token,
151 					     p_token2_value	=> G_VIEW,
152 					     p_token3		=> g_parent_table_token,
153 					     p_token3_value	=> 'OKC_K_HEADERS_V');
154 	     -- notify caller of an error
155           x_return_status := OKC_API.G_RET_STS_ERROR;
156       End If;
157     End If;
158 
159   IF (l_debug = 'Y') THEN
160      okc_debug.log('600: Exiting validate_target_chr_id', 2);
161      okc_debug.Reset_Indentation;
162   END IF;
163 
164   exception
165     when OTHERS then
166 
167     IF (l_debug = 'Y') THEN
168        okc_debug.log('700: Exiting validate_target_chr_id:OTHERS Exception', 2);
169        okc_debug.Reset_Indentation;
170     END IF;
171 
172 	  -- store SQL error message on message stack
173   	  OKC_API.SET_MESSAGE(p_app_name		=> g_app_name,
174 					  p_msg_name		=> g_unexpected_error,
175 					  p_token1		=> g_sqlcode_token,
176 					  p_token1_value	=> sqlcode,
177 					  p_token2		=> g_sqlerrm_token,
178 					  p_token2_value	=> sqlerrm);
179 	   -- notify caller of an error as UNEXPETED error
180         x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
181 
182         -- verify that cursor was closed
183         if l_chrv_csr%ISOPEN then
184 	      close l_chrv_csr;
185         end if;
186   End validate_target_chr_id;
187 
188   PROCEDURE validate_status_code(x_return_status OUT NOCOPY   VARCHAR2,
189                                  p_oiev_rec      IN    oiev_rec_type) is
190   Begin
191 
192     IF (l_debug = 'Y') THEN
193        okc_debug.Set_Indentation('OKC_OIE_PVT');
194        okc_debug.log('800: Entered validate_status_code', 2);
195     END IF;
196 
197     -- initialize return status
198     x_return_status := OKC_API.G_RET_STS_SUCCESS;
199 
200     -- check that data exists
201     If (p_oiev_rec.status_code = OKC_API.G_MISS_CHAR or
202 	   p_oiev_rec.status_code IS NULL)
203     Then
204   	  OKC_API.SET_MESSAGE(p_app_name		=> g_app_name,
205 					  p_msg_name		=> g_required_value,
206 					  p_token1		=> g_col_name_token,
207 					  p_token1_value	=> 'Status Code');
208 	   -- notify caller of an error
209         x_return_status := OKC_API.G_RET_STS_ERROR;
210 
211 	   -- halt validation
212 	   raise G_EXCEPTION_HALT_VALIDATION;
213     End If;
214 
215     -- enforce foreign key
216     -- check for OKS mass change operation status first
217     -- if not found , check for OKC Status
218 
219     x_return_status := OKC_UTIL.check_lookup_code('OKS_OPERATION_STATUS',
220 										p_oiev_rec.status_code);
221 
222     If (x_return_status <> OKC_API.G_RET_STS_SUCCESS) Then
223 	    -- Check if the value is a valid code from lookup table
224 	    x_return_status := OKC_UTIL.check_lookup_code('OKC_STATUS_TYPE',
225 						                         p_oiev_rec.status_code);
226 	    If (x_return_status = OKC_API.G_RET_STS_ERROR) Then
227 			  --set error message in message stack
228 			  OKC_API.SET_MESSAGE(
229 				   p_app_name	=> G_APP_NAME,
230 				   p_msg_name	=> G_INVALID_VALUE,
231 				   p_token1		=> G_COL_NAME_TOKEN,
232 				   p_token1_value => 'Status Code');
233 			  raise G_EXCEPTION_HALT_VALIDATION;
234 		Elsif (x_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) Then
235 		       raise G_EXCEPTION_HALT_VALIDATION;
236 		End If;
237     End If;
238 
239  IF (l_debug = 'Y') THEN
240     okc_debug.log('900: Exiting validate_status_code', 2);
241     okc_debug.Reset_Indentation;
242  END IF;
243 
244   EXCEPTION
245     when OTHERS then
246 
247     IF (l_debug = 'Y') THEN
248        okc_debug.log('1000: Exiting validate_status_code:OTHERS Exception', 2);
249        okc_debug.Reset_Indentation;
250     END IF;
251 
252 	  -- store SQL error message on message stack
253   	  OKC_API.SET_MESSAGE(p_app_name		=> g_app_name,
254 					  p_msg_name		=> g_unexpected_error,
255 					  p_token1		=> g_sqlcode_token,
256 					  p_token1_value	=> sqlcode,
257 					  p_token2		=> g_sqlerrm_token,
258 					  p_token2_value	=> sqlerrm);
259 	   -- notify caller of an error as UNEXPETED error
260         x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
261 
262   End validate_status_code;
263 
264 
265 -- Start of comments
266 --
267 -- Procedure Name  : validate_jtot_object1_code
268 -- Description     :
269 -- Business Rules  :
270 -- Parameters      :
271 -- Version         : 1.0
272 -- End of comments
273 
274 procedure validate_jtot_object1_code(x_return_status OUT NOCOPY        VARCHAR2,
275                           p_oiev_rec      IN    oiev_rec_type) is
276    l_dummy_var                 varchar2(1) := '?';
277 --
278  CURSOR l_jtf_csr IS
279    SELECT '!'
280    FROM JTF_OBJECTS_B
281    WHERE object_code = p_oiev_rec.jtot_object1_code
282    AND sysdate between nvl(start_date_active,sysdate) and nvl(end_date_active,sysdate);
283 
284 begin
285 
286     IF (l_debug = 'Y') THEN
287        okc_debug.Set_Indentation('OKC_OIE_PVT');
288        okc_debug.log('1100: Entered validate_jtot_object1_code', 2);
289     END IF;
290 
291   x_return_status := OKC_API.G_RET_STS_SUCCESS;
292   if (p_oiev_rec.jtot_object1_code = OKC_API.G_MISS_CHAR or p_oiev_rec.jtot_object1_code is NULL) then
293     return;
294   end if;
295 --
296   open l_jtf_csr;
297   fetch l_jtf_csr into l_dummy_var;
298   close l_jtf_csr;
299   if (l_dummy_var = '?') then
300     OKC_API.set_message(G_APP_NAME,G_INVALID_VALUE,G_COL_NAME_TOKEN,'JTOT_OBJECT1_CODE');
301     x_return_status := OKC_API.G_RET_STS_ERROR;
302   end if;
303 
304  IF (l_debug = 'Y') THEN
305     okc_debug.log('1200: Exiting validate_jtot_object1_code', 2);
306     okc_debug.Reset_Indentation;
307  END IF;
308 
309 exception
310   when OTHERS then
311 
312     IF (l_debug = 'Y') THEN
313        okc_debug.log('1300: Exiting validate_jtot_object1_code:OTHERS Exception', 2);
314        okc_debug.Reset_Indentation;
315     END IF;
316 
317     if l_jtf_csr%ISOPEN then
318       close l_jtf_csr;
319     end if;
320     OKC_API.set_message(p_app_name     => g_app_name,
321                         p_msg_name     => g_unexpected_error,
322                         p_token1       => g_sqlcode_token,
323                         p_token1_value => sqlcode,
324                         p_token2       => g_sqlerrm_token,
325                         p_token2_value => sqlerrm);
326     x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
327 
328 end validate_jtot_object1_code;
329 
330 -- Start of comments
331 --
332 -- Procedure Name  : validate_object1_id1
333 -- Description     :  to be called from validate record
334 -- Business Rules  :
335 -- Parameters      :
336 -- Version         : 1.0
337 -- End of comments
338 
339 procedure validate_object1_id1(x_return_status OUT NOCOPY      VARCHAR2,
340                           p_oiev_rec      IN    oiev_rec_type) is
341  l_dummy_var                 varchar2(1) := '?';
342  L_FROM_TABLE                    VARCHAR2(200);
343  L_WHERE_CLAUSE            VARCHAR2(2000);
344  cursor l_object1_csr is
345  select
346         from_table
347         ,trim(where_clause) where_clause
348  from
349         jtf_objects_vl OB
350  where
351         OB.OBJECT_CODE = p_oiev_rec.jtot_object1_code
352  ;
353  e_no_data_found EXCEPTION;
354  PRAGMA EXCEPTION_INIT(e_no_data_found,100);
355  e_too_many_rows EXCEPTION;
356  PRAGMA EXCEPTION_INIT(e_too_many_rows,-1422);
357  e_source_not_exists EXCEPTION;
358  PRAGMA EXCEPTION_INIT(e_source_not_exists,-942);
359  e_column_not_exists EXCEPTION;
360  PRAGMA EXCEPTION_INIT(e_column_not_exists,-904);
361 begin
362 
363     IF (l_debug = 'Y') THEN
364        okc_debug.Set_Indentation('OKC_OIE_PVT');
365        okc_debug.log('1400: Entered validate_object1_id1', 2);
366     END IF;
367 
368   x_return_status := OKC_API.G_RET_STS_SUCCESS;
369   if (p_oiev_rec.jtot_object1_code = OKC_API.G_MISS_CHAR or p_oiev_rec.jtot_object1_code is NULL) then
370     return;
371   end if;
372   if (p_oiev_rec.object1_id1 = OKC_API.G_MISS_CHAR or p_oiev_rec.object1_id1 is NULL) then
373         return;
374   end if;
375   open l_object1_csr;
376   fetch l_object1_csr into l_from_table, l_where_clause;
377   close l_object1_csr;
378   if (l_where_clause is not null) then
379         l_where_clause := ' and '||l_where_clause;
380   end if;
381   EXECUTE IMMEDIATE 'select ''x'' from '||l_from_table||
382         ' where id1=:object1_id1 and id2=:object1_id2'||l_where_clause
383         into l_dummy_var
384         USING p_oiev_rec.object1_id1, p_oiev_rec.object1_id2;
385 
386 IF (l_debug = 'Y') THEN
387    okc_debug.log('1500: Exiting validate_object1_id1', 2);
388    okc_debug.Reset_Indentation;
389 END IF;
390 
391 exception
392   when e_source_not_exists then
393 
394     IF (l_debug = 'Y') THEN
395        okc_debug.log('1600: Exiting validate_object1_id1:e_source_not_exists Exception', 2);
396        okc_debug.Reset_Indentation;
397     END IF;
398 
399     OKC_API.set_message(G_APP_NAME, G_INVALID_VALUE,G_COL_NAME_TOKEN,'JTOT_OBJECT1_CODE');
400     x_return_status := OKC_API.G_RET_STS_ERROR;
401   when e_column_not_exists then
402 
403     IF (l_debug = 'Y') THEN
404        okc_debug.log('1700: Exiting validate_object1_id1:e_column_not_exists Exception', 2);
405        okc_debug.Reset_Indentation;
406     END IF;
407 
408     OKC_API.set_message(G_APP_NAME, G_INVALID_VALUE,G_COL_NAME_TOKEN,l_from_table||'.ID1');
409     x_return_status := OKC_API.G_RET_STS_ERROR;
410   when e_no_data_found then
411 
412     IF (l_debug = 'Y') THEN
413        okc_debug.log('1800: Exiting validate_object1_id1:e_no_data_found Exception', 2);
414        okc_debug.Reset_Indentation;
415     END IF;
416 
417     OKC_API.set_message(G_APP_NAME, G_INVALID_VALUE,G_COL_NAME_TOKEN,'OBJECT1_ID1');
418     x_return_status := OKC_API.G_RET_STS_ERROR;
419   when e_too_many_rows then
420 
421     IF (l_debug = 'Y') THEN
422        okc_debug.log('1900: Exiting validate_object1_id1:e_too_many_rows Exception', 2);
423        okc_debug.Reset_Indentation;
424     END IF;
425 
426     OKC_API.set_message(G_APP_NAME, G_INVALID_VALUE,G_COL_NAME_TOKEN,l_from_table||'.ID1');
427     x_return_status := OKC_API.G_RET_STS_ERROR;
428   when OTHERS then
429 
430     IF (l_debug = 'Y') THEN
431        okc_debug.log('2000: Exiting validate_object1_id1:OTHERS Exception', 2);
432        okc_debug.Reset_Indentation;
433     END IF;
434 
435     if l_object1_csr%ISOPEN then
436       close l_object1_csr;
437     end if;
438     OKC_API.set_message(p_app_name     => g_app_name,
439                         p_msg_name     => g_unexpected_error,
440                         p_token1       => g_sqlcode_token,
441                         p_token1_value => sqlcode,
442                         p_token2       => g_sqlerrm_token,
443                         p_token2_value => sqlerrm);
444     x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
445 
446 end validate_object1_id1;
447 
448   /*********************** END HAND-CODED ********************************/
449 
450   ---------------------------------------------------------------------------
451   -- FUNCTION get_seq_id
452   ---------------------------------------------------------------------------
453   FUNCTION get_seq_id RETURN NUMBER IS
454     Cursor c Is
455     SELECT OKC_OPERATION_INSTANCES_S1.nextval
456     FROM dual;
457 
458     l_seq NUMBER;
459   BEGIN
460 
461     open c;
462     fetch c into l_seq;
463     close c;
464     RETURN (l_seq);
465 
466     --RETURN(okc_p_util.raw_to_number(sys_guid()));
467 
468   END get_seq_id;
469 
470   ---------------------------------------------------------------------------
471   -- PROCEDURE qc
472   ---------------------------------------------------------------------------
473   PROCEDURE qc IS
474   BEGIN
475 
476     null;
477 
478   END qc;
479 
480   ---------------------------------------------------------------------------
481   -- PROCEDURE change_version
482   ---------------------------------------------------------------------------
483   PROCEDURE change_version IS
484   BEGIN
485 
486     null;
487 
488   END change_version;
489 
490   ---------------------------------------------------------------------------
491   -- PROCEDURE api_copy
492   ---------------------------------------------------------------------------
493   PROCEDURE api_copy IS
494   BEGIN
495 
496     null;
497 
498   END api_copy;
499 
500   ---------------------------------------------------------------------------
501   -- FUNCTION get_rec for: OKC_OPERATION_INSTANCES
502   ---------------------------------------------------------------------------
503   FUNCTION get_rec (
504     p_oie_rec                      IN oie_rec_type,
505     x_no_data_found                OUT NOCOPY BOOLEAN
506   ) RETURN oie_rec_type IS
507     CURSOR okc_operation_instances_pk_csr (p_id                 IN NUMBER) IS
508     SELECT
509             ID,
510             COP_ID,
511             STATUS_CODE,
512             OBJECT_VERSION_NUMBER,
513             CREATED_BY,
514             CREATION_DATE,
515             LAST_UPDATED_BY,
516             LAST_UPDATE_DATE,
517             LAST_UPDATE_LOGIN,
518             NAME,
519             TARGET_CHR_ID,
520 		  REQUEST_ID,
521 		  PROGRAM_APPLICATION_ID,
522 		  PROGRAM_ID,
523 		  PROGRAM_UPDATE_DATE,
524 		  JTOT_OBJECT1_CODE,
525                   OBJECT1_ID1,
526                   OBJECT1_ID2,
527 -- R12 Data Model Changes 4485150 Start
528             BATCH_ID
529 -- R12 Data Model Changes 4485150 End
530       FROM Okc_Operation_Instances
531      WHERE okc_operation_instances.id = p_id;
532     l_okc_operation_instances_pk   okc_operation_instances_pk_csr%ROWTYPE;
533     l_oie_rec                      oie_rec_type;
534   BEGIN
535 
536     IF (l_debug = 'Y') THEN
537        okc_debug.Set_Indentation('OKC_OIE_PVT');
538        okc_debug.log('2500: Entered get_rec', 2);
539     END IF;
540 
541     x_no_data_found := TRUE;
542     -- Get current database values
543     OPEN okc_operation_instances_pk_csr (p_oie_rec.id);
544     FETCH okc_operation_instances_pk_csr INTO
545               l_oie_rec.ID,
546               l_oie_rec.COP_ID,
547               l_oie_rec.STATUS_CODE,
548               l_oie_rec.OBJECT_VERSION_NUMBER,
549               l_oie_rec.CREATED_BY,
550               l_oie_rec.CREATION_DATE,
551               l_oie_rec.LAST_UPDATED_BY,
552               l_oie_rec.LAST_UPDATE_DATE,
553               l_oie_rec.LAST_UPDATE_LOGIN,
554               l_oie_rec.NAME,
555               l_oie_rec.TARGET_CHR_ID,
556 		    l_oie_rec.REQUEST_ID,
557 		    l_oie_rec.PROGRAM_APPLICATION_ID,
558 		    l_oie_rec.PROGRAM_ID,
559 		    l_oie_rec.PROGRAM_UPDATE_DATE,
560 		    l_oie_rec.JTOT_OBJECT1_CODE,
561 		    l_oie_rec.OBJECT1_ID1,
562 		    l_oie_rec.OBJECT1_ID2,
563 -- R12 Data Model Changes 4485150 Start
564             l_oie_rec.batch_id;
565 -- R12 Data Model Changes 4485150 End
566 
567 
568     x_no_data_found := okc_operation_instances_pk_csr%NOTFOUND;
569     CLOSE okc_operation_instances_pk_csr;
570 
571 IF (l_debug = 'Y') THEN
572    okc_debug.log('2550: Leaving  Fn  Get_Rec ', 2);
573    okc_debug.Reset_Indentation;
574 END IF;
575 
576     RETURN(l_oie_rec);
577 
578   END get_rec;
579 
580   FUNCTION get_rec (
581     p_oie_rec                      IN oie_rec_type
582   ) RETURN oie_rec_type IS
583     l_row_notfound                 BOOLEAN := TRUE;
584   BEGIN
585 
586     RETURN(get_rec(p_oie_rec, l_row_notfound));
587 
588   END get_rec;
589   ---------------------------------------------------------------------------
590   -- FUNCTION get_rec for: OKC_OPERATION_INSTANCES_V
591   ---------------------------------------------------------------------------
592   FUNCTION get_rec (
593     p_oiev_rec                      IN oiev_rec_type,
594     x_no_data_found                OUT NOCOPY BOOLEAN
595   ) RETURN oiev_rec_type IS
596     CURSOR oiev_pk_csr (p_id                 IN NUMBER) IS
597     SELECT
598             ID,
599             NAME,
600             COP_ID,
601             STATUS_CODE,
602             TARGET_CHR_ID,
603             OBJECT_VERSION_NUMBER,
604             CREATED_BY,
605             CREATION_DATE,
606             LAST_UPDATED_BY,
607             LAST_UPDATE_DATE,
608             LAST_UPDATE_LOGIN,
609             JTOT_OBJECT1_CODE,
610             OBJECT1_ID1,
611             OBJECT1_ID2
612       FROM Okc_Operation_Instances_V
613      WHERE okc_operation_instances_v.id = p_id;
614     l_oiev_pk                       oiev_pk_csr%ROWTYPE;
615     l_oiev_rec                      oiev_rec_type;
616   BEGIN
617 
618     IF (l_debug = 'Y') THEN
619        okc_debug.Set_Indentation('OKC_OIE_PVT');
620        okc_debug.log('2700: Entered get_rec', 2);
621     END IF;
622 
623     x_no_data_found := TRUE;
624     -- Get current database values
625     OPEN oiev_pk_csr (p_oiev_rec.id);
626     FETCH oiev_pk_csr INTO
627               l_oiev_rec.ID,
628               l_oiev_rec.NAME,
629               l_oiev_rec.COP_ID,
630               l_oiev_rec.STATUS_CODE,
631               l_oiev_rec.TARGET_CHR_ID,
632               l_oiev_rec.OBJECT_VERSION_NUMBER,
633               l_oiev_rec.CREATED_BY,
634               l_oiev_rec.CREATION_DATE,
635               l_oiev_rec.LAST_UPDATED_BY,
636               l_oiev_rec.LAST_UPDATE_DATE,
637               l_oiev_rec.LAST_UPDATE_LOGIN,
638               l_oiev_rec.JTOT_OBJECT1_CODE,
639               l_oiev_rec.OBJECT1_ID1,
640               l_oiev_rec.OBJECT1_ID2;
641     x_no_data_found := oiev_pk_csr%NOTFOUND;
642     CLOSE oiev_pk_csr;
643 
644 IF (l_debug = 'Y') THEN
645    okc_debug.log('2750: Leaving  Fn  Get_Rec ', 2);
646    okc_debug.Reset_Indentation;
647 END IF;
648 
649     RETURN(l_oiev_rec);
650 
651   END get_rec;
652 
653   FUNCTION get_rec (
654     p_oiev_rec                      IN oiev_rec_type
655   ) RETURN oiev_rec_type IS
656     l_row_notfound                 BOOLEAN := TRUE;
657   BEGIN
658 
659     RETURN(get_rec(p_oiev_rec, l_row_notfound));
660 
661   END get_rec;
662 
663   ---------------------------------------------------------------
664   -- FUNCTION null_out_defaults for: OKC_OPERATION_INSTANCES_V --
665   ---------------------------------------------------------------
666   FUNCTION null_out_defaults (
667     p_oiev_rec	IN oiev_rec_type
668   ) RETURN oiev_rec_type IS
669     l_oiev_rec	oiev_rec_type := p_oiev_rec;
670   BEGIN
671 
672     IF (l_debug = 'Y') THEN
673        okc_debug.Set_Indentation('OKC_OIE_PVT');
674        okc_debug.log('2900: Entered null_out_defaults', 2);
675     END IF;
676 
677     IF (l_oiev_rec.name = OKC_API.G_MISS_CHAR) THEN
678       l_oiev_rec.name := NULL;
679     END IF;
680     IF (l_oiev_rec.cop_id = OKC_API.G_MISS_NUM) THEN
681       l_oiev_rec.cop_id := NULL;
682     END IF;
683     IF (l_oiev_rec.status_code = OKC_API.G_MISS_CHAR) THEN
684       l_oiev_rec.status_code := NULL;
685     END IF;
686     IF (l_oiev_rec.target_chr_id = OKC_API.G_MISS_NUM) THEN
687       l_oiev_rec.target_chr_id := NULL;
688     END IF;
689     IF (l_oiev_rec.object_version_number = OKC_API.G_MISS_NUM) THEN
690       l_oiev_rec.object_version_number := NULL;
691     END IF;
692     IF (l_oiev_rec.created_by = OKC_API.G_MISS_NUM) THEN
693       l_oiev_rec.created_by := NULL;
694     END IF;
695     IF (l_oiev_rec.creation_date = OKC_API.G_MISS_DATE) THEN
696       l_oiev_rec.creation_date := NULL;
697     END IF;
698     IF (l_oiev_rec.last_updated_by = OKC_API.G_MISS_NUM) THEN
699       l_oiev_rec.last_updated_by := NULL;
700     END IF;
701     IF (l_oiev_rec.last_update_date = OKC_API.G_MISS_DATE) THEN
702       l_oiev_rec.last_update_date := NULL;
703     END IF;
704     IF (l_oiev_rec.last_update_login = OKC_API.G_MISS_NUM) THEN
705       l_oiev_rec.last_update_login := NULL;
706     END IF;
707     IF (l_oiev_rec.jtot_object1_code = OKC_API.G_MISS_CHAR) THEN
708       l_oiev_rec.jtot_object1_code := NULL;
709     END IF;
710     IF (l_oiev_rec.object1_id1 = OKC_API.G_MISS_CHAR) THEN
711       l_oiev_rec.object1_id1 := NULL;
712     END IF;
713     IF (l_oiev_rec.object1_id2 = OKC_API.G_MISS_CHAR) THEN
714       l_oiev_rec.object1_id2 := NULL;
715     END IF;
716 
717 IF (l_debug = 'Y') THEN
718    okc_debug.log('500: Leaving  null_out_defaults ', 2);
719    okc_debug.Reset_Indentation;
720 END IF;
721 
722     RETURN(l_oiev_rec);
723 
724   END null_out_defaults;
725   ---------------------------------------------------------------------------
726   -- PROCEDURE Validate_Attributes
727   ---------------------------------------------------------------------------
728   -------------------------------------------------------
729   -- Validate_Attributes for:OKC_OPERATION_INSTANCES_V --
730   -------------------------------------------------------
731   FUNCTION Validate_Attributes (
732     p_oiev_rec IN  oiev_rec_type
733   ) RETURN VARCHAR2 IS
734     l_return_status	VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
735     x_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
736   BEGIN
737 
738     IF (l_debug = 'Y') THEN
739        okc_debug.Set_Indentation('OKC_OIE_PVT');
740        okc_debug.log('3000: Entered Validate_Attributes', 2);
741     END IF;
742 
743     /************************ HAND-CODED *********************************/
744 	  validate_cop_id(x_return_status => l_return_status,
745 				   p_oiev_rec      => p_oiev_rec);
746 
747 	    -- store the highest degree of error
748 	    If l_return_status <> OKC_API.G_RET_STS_SUCCESS Then
749 		  If x_return_status <> OKC_API.G_RET_STS_UNEXP_ERROR Then
750 			x_return_status := l_return_status;
751 		  End If;
752 	    End If;
753 
754 	  validate_target_chr_id(x_return_status => l_return_status,
755 				          p_oiev_rec      => p_oiev_rec);
756 
757 	    -- store the highest degree of error
758 	    If l_return_status <> OKC_API.G_RET_STS_SUCCESS Then
759 		  If x_return_status <> OKC_API.G_RET_STS_UNEXP_ERROR Then
760 			x_return_status := l_return_status;
761 		  End If;
762 	    End If;
763 
764 	  validate_status_code(x_return_status => l_return_status,
765 				        p_oiev_rec      => p_oiev_rec);
766 
767 	    -- store the highest degree of error
768 	    If l_return_status <> OKC_API.G_RET_STS_SUCCESS Then
769 		  If x_return_status <> OKC_API.G_RET_STS_UNEXP_ERROR Then
770 			x_return_status := l_return_status;
771 		  End If;
772 	    End If;
773 
774 	  validate_jtot_object1_code(x_return_status => l_return_status,
775 				        p_oiev_rec      => p_oiev_rec);
776 
777 	    -- store the highest degree of error
778 	    If l_return_status <> OKC_API.G_RET_STS_SUCCESS Then
779 		  If x_return_status <> OKC_API.G_RET_STS_UNEXP_ERROR Then
780 			x_return_status := l_return_status;
781 		  End If;
782 	    End If;
783 
784 	  validate_object1_id1(x_return_status => l_return_status,
785 				        p_oiev_rec      => p_oiev_rec);
786 
787 	    -- store the highest degree of error
788 	    If l_return_status <> OKC_API.G_RET_STS_SUCCESS Then
789 		  If x_return_status <> OKC_API.G_RET_STS_UNEXP_ERROR Then
790 			x_return_status := l_return_status;
791 		  End If;
792 	    End If;
793 
794     IF (l_debug = 'Y') THEN
795        okc_debug.log('3100: Exiting Validate_Attributes', 2);
796        okc_debug.Reset_Indentation;
797     END IF;
798 
799     RETURN(x_return_status);
800 
801   EXCEPTION
802     when OTHERS then
803 
804     IF (l_debug = 'Y') THEN
805        okc_debug.log('3200: Exiting Validate_Attributes:OTHERS Exception', 2);
806        okc_debug.Reset_Indentation;
807     END IF;
808 
809        -- store SQL error message on message stack
810        OKC_API.SET_MESSAGE(p_app_name        => g_app_name,
811                            p_msg_name        => g_unexpected_error,
812                            p_token1          => g_sqlcode_token,
813                            p_token1_value    => sqlcode,
814                            p_token2          => g_sqlerrm_token,
815                            p_token2_value    => sqlerrm);
816 
817         -- notify caller of an UNEXPETED error
818         x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
819 
820         -- return status to caller
821         RETURN(x_return_status);
822     /*********************** END HAND-CODED ********************************/
823 
824   END Validate_Attributes;
825 
826   ---------------------------------------------------------------------------
827   -- PROCEDURE Validate_Record
828   ---------------------------------------------------------------------------
829   ---------------------------------------------------
830   -- Validate_Record for:OKC_OPERATION_INSTANCES_V --
831   ---------------------------------------------------
832   FUNCTION Validate_Record (
833     p_oiev_rec IN oiev_rec_type
834   ) RETURN VARCHAR2 IS
835     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
836   BEGIN
837 
838     RETURN (l_return_status);
839 
840   END Validate_Record;
841 
842   ---------------------------------------------------------------------------
843   -- PROCEDURE Migrate
844   ---------------------------------------------------------------------------
845   PROCEDURE migrate (
846     p_from	IN oiev_rec_type,
847     p_to	IN OUT NOCOPY oie_rec_type
848   ) IS
849   BEGIN
850 
851     p_to.id := p_from.id;
852     p_to.cop_id := p_from.cop_id;
853     p_to.status_code := p_from.status_code;
854     p_to.object_version_number := p_from.object_version_number;
855     p_to.created_by := p_from.created_by;
856     p_to.creation_date := p_from.creation_date;
857     p_to.last_updated_by := p_from.last_updated_by;
858     p_to.last_update_date := p_from.last_update_date;
859     p_to.last_update_login := p_from.last_update_login;
860     p_to.name := p_from.name;
861     p_to.target_chr_id := p_from.target_chr_id;
862     p_to.jtot_object1_code := p_from.jtot_object1_code;
863     p_to.object1_id1       := p_from.object1_id1;
864     p_to.object1_id2       := p_from.object1_id2;
865 
866   END migrate;
867 
868   PROCEDURE migrate (
869     p_from	IN oie_rec_type,
870     p_to	IN OUT NOCOPY oiev_rec_type
871   ) IS
872   BEGIN
873 
874     p_to.id := p_from.id;
875     p_to.cop_id := p_from.cop_id;
876     p_to.status_code := p_from.status_code;
877     p_to.object_version_number := p_from.object_version_number;
878     p_to.created_by := p_from.created_by;
879     p_to.creation_date := p_from.creation_date;
880     p_to.last_updated_by := p_from.last_updated_by;
881     p_to.last_update_date := p_from.last_update_date;
882     p_to.last_update_login := p_from.last_update_login;
883     p_to.name := p_from.name;
884     p_to.target_chr_id := p_from.target_chr_id;
885     p_to.jtot_object1_code := p_from.jtot_object1_code;
886     p_to.object1_id1       := p_from.object1_id1;
887     p_to.object1_id2       := p_from.object1_id2;
888 
889   END migrate;
890 
891   ---------------------------------------------------------------------------
892   -- PROCEDURE validate_row
893   ---------------------------------------------------------------------------
894   ------------------------------------------------
895   -- validate_row for:OKC_OPERATION_INSTANCES_V --
896   ------------------------------------------------
897   PROCEDURE validate_row(
898     p_api_version                  IN NUMBER,
899     p_init_msg_list                IN VARCHAR2 ,
900     x_return_status                OUT NOCOPY VARCHAR2,
901     x_msg_count                    OUT NOCOPY NUMBER,
902     x_msg_data                     OUT NOCOPY VARCHAR2,
903     p_oiev_rec                      IN oiev_rec_type) IS
904 
905     l_api_version                 CONSTANT NUMBER := 1;
906     l_api_name                     CONSTANT VARCHAR2(30) := 'V_validate_row';
907     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
908     l_oiev_rec                      oiev_rec_type := p_oiev_rec;
909     l_oie_rec                      oie_rec_type;
910   BEGIN
911 
912     IF (l_debug = 'Y') THEN
913        okc_debug.Set_Indentation('OKC_OIE_PVT');
914        okc_debug.log('3600: Entered validate_row', 2);
915     END IF;
916 
917     l_return_status := OKC_API.START_ACTIVITY(l_api_name,
918                                               G_PKG_NAME,
919                                               p_init_msg_list,
920                                               l_api_version,
921                                               p_api_version,
922                                               '_PVT',
923                                               x_return_status);
924     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
925       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
926     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
927       RAISE OKC_API.G_EXCEPTION_ERROR;
928     END IF;
929     --- Validate all non-missing attributes (Item Level Validation)
930     l_return_status := Validate_Attributes(l_oiev_rec);
931     --- If any errors happen abort API
932     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
933       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
934     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
935       RAISE OKC_API.G_EXCEPTION_ERROR;
936     END IF;
937     l_return_status := Validate_Record(l_oiev_rec);
938     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
939       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
940     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
941       RAISE OKC_API.G_EXCEPTION_ERROR;
942     END IF;
943     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
944 
945     IF (l_debug = 'Y') THEN
946        okc_debug.log('3700: Exiting validate_row', 2);
947        okc_debug.Reset_Indentation;
948     END IF;
949 
950   EXCEPTION
951     WHEN OKC_API.G_EXCEPTION_ERROR THEN
952 
953     IF (l_debug = 'Y') THEN
954        okc_debug.log('3800: Exiting validate_row:OKC_API.G_EXCEPTION_ERROR Exception', 2);
955        okc_debug.Reset_Indentation;
956     END IF;
957 
958       x_return_status := OKC_API.HANDLE_EXCEPTIONS
959       (
960         l_api_name,
961         G_PKG_NAME,
962         'OKC_API.G_RET_STS_ERROR',
963         x_msg_count,
964         x_msg_data,
965         '_PVT'
966       );
967     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
968 
969     IF (l_debug = 'Y') THEN
970        okc_debug.log('3900: Exiting validate_row:OKC_API.G_EXCEPTION_UNEXPECTED_ERROR Exception', 2);
971        okc_debug.Reset_Indentation;
972     END IF;
973 
974       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
975       (
976         l_api_name,
977         G_PKG_NAME,
978         'OKC_API.G_RET_STS_UNEXP_ERROR',
979         x_msg_count,
980         x_msg_data,
981         '_PVT'
982       );
983     WHEN OTHERS THEN
984 
985     IF (l_debug = 'Y') THEN
986        okc_debug.log('4000: Exiting validate_row:OTHERS Exception', 2);
987        okc_debug.Reset_Indentation;
988     END IF;
989 
990       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
991       (
992         l_api_name,
993         G_PKG_NAME,
994         'OTHERS',
995         x_msg_count,
996         x_msg_data,
997         '_PVT'
998       );
999 
1000   END validate_row;
1001   -----------------------------------------
1002   -- PL/SQL TBL validate_row for:oiev_tbl --
1003   -----------------------------------------
1004   PROCEDURE validate_row(
1005     p_api_version                  IN NUMBER,
1006     p_init_msg_list                IN VARCHAR2 ,
1007     x_return_status                OUT NOCOPY VARCHAR2,
1008     x_msg_count                    OUT NOCOPY NUMBER,
1009     x_msg_data                     OUT NOCOPY VARCHAR2,
1010     p_oiev_tbl                      IN oiev_tbl_type) IS
1011 
1012     l_api_version                 CONSTANT NUMBER := 1;
1013     l_api_name                     CONSTANT VARCHAR2(30) := 'V_tbl_validate_row';
1014     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1015     l_overall_status               VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1016     i                              NUMBER := 0;
1017   BEGIN
1018 
1019     IF (l_debug = 'Y') THEN
1020        okc_debug.Set_Indentation('OKC_OIE_PVT');
1021        okc_debug.log('4100: Entered validate_row', 2);
1022     END IF;
1023 
1024     OKC_API.init_msg_list(p_init_msg_list);
1025     -- Make sure PL/SQL table has records in it before passing
1026     IF (p_oiev_tbl.COUNT > 0) THEN
1027       i := p_oiev_tbl.FIRST;
1028       LOOP
1029         validate_row (
1030           p_api_version                  => p_api_version,
1031           p_init_msg_list                => OKC_API.G_FALSE,
1032           x_return_status                => x_return_status,
1033           x_msg_count                    => x_msg_count,
1034           x_msg_data                     => x_msg_data,
1035           p_oiev_rec                      => p_oiev_tbl(i));
1036 
1037           -- store the highest degree of error
1038           If x_return_status <> OKC_API.G_RET_STS_SUCCESS Then
1039              If l_overall_status <> OKC_API.G_RET_STS_UNEXP_ERROR Then
1040                 l_overall_status := x_return_status;
1041              End If;
1042           End If;
1043 
1044 
1045         i := p_oiev_tbl.NEXT(i);
1046       END LOOP;
1047       -- return overall status
1048       x_return_status := l_overall_status;
1049     END IF;
1050 
1051     IF (l_debug = 'Y') THEN
1052        okc_debug.log('4200: Exiting validate_row', 2);
1053        okc_debug.Reset_Indentation;
1054     END IF;
1055 
1056   EXCEPTION
1057     WHEN OKC_API.G_EXCEPTION_ERROR THEN
1058 
1059     IF (l_debug = 'Y') THEN
1060        okc_debug.log('4300: Exiting validate_row:OKC_API.G_EXCEPTION_ERROR Exception', 2);
1061        okc_debug.Reset_Indentation;
1062     END IF;
1063 
1064       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1065       (
1066         l_api_name,
1067         G_PKG_NAME,
1068         'OKC_API.G_RET_STS_ERROR',
1069         x_msg_count,
1070         x_msg_data,
1071         '_PVT'
1072       );
1073     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1074 
1075     IF (l_debug = 'Y') THEN
1076        okc_debug.log('4400: Exiting validate_row:OKC_API.G_EXCEPTION_UNEXPECTED_ERROR Exception', 2);
1077        okc_debug.Reset_Indentation;
1078     END IF;
1079 
1080       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1081       (
1082         l_api_name,
1083         G_PKG_NAME,
1084         'OKC_API.G_RET_STS_UNEXP_ERROR',
1085         x_msg_count,
1086         x_msg_data,
1087         '_PVT'
1088       );
1089     WHEN OTHERS THEN
1090 
1091     IF (l_debug = 'Y') THEN
1092        okc_debug.log('4500: Exiting validate_row:OTHERS Exception', 2);
1093        okc_debug.Reset_Indentation;
1094     END IF;
1095 
1096       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1097       (
1098         l_api_name,
1099         G_PKG_NAME,
1100         'OTHERS',
1101         x_msg_count,
1102         x_msg_data,
1103         '_PVT'
1104       );
1105 
1106   END validate_row;
1107 
1108   ---------------------------------------------------------------------------
1109   -- PROCEDURE insert_row
1110   ---------------------------------------------------------------------------
1111   --------------------------------------------
1112   -- insert_row for:OKC_OPERATION_INSTANCES --
1113   --------------------------------------------
1114   PROCEDURE insert_row(
1115     p_init_msg_list                IN VARCHAR2 ,
1116     x_return_status                OUT NOCOPY VARCHAR2,
1117     x_msg_count                    OUT NOCOPY NUMBER,
1118     x_msg_data                     OUT NOCOPY VARCHAR2,
1119     p_oie_rec                      IN oie_rec_type,
1120     x_oie_rec                      OUT NOCOPY oie_rec_type) IS
1121 
1122     l_api_version                 CONSTANT NUMBER := 1;
1123     l_api_name                     CONSTANT VARCHAR2(30) := 'INSTANCES_insert_row';
1124     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1125     l_oie_rec                      oie_rec_type := p_oie_rec;
1126     l_def_oie_rec                  oie_rec_type;
1127     ------------------------------------------------
1128     -- Set_Attributes for:OKC_OPERATION_INSTANCES --
1129     ------------------------------------------------
1130     FUNCTION Set_Attributes (
1131       p_oie_rec IN  oie_rec_type,
1132       x_oie_rec OUT NOCOPY oie_rec_type
1133     ) RETURN VARCHAR2 IS
1134       l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1135     BEGIN
1136 
1137       x_oie_rec := p_oie_rec;
1138       RETURN(l_return_status);
1139 
1140     END Set_Attributes;
1141   BEGIN
1142 
1143     IF (l_debug = 'Y') THEN
1144        okc_debug.Set_Indentation('OKC_OIE_PVT');
1145        okc_debug.log('4700: Entered insert_row', 2);
1146     END IF;
1147 
1148     l_return_status := OKC_API.START_ACTIVITY(l_api_name,
1149                                               p_init_msg_list,
1150                                               '_PVT',
1151                                               x_return_status);
1152     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1153       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1154     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1155       RAISE OKC_API.G_EXCEPTION_ERROR;
1156     END IF;
1157     --- Setting item attributes
1158     l_return_status := Set_Attributes(
1159       p_oie_rec,                         -- IN
1160       l_oie_rec);                        -- OUT
1161     --- If any errors happen abort API
1162     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1163       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1164     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1165       RAISE OKC_API.G_EXCEPTION_ERROR;
1166     END IF;
1167     INSERT INTO OKC_OPERATION_INSTANCES(
1168         id,
1169         cop_id,
1170         status_code,
1171         object_version_number,
1172         created_by,
1173         creation_date,
1174         last_updated_by,
1175         last_update_date,
1176         last_update_login,
1177         name,
1178         target_chr_id,
1179 	   request_id,
1180 	   program_application_id,
1181 	   program_id,
1182 	   program_update_date,
1183            jtot_object1_code,
1184            object1_id1,
1185            object1_id2,
1186 -- R12 Data Model Changes 4485150 Start
1187            batch_id
1188 -- R12 Data Model Changes 4485150 End
1189 )
1190       VALUES (
1191         l_oie_rec.id,
1192         l_oie_rec.cop_id,
1193         l_oie_rec.status_code,
1194         l_oie_rec.object_version_number,
1195         l_oie_rec.created_by,
1196         l_oie_rec.creation_date,
1197         l_oie_rec.last_updated_by,
1198         l_oie_rec.last_update_date,
1199         l_oie_rec.last_update_login,
1200         l_oie_rec.name,
1201         l_oie_rec.target_chr_id,
1202         decode(FND_GLOBAL.CONC_REQUEST_ID,-1,NULL,FND_GLOBAL.CONC_REQUEST_ID),
1203         decode(FND_GLOBAL.PROG_APPL_ID,-1,NULL,FND_GLOBAL.PROG_APPL_ID),
1204         decode(FND_GLOBAL.CONC_PROGRAM_ID,-1,NULL,FND_GLOBAL.CONC_PROGRAM_ID),
1205         decode(FND_GLOBAL.CONC_REQUEST_ID,-1,NULL,SYSDATE),
1206         l_oie_rec.jtot_object1_code,
1207         l_oie_rec.object1_id1,
1208         l_oie_rec.object1_id2,
1209 -- R12 Data Model Changes 4485150 Start
1210         l_oie_rec.batch_id
1211 -- R12 Data Model Changes 4485150 End
1212 );
1213 
1214     -- Set OUT values
1215     x_oie_rec := l_oie_rec;
1216     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
1217 
1218     IF (l_debug = 'Y') THEN
1219        okc_debug.log('4800: Exiting insert_row', 2);
1220        okc_debug.Reset_Indentation;
1221     END IF;
1222 
1223   EXCEPTION
1224     WHEN OKC_API.G_EXCEPTION_ERROR THEN
1225 
1226     IF (l_debug = 'Y') THEN
1227        okc_debug.log('4900: Exiting insert_row:OKC_API.G_EXCEPTION_ERROR Exception', 2);
1228        okc_debug.Reset_Indentation;
1229     END IF;
1230 
1231       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1232       (
1233         l_api_name,
1234         G_PKG_NAME,
1235         'OKC_API.G_RET_STS_ERROR',
1236         x_msg_count,
1237         x_msg_data,
1238         '_PVT'
1239       );
1240     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1241 
1242     IF (l_debug = 'Y') THEN
1243        okc_debug.log('5000: Exiting insert_row:OKC_API.G_EXCEPTION_UNEXPECTED_ERROR Exception', 2);
1244        okc_debug.Reset_Indentation;
1245     END IF;
1246 
1247       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1248       (
1249         l_api_name,
1250         G_PKG_NAME,
1251         'OKC_API.G_RET_STS_UNEXP_ERROR',
1252         x_msg_count,
1253         x_msg_data,
1254         '_PVT'
1255       );
1256     WHEN OTHERS THEN
1257 
1258     IF (l_debug = 'Y') THEN
1259        okc_debug.log('5100: Exiting insert_row:OTHERS Exception', 2);
1260        okc_debug.Reset_Indentation;
1261     END IF;
1262 
1263       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1264       (
1265         l_api_name,
1266         G_PKG_NAME,
1267         'OTHERS',
1268         x_msg_count,
1269         x_msg_data,
1270         '_PVT'
1271       );
1272 
1273   END insert_row;
1274   ----------------------------------------------
1275   -- insert_row for:OKC_OPERATION_INSTANCES_V --
1276   ----------------------------------------------
1277   PROCEDURE insert_row(
1278     p_api_version                  IN NUMBER,
1279     p_init_msg_list                IN VARCHAR2 ,
1280     x_return_status                OUT NOCOPY VARCHAR2,
1281     x_msg_count                    OUT NOCOPY NUMBER,
1282     x_msg_data                     OUT NOCOPY VARCHAR2,
1283     p_oiev_rec                      IN oiev_rec_type,
1284     x_oiev_rec                      OUT NOCOPY oiev_rec_type) IS
1285 
1286     l_api_version                 CONSTANT NUMBER := 1;
1287     l_api_name                     CONSTANT VARCHAR2(30) := 'V_insert_row';
1288     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1289     l_oiev_rec                      oiev_rec_type;
1290     l_def_oiev_rec                  oiev_rec_type;
1291     l_oie_rec                      oie_rec_type;
1292     lx_oie_rec                     oie_rec_type;
1293     -------------------------------
1294     -- FUNCTION fill_who_columns --
1295     -------------------------------
1296     FUNCTION fill_who_columns (
1297       p_oiev_rec	IN oiev_rec_type
1298     ) RETURN oiev_rec_type IS
1299       l_oiev_rec	oiev_rec_type := p_oiev_rec;
1300     BEGIN
1301 
1302       l_oiev_rec.CREATION_DATE := SYSDATE;
1303       l_oiev_rec.CREATED_BY := FND_GLOBAL.USER_ID;
1304       l_oiev_rec.LAST_UPDATE_DATE := l_oiev_rec.CREATION_DATE;
1305       l_oiev_rec.LAST_UPDATED_BY := FND_GLOBAL.USER_ID;
1306       l_oiev_rec.LAST_UPDATE_LOGIN := FND_GLOBAL.LOGIN_ID;
1307 
1308       RETURN(l_oiev_rec);
1309 
1310     END fill_who_columns;
1311     --------------------------------------------------
1312     -- Set_Attributes for:OKC_OPERATION_INSTANCES_V --
1313     --------------------------------------------------
1314     FUNCTION Set_Attributes (
1315       p_oiev_rec IN  oiev_rec_type,
1316       x_oiev_rec OUT NOCOPY oiev_rec_type
1317     ) RETURN VARCHAR2 IS
1318       l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1319     BEGIN
1320 
1321       x_oiev_rec := p_oiev_rec;
1322       x_oiev_rec.OBJECT_VERSION_NUMBER := 1;
1323       RETURN(l_return_status);
1324 
1325     END Set_Attributes;
1326   BEGIN
1327 
1328     IF (l_debug = 'Y') THEN
1329        okc_debug.Set_Indentation('OKC_OIE_PVT');
1330        okc_debug.log('5400: Entered insert_row', 2);
1331     END IF;
1332 
1333     l_return_status := OKC_API.START_ACTIVITY(l_api_name,
1334                                               G_PKG_NAME,
1335                                               p_init_msg_list,
1336                                               l_api_version,
1337                                               p_api_version,
1338                                               '_PVT',
1339                                               x_return_status);
1340     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1341       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1342     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1343       RAISE OKC_API.G_EXCEPTION_ERROR;
1344     END IF;
1345     l_oiev_rec := null_out_defaults(p_oiev_rec);
1346     -- Set primary key value
1347     l_oiev_rec.ID := get_seq_id;
1348     --- Setting item attributes
1349     l_return_status := Set_Attributes(
1350       l_oiev_rec,                         -- IN
1351       l_def_oiev_rec);                    -- OUT
1352     --- If any errors happen abort API
1353     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1354       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1355     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1356       RAISE OKC_API.G_EXCEPTION_ERROR;
1357     END IF;
1358     l_def_oiev_rec := fill_who_columns(l_def_oiev_rec);
1359     --- Validate all non-missing attributes (Item Level Validation)
1360     l_return_status := Validate_Attributes(l_def_oiev_rec);
1361     --- If any errors happen abort API
1362     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1363       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1364     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1365       RAISE OKC_API.G_EXCEPTION_ERROR;
1366     END IF;
1367     l_return_status := Validate_Record(l_def_oiev_rec);
1368     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1369       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1370     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1371       RAISE OKC_API.G_EXCEPTION_ERROR;
1372     END IF;
1373     --------------------------------------
1374     -- Move VIEW record to "Child" records
1375     --------------------------------------
1376     migrate(l_def_oiev_rec, l_oie_rec);
1377     --------------------------------------------
1378     -- Call the INSERT_ROW for each child record
1379     --------------------------------------------
1380     insert_row(
1381       p_init_msg_list,
1382       x_return_status,
1383       x_msg_count,
1384       x_msg_data,
1385       l_oie_rec,
1386       lx_oie_rec
1387     );
1388     IF (x_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1389       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1390     ELSIF (x_return_status = OKC_API.G_RET_STS_ERROR) THEN
1391       RAISE OKC_API.G_EXCEPTION_ERROR;
1392     END IF;
1393     migrate(lx_oie_rec, l_def_oiev_rec);
1394     -- Set OUT values
1395     x_oiev_rec := l_def_oiev_rec;
1396     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
1397 
1398     IF (l_debug = 'Y') THEN
1399        okc_debug.log('5500: Exiting insert_row', 2);
1400        okc_debug.Reset_Indentation;
1401     END IF;
1402 
1403   EXCEPTION
1404     WHEN OKC_API.G_EXCEPTION_ERROR THEN
1405 
1406     IF (l_debug = 'Y') THEN
1407        okc_debug.log('5600: Exiting insert_row:OKC_API.G_EXCEPTION_ERROR Exception', 2);
1408        okc_debug.Reset_Indentation;
1409     END IF;
1410 
1411       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1412       (
1413         l_api_name,
1414         G_PKG_NAME,
1415         'OKC_API.G_RET_STS_ERROR',
1416         x_msg_count,
1417         x_msg_data,
1418         '_PVT'
1419       );
1420     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1421 
1422     IF (l_debug = 'Y') THEN
1423        okc_debug.log('5700: Exiting insert_row:OKC_API.G_EXCEPTION_UNEXPECTED_ERROR Exception', 2);
1424        okc_debug.Reset_Indentation;
1425     END IF;
1426 
1427       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1428       (
1429         l_api_name,
1430         G_PKG_NAME,
1431         'OKC_API.G_RET_STS_UNEXP_ERROR',
1432         x_msg_count,
1433         x_msg_data,
1434         '_PVT'
1435       );
1436     WHEN OTHERS THEN
1437 
1438     IF (l_debug = 'Y') THEN
1439        okc_debug.log('5800: Exiting insert_row:OTHERS Exception', 2);
1440        okc_debug.Reset_Indentation;
1441     END IF;
1442 
1443       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1444       (
1445         l_api_name,
1446         G_PKG_NAME,
1447         'OTHERS',
1448         x_msg_count,
1449         x_msg_data,
1450         '_PVT'
1451       );
1452 
1453   END insert_row;
1454   ---------------------------------------
1455   -- PL/SQL TBL insert_row for:oiev_tbl --
1456   ---------------------------------------
1457   PROCEDURE insert_row(
1458     p_api_version                  IN NUMBER,
1459     p_init_msg_list                IN VARCHAR2 ,
1460     x_return_status                OUT NOCOPY VARCHAR2,
1461     x_msg_count                    OUT NOCOPY NUMBER,
1462     x_msg_data                     OUT NOCOPY VARCHAR2,
1463     p_oiev_tbl                      IN oiev_tbl_type,
1464     x_oiev_tbl                      OUT NOCOPY oiev_tbl_type) IS
1465 
1466     l_api_version                 CONSTANT NUMBER := 1;
1467     l_api_name                     CONSTANT VARCHAR2(30) := 'V_tbl_insert_row';
1468     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1469     l_overall_status               VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1470     i                              NUMBER := 0;
1471   BEGIN
1472 
1473     IF (l_debug = 'Y') THEN
1474        okc_debug.Set_Indentation('OKC_OIE_PVT');
1475        okc_debug.log('5900: Entered insert_row', 2);
1476     END IF;
1477 
1478     OKC_API.init_msg_list(p_init_msg_list);
1479     -- Make sure PL/SQL table has records in it before passing
1480     IF (p_oiev_tbl.COUNT > 0) THEN
1481       i := p_oiev_tbl.FIRST;
1482       LOOP
1483         insert_row (
1484           p_api_version                  => p_api_version,
1485           p_init_msg_list                => OKC_API.G_FALSE,
1486           x_return_status                => x_return_status,
1487           x_msg_count                    => x_msg_count,
1488           x_msg_data                     => x_msg_data,
1489           p_oiev_rec                      => p_oiev_tbl(i),
1490           x_oiev_rec                      => x_oiev_tbl(i));
1491 
1492           -- store the highest degree of error
1493           If x_return_status <> OKC_API.G_RET_STS_SUCCESS Then
1494              If l_overall_status <> OKC_API.G_RET_STS_UNEXP_ERROR Then
1495                 l_overall_status := x_return_status;
1496              End If;
1497           End If;
1498 
1499         EXIT WHEN (i = p_oiev_tbl.LAST);
1500         i := p_oiev_tbl.NEXT(i);
1501       END LOOP;
1502       -- return overall status
1503       x_return_status := l_overall_status;
1504     END IF;
1505 
1506     IF (l_debug = 'Y') THEN
1507        okc_debug.log('6000: Exiting insert_row', 2);
1508        okc_debug.Reset_Indentation;
1509     END IF;
1510 
1511   EXCEPTION
1512     WHEN OKC_API.G_EXCEPTION_ERROR THEN
1513 
1514     IF (l_debug = 'Y') THEN
1515        okc_debug.log('6100: Exiting insert_row:OKC_API.G_EXCEPTION_ERROR Exception', 2);
1516        okc_debug.Reset_Indentation;
1517     END IF;
1518 
1519       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1520       (
1521         l_api_name,
1522         G_PKG_NAME,
1523         'OKC_API.G_RET_STS_ERROR',
1524         x_msg_count,
1525         x_msg_data,
1526         '_PVT'
1527       );
1528     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1529 
1530     IF (l_debug = 'Y') THEN
1531        okc_debug.log('6200: Exiting insert_row:OKC_API.G_EXCEPTION_UNEXPECTED_ERROR Exception', 2);
1532        okc_debug.Reset_Indentation;
1533     END IF;
1534 
1535       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1536       (
1537         l_api_name,
1538         G_PKG_NAME,
1539         'OKC_API.G_RET_STS_UNEXP_ERROR',
1540         x_msg_count,
1541         x_msg_data,
1542         '_PVT'
1543       );
1544     WHEN OTHERS THEN
1545 
1546     IF (l_debug = 'Y') THEN
1547        okc_debug.log('6300: Exiting insert_row:OTHERS Exception', 2);
1548        okc_debug.Reset_Indentation;
1549     END IF;
1550 
1551       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1552       (
1553         l_api_name,
1554         G_PKG_NAME,
1555         'OTHERS',
1556         x_msg_count,
1557         x_msg_data,
1558         '_PVT'
1559       );
1560 
1561   END insert_row;
1562 
1563   ---------------------------------------------------------------------------
1564   -- PROCEDURE lock_row
1565   ---------------------------------------------------------------------------
1566   ------------------------------------------
1567   -- lock_row for:OKC_OPERATION_INSTANCES --
1568   ------------------------------------------
1569   PROCEDURE lock_row(
1570     p_init_msg_list                IN VARCHAR2 ,
1571     x_return_status                OUT NOCOPY VARCHAR2,
1572     x_msg_count                    OUT NOCOPY NUMBER,
1573     x_msg_data                     OUT NOCOPY VARCHAR2,
1574     p_oie_rec                      IN oie_rec_type) IS
1575 
1576     E_Resource_Busy               EXCEPTION;
1577     PRAGMA EXCEPTION_INIT(E_Resource_Busy, -00054);
1578     CURSOR lock_csr (p_oie_rec IN oie_rec_type) IS
1579     SELECT OBJECT_VERSION_NUMBER
1580       FROM OKC_OPERATION_INSTANCES
1581      WHERE ID = p_oie_rec.id
1582        AND OBJECT_VERSION_NUMBER = p_oie_rec.object_version_number
1583     FOR UPDATE OF OBJECT_VERSION_NUMBER NOWAIT;
1584 
1585     CURSOR  lchk_csr (p_oie_rec IN oie_rec_type) IS
1586     SELECT OBJECT_VERSION_NUMBER
1587       FROM OKC_OPERATION_INSTANCES
1588     WHERE ID = p_oie_rec.id;
1589     l_api_version                 CONSTANT NUMBER := 1;
1590     l_api_name                     CONSTANT VARCHAR2(30) := 'INSTANCES_lock_row';
1591     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1592     l_object_version_number       OKC_OPERATION_INSTANCES.OBJECT_VERSION_NUMBER%TYPE;
1593     lc_object_version_number      OKC_OPERATION_INSTANCES.OBJECT_VERSION_NUMBER%TYPE;
1594     l_row_notfound                BOOLEAN := FALSE;
1595     lc_row_notfound               BOOLEAN := FALSE;
1596   BEGIN
1597 
1598     IF (l_debug = 'Y') THEN
1599        okc_debug.Set_Indentation('OKC_OIE_PVT');
1600        okc_debug.log('6400: Entered lock_row', 2);
1601     END IF;
1602 
1603     l_return_status := OKC_API.START_ACTIVITY(l_api_name,
1604                                               p_init_msg_list,
1605                                               '_PVT',
1606                                               x_return_status);
1607     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1608       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1609     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1610       RAISE OKC_API.G_EXCEPTION_ERROR;
1611     END IF;
1612     BEGIN
1613 
1614       OPEN lock_csr(p_oie_rec);
1615       FETCH lock_csr INTO l_object_version_number;
1616       l_row_notfound := lock_csr%NOTFOUND;
1617       CLOSE lock_csr;
1618 
1619     EXCEPTION
1620       WHEN E_Resource_Busy THEN
1621 
1622     IF (l_debug = 'Y') THEN
1623        okc_debug.log('6700: Exiting lock_row:E_Resource_Busy Exception', 2);
1624        okc_debug.Reset_Indentation;
1625     END IF;
1626 
1627         IF (lock_csr%ISOPEN) THEN
1628           CLOSE lock_csr;
1629         END IF;
1630         OKC_API.set_message(G_FND_APP,G_FORM_UNABLE_TO_RESERVE_REC);
1631         RAISE APP_EXCEPTIONS.RECORD_LOCK_EXCEPTION;
1632     END;
1633 
1634     IF ( l_row_notfound ) THEN
1635       OPEN lchk_csr(p_oie_rec);
1636       FETCH lchk_csr INTO lc_object_version_number;
1637       lc_row_notfound := lchk_csr%NOTFOUND;
1638       CLOSE lchk_csr;
1639     END IF;
1640     IF (lc_row_notfound) THEN
1641       OKC_API.set_message(G_FND_APP,G_FORM_RECORD_DELETED);
1642       RAISE OKC_API.G_EXCEPTION_ERROR;
1643     ELSIF lc_object_version_number > p_oie_rec.object_version_number THEN
1644       OKC_API.set_message(G_FND_APP,G_FORM_RECORD_CHANGED);
1645       RAISE OKC_API.G_EXCEPTION_ERROR;
1646     ELSIF lc_object_version_number <> p_oie_rec.object_version_number THEN
1647       OKC_API.set_message(G_FND_APP,G_FORM_RECORD_CHANGED);
1648       RAISE OKC_API.G_EXCEPTION_ERROR;
1649     ELSIF lc_object_version_number = -1 THEN
1650       OKC_API.set_message(G_APP_NAME,G_RECORD_LOGICALLY_DELETED);
1651       RAISE OKC_API.G_EXCEPTION_ERROR;
1652     END IF;
1653     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
1654 
1655     IF (l_debug = 'Y') THEN
1656        okc_debug.log('6800: Exiting lock_row', 2);
1657        okc_debug.Reset_Indentation;
1658     END IF;
1659 
1660   EXCEPTION
1661     WHEN OKC_API.G_EXCEPTION_ERROR THEN
1662 
1663     IF (l_debug = 'Y') THEN
1664        okc_debug.log('6900: Exiting lock_row:OKC_API.G_EXCEPTION_ERROR Exception', 2);
1665        okc_debug.Reset_Indentation;
1666     END IF;
1667 
1668       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1669       (
1670         l_api_name,
1671         G_PKG_NAME,
1672         'OKC_API.G_RET_STS_ERROR',
1673         x_msg_count,
1674         x_msg_data,
1675         '_PVT'
1676       );
1677     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1678 
1679     IF (l_debug = 'Y') THEN
1680        okc_debug.log('7000: Exiting lock_row:OKC_API.G_EXCEPTION_UNEXPECTED_ERROR Exception', 2);
1681        okc_debug.Reset_Indentation;
1682     END IF;
1683 
1684       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1685       (
1686         l_api_name,
1687         G_PKG_NAME,
1688         'OKC_API.G_RET_STS_UNEXP_ERROR',
1689         x_msg_count,
1690         x_msg_data,
1691         '_PVT'
1692       );
1693     WHEN OTHERS THEN
1694 
1695     IF (l_debug = 'Y') THEN
1696        okc_debug.log('7100: Exiting lock_row:OTHERS Exception', 2);
1697        okc_debug.Reset_Indentation;
1698     END IF;
1699 
1700       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1701       (
1702         l_api_name,
1703         G_PKG_NAME,
1704         'OTHERS',
1705         x_msg_count,
1706         x_msg_data,
1707         '_PVT'
1708       );
1709 
1710   END lock_row;
1711   --------------------------------------------
1712   -- lock_row for:OKC_OPERATION_INSTANCES_V --
1713   --------------------------------------------
1714   PROCEDURE lock_row(
1715     p_api_version                  IN NUMBER,
1716     p_init_msg_list                IN VARCHAR2 ,
1717     x_return_status                OUT NOCOPY VARCHAR2,
1718     x_msg_count                    OUT NOCOPY NUMBER,
1719     x_msg_data                     OUT NOCOPY VARCHAR2,
1720     p_oiev_rec                      IN oiev_rec_type) IS
1721 
1722     l_api_version                 CONSTANT NUMBER := 1;
1723     l_api_name                     CONSTANT VARCHAR2(30) := 'V_lock_row';
1724     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1725     l_oie_rec                      oie_rec_type;
1726   BEGIN
1727 
1728     IF (l_debug = 'Y') THEN
1729        okc_debug.Set_Indentation('OKC_OIE_PVT');
1730        okc_debug.log('7200: Entered lock_row', 2);
1731     END IF;
1732 
1733     l_return_status := OKC_API.START_ACTIVITY(l_api_name,
1734                                               G_PKG_NAME,
1735                                               p_init_msg_list,
1736                                               l_api_version,
1737                                               p_api_version,
1738                                               '_PVT',
1739                                               x_return_status);
1740     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1741       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1742     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1743       RAISE OKC_API.G_EXCEPTION_ERROR;
1744     END IF;
1745     --------------------------------------
1746     -- Move VIEW record to "Child" records
1747     --------------------------------------
1748     migrate(p_oiev_rec, l_oie_rec);
1749     --------------------------------------------
1750     -- Call the LOCK_ROW for each child record
1751     --------------------------------------------
1752     lock_row(
1753       p_init_msg_list,
1754       x_return_status,
1755       x_msg_count,
1756       x_msg_data,
1757       l_oie_rec
1758     );
1759     IF (x_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1760       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1761     ELSIF (x_return_status = OKC_API.G_RET_STS_ERROR) THEN
1762       RAISE OKC_API.G_EXCEPTION_ERROR;
1763     END IF;
1764     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
1765 
1766     IF (l_debug = 'Y') THEN
1767        okc_debug.log('7300: Exiting lock_row', 2);
1768        okc_debug.Reset_Indentation;
1769     END IF;
1770 
1771   EXCEPTION
1772     WHEN OKC_API.G_EXCEPTION_ERROR THEN
1773 
1774     IF (l_debug = 'Y') THEN
1775        okc_debug.log('7400: Exiting lock_row:OKC_API.G_EXCEPTION_ERROR Exception', 2);
1776        okc_debug.Reset_Indentation;
1777     END IF;
1778 
1779       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1780       (
1781         l_api_name,
1782         G_PKG_NAME,
1783         'OKC_API.G_RET_STS_ERROR',
1784         x_msg_count,
1785         x_msg_data,
1786         '_PVT'
1787       );
1788     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1789 
1790     IF (l_debug = 'Y') THEN
1791        okc_debug.log('7500: Exiting lock_row:OKC_API.G_EXCEPTION_UNEXPECTED_ERROR Exception', 2);
1792        okc_debug.Reset_Indentation;
1793     END IF;
1794 
1795       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1796       (
1797         l_api_name,
1798         G_PKG_NAME,
1799         'OKC_API.G_RET_STS_UNEXP_ERROR',
1800         x_msg_count,
1801         x_msg_data,
1802         '_PVT'
1803       );
1804     WHEN OTHERS THEN
1805 
1806     IF (l_debug = 'Y') THEN
1807        okc_debug.log('7600: Exiting lock_row:OTHERS Exception', 2);
1808        okc_debug.Reset_Indentation;
1809     END IF;
1810 
1811       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1812       (
1813         l_api_name,
1814         G_PKG_NAME,
1815         'OTHERS',
1816         x_msg_count,
1817         x_msg_data,
1818         '_PVT'
1819       );
1820 
1821   END lock_row;
1822   -------------------------------------
1823   -- PL/SQL TBL lock_row for:oiev_tbl --
1824   -------------------------------------
1825   PROCEDURE lock_row(
1826     p_api_version                  IN NUMBER,
1827     p_init_msg_list                IN VARCHAR2 ,
1828     x_return_status                OUT NOCOPY VARCHAR2,
1829     x_msg_count                    OUT NOCOPY NUMBER,
1830     x_msg_data                     OUT NOCOPY VARCHAR2,
1831     p_oiev_tbl                      IN oiev_tbl_type) IS
1832 
1833     l_api_version                 CONSTANT NUMBER := 1;
1834     l_api_name                     CONSTANT VARCHAR2(30) := 'V_tbl_lock_row';
1835     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1836     l_overall_status               VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1837     i                              NUMBER := 0;
1838   BEGIN
1839 
1840     IF (l_debug = 'Y') THEN
1841        okc_debug.Set_Indentation('OKC_OIE_PVT');
1842        okc_debug.log('7700: Entered lock_row', 2);
1843     END IF;
1844 
1845     OKC_API.init_msg_list(p_init_msg_list);
1846     -- Make sure PL/SQL table has records in it before passing
1847     IF (p_oiev_tbl.COUNT > 0) THEN
1848       i := p_oiev_tbl.FIRST;
1849       LOOP
1850         lock_row (
1851           p_api_version                  => p_api_version,
1852           p_init_msg_list                => OKC_API.G_FALSE,
1853           x_return_status                => x_return_status,
1854           x_msg_count                    => x_msg_count,
1855           x_msg_data                     => x_msg_data,
1856           p_oiev_rec                      => p_oiev_tbl(i));
1857 
1858           -- store the highest degree of error
1859           If x_return_status <> OKC_API.G_RET_STS_SUCCESS Then
1860              If l_overall_status <> OKC_API.G_RET_STS_UNEXP_ERROR Then
1861                 l_overall_status := x_return_status;
1862              End If;
1863           End If;
1864 
1865         EXIT WHEN (i = p_oiev_tbl.LAST);
1866         i := p_oiev_tbl.NEXT(i);
1867       END LOOP;
1868       -- return overall status
1869       x_return_status := l_overall_status;
1870     END IF;
1871 
1872 IF (l_debug = 'Y') THEN
1873    okc_debug.log('7800: Exiting lock_row', 2);
1874    okc_debug.Reset_Indentation;
1875 END IF;
1876 
1877   EXCEPTION
1878     WHEN OKC_API.G_EXCEPTION_ERROR THEN
1879 
1880     IF (l_debug = 'Y') THEN
1881        okc_debug.log('7900: Exiting lock_row:OKC_API.G_EXCEPTION_ERROR Exception', 2);
1882        okc_debug.Reset_Indentation;
1883     END IF;
1884 
1885       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1886       (
1887         l_api_name,
1888         G_PKG_NAME,
1889         'OKC_API.G_RET_STS_ERROR',
1890         x_msg_count,
1891         x_msg_data,
1892         '_PVT'
1893       );
1894     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1895 
1896     IF (l_debug = 'Y') THEN
1897        okc_debug.log('8000: Exiting lock_row:OKC_API.G_EXCEPTION_UNEXPECTED_ERROR Exception', 2);
1898        okc_debug.Reset_Indentation;
1899     END IF;
1900 
1901       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1902       (
1903         l_api_name,
1904         G_PKG_NAME,
1905         'OKC_API.G_RET_STS_UNEXP_ERROR',
1906         x_msg_count,
1907         x_msg_data,
1908         '_PVT'
1909       );
1910     WHEN OTHERS THEN
1911 
1912     IF (l_debug = 'Y') THEN
1913        okc_debug.log('8100: Exiting lock_row:OTHERS Exception', 2);
1914        okc_debug.Reset_Indentation;
1915     END IF;
1916 
1917       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1918       (
1919         l_api_name,
1920         G_PKG_NAME,
1921         'OTHERS',
1922         x_msg_count,
1923         x_msg_data,
1924         '_PVT'
1925       );
1926 
1927   END lock_row;
1928 
1929   ---------------------------------------------------------------------------
1930   -- PROCEDURE update_row
1931   ---------------------------------------------------------------------------
1932   --------------------------------------------
1933   -- update_row for:OKC_OPERATION_INSTANCES --
1934   --------------------------------------------
1935   PROCEDURE update_row(
1936     p_init_msg_list                IN VARCHAR2 ,
1937     x_return_status                OUT NOCOPY VARCHAR2,
1938     x_msg_count                    OUT NOCOPY NUMBER,
1939     x_msg_data                     OUT NOCOPY VARCHAR2,
1940     p_oie_rec                      IN oie_rec_type,
1941     x_oie_rec                      OUT NOCOPY oie_rec_type) IS
1942 
1943     l_api_version                 CONSTANT NUMBER := 1;
1944     l_api_name                     CONSTANT VARCHAR2(30) := 'INSTANCES_update_row';
1945     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1946     l_oie_rec                      oie_rec_type := p_oie_rec;
1947     l_def_oie_rec                  oie_rec_type;
1948     l_row_notfound                 BOOLEAN := TRUE;
1949     ----------------------------------
1950     -- FUNCTION populate_new_record --
1951     ----------------------------------
1952     FUNCTION populate_new_record (
1953       p_oie_rec	IN oie_rec_type,
1954       x_oie_rec	OUT NOCOPY oie_rec_type
1955     ) RETURN VARCHAR2 IS
1956       l_oie_rec                      oie_rec_type;
1957       l_row_notfound                 BOOLEAN := TRUE;
1958       l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1959     BEGIN
1960 
1961     IF (l_debug = 'Y') THEN
1962        okc_debug.Set_Indentation('OKC_OIE_PVT');
1963        okc_debug.log('8200: Entered populate_new_record', 2);
1964     END IF;
1965 
1966       x_oie_rec := p_oie_rec;
1967       -- Get current database values
1968       l_oie_rec := get_rec(p_oie_rec, l_row_notfound);
1969       IF (l_row_notfound) THEN
1970         l_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
1971       END IF;
1972       IF (x_oie_rec.id = OKC_API.G_MISS_NUM)
1973       THEN
1974         x_oie_rec.id := l_oie_rec.id;
1975       END IF;
1976       IF (x_oie_rec.cop_id = OKC_API.G_MISS_NUM)
1977       THEN
1978         x_oie_rec.cop_id := l_oie_rec.cop_id;
1979       END IF;
1980       IF (x_oie_rec.status_code = OKC_API.G_MISS_CHAR)
1981       THEN
1982         x_oie_rec.status_code := l_oie_rec.status_code;
1983       END IF;
1984       IF (x_oie_rec.object_version_number = OKC_API.G_MISS_NUM)
1985       THEN
1986         x_oie_rec.object_version_number := l_oie_rec.object_version_number;
1987       END IF;
1988       IF (x_oie_rec.created_by = OKC_API.G_MISS_NUM)
1989       THEN
1990         x_oie_rec.created_by := l_oie_rec.created_by;
1991       END IF;
1992       IF (x_oie_rec.creation_date = OKC_API.G_MISS_DATE)
1993       THEN
1994         x_oie_rec.creation_date := l_oie_rec.creation_date;
1995       END IF;
1996       IF (x_oie_rec.last_updated_by = OKC_API.G_MISS_NUM)
1997       THEN
1998         x_oie_rec.last_updated_by := l_oie_rec.last_updated_by;
1999       END IF;
2000       IF (x_oie_rec.last_update_date = OKC_API.G_MISS_DATE)
2001       THEN
2002         x_oie_rec.last_update_date := l_oie_rec.last_update_date;
2003       END IF;
2004       IF (x_oie_rec.last_update_login = OKC_API.G_MISS_NUM)
2005       THEN
2006         x_oie_rec.last_update_login := l_oie_rec.last_update_login;
2007       END IF;
2008       IF (x_oie_rec.name = OKC_API.G_MISS_CHAR)
2009       THEN
2010         x_oie_rec.name := l_oie_rec.name;
2011       END IF;
2012       IF (x_oie_rec.target_chr_id = OKC_API.G_MISS_NUM)
2013       THEN
2014         x_oie_rec.target_chr_id := l_oie_rec.target_chr_id;
2015       END IF;
2016       IF (x_oie_rec.request_id = OKC_API.G_MISS_NUM)
2017       THEN
2018         x_oie_rec.request_id := l_oie_rec.request_id;
2019       END IF;
2020       IF (x_oie_rec.program_application_id = OKC_API.G_MISS_NUM)
2021       THEN
2022         x_oie_rec.program_application_id := l_oie_rec.program_application_id;
2023       END IF;
2024       IF (x_oie_rec.program_id = OKC_API.G_MISS_NUM)
2025       THEN
2026         x_oie_rec.program_id := l_oie_rec.program_id;
2027       END IF;
2028       IF (x_oie_rec.program_update_date = OKC_API.G_MISS_DATE)
2029       THEN
2030         x_oie_rec.program_update_date := l_oie_rec.program_update_date;
2031       END IF;
2032       IF (x_oie_rec.jtot_object1_code =  OKC_API.G_MISS_CHAR)
2033       THEN
2034         x_oie_rec.jtot_object1_code := l_oie_rec.jtot_object1_code;
2035       END IF;
2036       IF (x_oie_rec.object1_id1 = OKC_API.G_MISS_CHAR)
2037       THEN
2038         x_oie_rec.object1_id1 := l_oie_rec.object1_id1;
2039       END IF;
2040       IF (x_oie_rec.object1_id2 = OKC_API.G_MISS_CHAR)
2041       THEN
2042         x_oie_rec.object1_id2 := l_oie_rec.object1_id2;
2043       END IF;
2044 
2045 -- R12 Data Model Changes 4485150 Start
2046       IF (x_oie_rec.batch_id = OKC_API.G_MISS_NUM) /* mmadhavi 4485150 : it is G_MISS_NUM */
2047       THEN
2048         x_oie_rec.batch_id := l_oie_rec.batch_id;
2049       END IF;
2050 -- R12 Data Model Changes 4485150 Start
2051 
2052 IF (l_debug = 'Y') THEN
2053    okc_debug.log('8250: Leaving  populate_new_record ', 2);
2054    okc_debug.Reset_Indentation;
2055 END IF;
2056 
2057       RETURN(l_return_status);
2058     END populate_new_record;
2059     ------------------------------------------------
2060     -- Set_Attributes for:OKC_OPERATION_INSTANCES --
2061     ------------------------------------------------
2062     FUNCTION Set_Attributes (
2063       p_oie_rec IN  oie_rec_type,
2064       x_oie_rec OUT NOCOPY oie_rec_type
2065     ) RETURN VARCHAR2 IS
2066       l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
2067     BEGIN
2068 
2069       x_oie_rec := p_oie_rec;
2070       RETURN(l_return_status);
2071 
2072     END Set_Attributes;
2073   BEGIN
2074 
2075     IF (l_debug = 'Y') THEN
2076        okc_debug.Set_Indentation('OKC_OIE_PVT');
2077        okc_debug.log('8400: Entered update_row', 2);
2078     END IF;
2079 
2080     l_return_status := OKC_API.START_ACTIVITY(l_api_name,
2081                                               p_init_msg_list,
2082                                               '_PVT',
2083                                               x_return_status);
2084     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2085       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2086     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2087       RAISE OKC_API.G_EXCEPTION_ERROR;
2088     END IF;
2089     --- Setting item attributes
2090     l_return_status := Set_Attributes(
2091       p_oie_rec,                         -- IN
2092       l_oie_rec);                        -- OUT
2093     --- If any errors happen abort API
2094     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2095       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2096     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2097       RAISE OKC_API.G_EXCEPTION_ERROR;
2098     END IF;
2099     l_return_status := populate_new_record(l_oie_rec, l_def_oie_rec);
2100     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2101       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2102     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2103       RAISE OKC_API.G_EXCEPTION_ERROR;
2104     END IF;
2105     UPDATE  OKC_OPERATION_INSTANCES
2106     SET COP_ID = l_def_oie_rec.cop_id,
2107         STATUS_CODE = l_def_oie_rec.status_code,
2108         OBJECT_VERSION_NUMBER = l_def_oie_rec.object_version_number,
2109         CREATED_BY = l_def_oie_rec.created_by,
2110         CREATION_DATE = l_def_oie_rec.creation_date,
2111         LAST_UPDATED_BY = l_def_oie_rec.last_updated_by,
2112         LAST_UPDATE_DATE = l_def_oie_rec.last_update_date,
2113         LAST_UPDATE_LOGIN = l_def_oie_rec.last_update_login,
2114         NAME = l_def_oie_rec.name,
2115         TARGET_CHR_ID = l_def_oie_rec.target_chr_id,
2116 
2117         REQUEST_ID = NVL(decode(FND_GLOBAL.CONC_REQUEST_ID,-1,NULL,FND_GLOBAL.CONC_REQUEST_ID),l_def_oie_rec.request_id),
2118 	   PROGRAM_APPLICATION_ID = NVL(decode(FND_GLOBAL.PROG_APPL_ID,-1,NULL,FND_GLOBAL.PROG_APPL_ID),l_def_oie_rec.program_application_id),
2119         PROGRAM_ID = NVL(decode(FND_GLOBAL.CONC_PROGRAM_ID,-1,NULL,FND_GLOBAL.CONC_PROGRAM_ID),l_def_oie_rec.program_id),
2120         PROGRAM_UPDATE_DATE = decode(decode(FND_GLOBAL.CONC_REQUEST_ID,-1,NULL,SYSDATE),NULL,l_def_oie_rec.program_update_date,SYSDATE),
2121         JTOT_OBJECT1_CODE = l_def_oie_rec.jtot_object1_code,
2122         OBJECT1_ID1 = l_def_oie_rec.object1_id1,
2123         OBJECT1_ID2 = l_def_oie_rec.object1_id2,
2124 -- R12 Data Model Changes 4485150 Start
2125         BATCH_ID = l_def_oie_rec.batch_id
2126 -- R12 Data Model Changes 4485150 End
2127     WHERE ID = l_def_oie_rec.id;
2128 
2129     x_oie_rec := l_def_oie_rec;
2130     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
2131 
2132   IF (l_debug = 'Y') THEN
2133      okc_debug.log('8500: Exiting update_row', 2);
2134      okc_debug.Reset_Indentation;
2135   END IF;
2136 
2137   EXCEPTION
2138     WHEN OKC_API.G_EXCEPTION_ERROR THEN
2139 
2140     IF (l_debug = 'Y') THEN
2141        okc_debug.log('8600: Exiting update_row:OKC_API.G_EXCEPTION_ERROR Exception', 2);
2142        okc_debug.Reset_Indentation;
2143     END IF;
2144 
2145       x_return_status := OKC_API.HANDLE_EXCEPTIONS
2146       (
2147         l_api_name,
2148         G_PKG_NAME,
2149         'OKC_API.G_RET_STS_ERROR',
2150         x_msg_count,
2151         x_msg_data,
2152         '_PVT'
2153       );
2154     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
2155 
2156     IF (l_debug = 'Y') THEN
2157        okc_debug.log('8700: Exiting update_row:OKC_API.G_EXCEPTION_UNEXPECTED_ERROR Exception', 2);
2158        okc_debug.Reset_Indentation;
2159     END IF;
2160 
2161       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2162       (
2163         l_api_name,
2164         G_PKG_NAME,
2165         'OKC_API.G_RET_STS_UNEXP_ERROR',
2166         x_msg_count,
2167         x_msg_data,
2168         '_PVT'
2169       );
2170     WHEN OTHERS THEN
2171 
2172     IF (l_debug = 'Y') THEN
2173        okc_debug.log('8800: Exiting update_row:OTHERS Exception', 2);
2174        okc_debug.Reset_Indentation;
2175     END IF;
2176 
2177       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2178       (
2179         l_api_name,
2180         G_PKG_NAME,
2181         'OTHERS',
2182         x_msg_count,
2183         x_msg_data,
2184         '_PVT'
2185       );
2186 
2187   END update_row;
2188   ----------------------------------------------
2189   -- update_row for:OKC_OPERATION_INSTANCES_V --
2190   ----------------------------------------------
2191   PROCEDURE update_row(
2192     p_api_version                  IN NUMBER,
2193     p_init_msg_list                IN VARCHAR2 ,
2194     x_return_status                OUT NOCOPY VARCHAR2,
2195     x_msg_count                    OUT NOCOPY NUMBER,
2196     x_msg_data                     OUT NOCOPY VARCHAR2,
2197     p_oiev_rec                      IN oiev_rec_type,
2198     x_oiev_rec                      OUT NOCOPY oiev_rec_type) IS
2199 
2200     l_api_version                 CONSTANT NUMBER := 1;
2201     l_api_name                     CONSTANT VARCHAR2(30) := 'V_update_row';
2202     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
2203     l_oiev_rec                      oiev_rec_type := p_oiev_rec;
2204     l_def_oiev_rec                  oiev_rec_type;
2205     l_oie_rec                      oie_rec_type;
2206     lx_oie_rec                     oie_rec_type;
2207     -------------------------------
2208     -- FUNCTION fill_who_columns --
2209     -------------------------------
2210     FUNCTION fill_who_columns (
2211       p_oiev_rec	IN oiev_rec_type
2212     ) RETURN oiev_rec_type IS
2213       l_oiev_rec	oiev_rec_type := p_oiev_rec;
2214     BEGIN
2215 
2216     IF (l_debug = 'Y') THEN
2217        okc_debug.Set_Indentation('OKC_OIE_PVT');
2218        okc_debug.log('8900: Entered fill_who_columns', 2);
2219     END IF;
2220 
2221       l_oiev_rec.LAST_UPDATE_DATE := SYSDATE;
2222       l_oiev_rec.LAST_UPDATED_BY := FND_GLOBAL.USER_ID;
2223       l_oiev_rec.LAST_UPDATE_LOGIN := FND_GLOBAL.LOGIN_ID;
2224       RETURN(l_oiev_rec);
2225 
2226     END fill_who_columns;
2227     ----------------------------------
2228     -- FUNCTION populate_new_record --
2229     ----------------------------------
2230     FUNCTION populate_new_record (
2231       p_oiev_rec	IN oiev_rec_type,
2232       x_oiev_rec	OUT NOCOPY oiev_rec_type
2233     ) RETURN VARCHAR2 IS
2234       l_oiev_rec                      oiev_rec_type;
2235       l_row_notfound                 BOOLEAN := TRUE;
2236       l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
2237     BEGIN
2238 
2239     IF (l_debug = 'Y') THEN
2240        okc_debug.Set_Indentation('OKC_OIE_PVT');
2241        okc_debug.log('9000: Entered populate_new_record', 2);
2242     END IF;
2243 
2244       x_oiev_rec := p_oiev_rec;
2245       -- Get current database values
2246       l_oiev_rec := get_rec(p_oiev_rec, l_row_notfound);
2247       IF (l_row_notfound) THEN
2248         l_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
2249       END IF;
2250       IF (x_oiev_rec.id = OKC_API.G_MISS_NUM)
2251       THEN
2252         x_oiev_rec.id := l_oiev_rec.id;
2253       END IF;
2254       IF (x_oiev_rec.name = OKC_API.G_MISS_CHAR)
2255       THEN
2256         x_oiev_rec.name := l_oiev_rec.name;
2257       END IF;
2258       IF (x_oiev_rec.cop_id = OKC_API.G_MISS_NUM)
2259       THEN
2260         x_oiev_rec.cop_id := l_oiev_rec.cop_id;
2261       END IF;
2262       IF (x_oiev_rec.status_code = OKC_API.G_MISS_CHAR)
2263       THEN
2264         x_oiev_rec.status_code := l_oiev_rec.status_code;
2265       END IF;
2266       IF (x_oiev_rec.target_chr_id = OKC_API.G_MISS_NUM)
2267       THEN
2268         x_oiev_rec.target_chr_id := l_oiev_rec.target_chr_id;
2269       END IF;
2270       IF (x_oiev_rec.object_version_number = OKC_API.G_MISS_NUM)
2271       THEN
2272         x_oiev_rec.object_version_number := l_oiev_rec.object_version_number;
2273       END IF;
2274       IF (x_oiev_rec.created_by = OKC_API.G_MISS_NUM)
2275       THEN
2276         x_oiev_rec.created_by := l_oiev_rec.created_by;
2277       END IF;
2278       IF (x_oiev_rec.creation_date = OKC_API.G_MISS_DATE)
2279       THEN
2280         x_oiev_rec.creation_date := l_oiev_rec.creation_date;
2281       END IF;
2282       IF (x_oiev_rec.last_updated_by = OKC_API.G_MISS_NUM)
2283       THEN
2284         x_oiev_rec.last_updated_by := l_oiev_rec.last_updated_by;
2285       END IF;
2286       IF (x_oiev_rec.last_update_date = OKC_API.G_MISS_DATE)
2287       THEN
2288         x_oiev_rec.last_update_date := l_oiev_rec.last_update_date;
2289       END IF;
2290       IF (x_oiev_rec.last_update_login = OKC_API.G_MISS_NUM)
2291       THEN
2292         x_oiev_rec.last_update_login := l_oiev_rec.last_update_login;
2293       END IF;
2294       IF (x_oiev_rec.jtot_object1_code = OKC_API.G_MISS_CHAR)
2295       THEN
2296         x_oiev_rec.jtot_object1_code := l_oiev_rec.jtot_object1_code;
2297       END IF;
2298       IF (x_oiev_rec.object1_id1 = OKC_API.G_MISS_CHAR)
2299       THEN
2300         x_oiev_rec.object1_id1 := l_oiev_rec.object1_id1;
2301       END IF;
2302       IF (x_oiev_rec.object1_id2 = OKC_API.G_MISS_CHAR)
2303       THEN
2304         x_oiev_rec.object1_id2 := l_oiev_rec.object1_id2;
2305       END IF;
2306 
2307 IF (l_debug = 'Y') THEN
2308    okc_debug.log('11950: Leaving  populate_new_record ', 2);
2309    okc_debug.Reset_Indentation;
2310 END IF;
2311 
2312       RETURN(l_return_status);
2313 
2314     END populate_new_record;
2315     --------------------------------------------------
2316     -- Set_Attributes for:OKC_OPERATION_INSTANCES_V --
2317     --------------------------------------------------
2318     FUNCTION Set_Attributes (
2319       p_oiev_rec IN  oiev_rec_type,
2320       x_oiev_rec OUT NOCOPY oiev_rec_type
2321     ) RETURN VARCHAR2 IS
2322       l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
2323     BEGIN
2324 
2325       x_oiev_rec := p_oiev_rec;
2326       x_oiev_rec.OBJECT_VERSION_NUMBER := NVL(x_oiev_rec.OBJECT_VERSION_NUMBER, 0) + 1;
2327       RETURN(l_return_status);
2328 
2329     END Set_Attributes;
2330   BEGIN
2331 
2332     IF (l_debug = 'Y') THEN
2333        okc_debug.Set_Indentation('OKC_OIE_PVT');
2334        okc_debug.log('9200: Entered update_row', 2);
2335     END IF;
2336 
2337     l_return_status := OKC_API.START_ACTIVITY(l_api_name,
2338                                               G_PKG_NAME,
2339                                               p_init_msg_list,
2340                                               l_api_version,
2341                                               p_api_version,
2342                                               '_PVT',
2343                                               x_return_status);
2344     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2345       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2346     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2347       RAISE OKC_API.G_EXCEPTION_ERROR;
2348     END IF;
2349     --- Setting item attributes
2350     l_return_status := Set_Attributes(
2351       p_oiev_rec,                         -- IN
2352       l_oiev_rec);                        -- OUT
2353     --- If any errors happen abort API
2354     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2355       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2356     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2357       RAISE OKC_API.G_EXCEPTION_ERROR;
2358     END IF;
2359     l_return_status := populate_new_record(l_oiev_rec, l_def_oiev_rec);
2360     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2361       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2362     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2363       RAISE OKC_API.G_EXCEPTION_ERROR;
2364     END IF;
2365     l_def_oiev_rec := fill_who_columns(l_def_oiev_rec);
2366     --- Validate all non-missing attributes (Item Level Validation)
2367     l_return_status := Validate_Attributes(l_def_oiev_rec);
2368     --- If any errors happen abort API
2369     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2370       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2371     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2372       RAISE OKC_API.G_EXCEPTION_ERROR;
2373     END IF;
2374     l_return_status := Validate_Record(l_def_oiev_rec);
2375     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2376       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2377     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2378       RAISE OKC_API.G_EXCEPTION_ERROR;
2379     END IF;
2380 
2381     --------------------------------------
2382     -- Move VIEW record to "Child" records
2383     --------------------------------------
2384     migrate(l_def_oiev_rec, l_oie_rec);
2385     --------------------------------------------
2386     -- Call the UPDATE_ROW for each child record
2387     --------------------------------------------
2388     update_row(
2389       p_init_msg_list,
2390       x_return_status,
2391       x_msg_count,
2392       x_msg_data,
2393       l_oie_rec,
2394       lx_oie_rec
2395     );
2396     IF (x_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2397       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2398     ELSIF (x_return_status = OKC_API.G_RET_STS_ERROR) THEN
2399       RAISE OKC_API.G_EXCEPTION_ERROR;
2400     END IF;
2401     migrate(lx_oie_rec, l_def_oiev_rec);
2402     x_oiev_rec := l_def_oiev_rec;
2403     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
2404 
2405  IF (l_debug = 'Y') THEN
2406     okc_debug.log('9300: Exiting update_row', 2);
2407     okc_debug.Reset_Indentation;
2408  END IF;
2409 
2410   EXCEPTION
2411     WHEN OKC_API.G_EXCEPTION_ERROR THEN
2412 
2413     IF (l_debug = 'Y') THEN
2414        okc_debug.log('9400: Exiting update_row:OKC_API.G_EXCEPTION_ERROR Exception', 2);
2415        okc_debug.Reset_Indentation;
2416     END IF;
2417 
2418       x_return_status := OKC_API.HANDLE_EXCEPTIONS
2419       (
2420         l_api_name,
2421         G_PKG_NAME,
2422         'OKC_API.G_RET_STS_ERROR',
2423         x_msg_count,
2424         x_msg_data,
2425         '_PVT'
2426       );
2427     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
2428 
2429     IF (l_debug = 'Y') THEN
2430        okc_debug.log('9500: Exiting update_row:OKC_API.G_EXCEPTION_UNEXPECTED_ERROR Exception', 2);
2431        okc_debug.Reset_Indentation;
2432     END IF;
2433 
2434       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2435       (
2436         l_api_name,
2437         G_PKG_NAME,
2438         'OKC_API.G_RET_STS_UNEXP_ERROR',
2439         x_msg_count,
2440         x_msg_data,
2441         '_PVT'
2442       );
2443     WHEN OTHERS THEN
2444 
2445     IF (l_debug = 'Y') THEN
2446        okc_debug.log('9600: Exiting update_row:OTHERS Exception', 2);
2447        okc_debug.Reset_Indentation;
2448     END IF;
2449 
2450       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2451       (
2452         l_api_name,
2453         G_PKG_NAME,
2454         'OTHERS',
2455         x_msg_count,
2456         x_msg_data,
2457         '_PVT'
2458       );
2459 
2460   END update_row;
2461   ---------------------------------------
2462   -- PL/SQL TBL update_row for:oiev_tbl --
2463   ---------------------------------------
2464   PROCEDURE update_row(
2465     p_api_version                  IN NUMBER,
2466     p_init_msg_list                IN VARCHAR2 ,
2467     x_return_status                OUT NOCOPY VARCHAR2,
2468     x_msg_count                    OUT NOCOPY NUMBER,
2469     x_msg_data                     OUT NOCOPY VARCHAR2,
2470     p_oiev_tbl                      IN oiev_tbl_type,
2471     x_oiev_tbl                      OUT NOCOPY oiev_tbl_type) IS
2472 
2473     l_api_version                 CONSTANT NUMBER := 1;
2474     l_api_name                     CONSTANT VARCHAR2(30) := 'V_tbl_update_row';
2475     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
2476     l_overall_status               VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
2477     i                              NUMBER := 0;
2478   BEGIN
2479 
2480     IF (l_debug = 'Y') THEN
2481        okc_debug.Set_Indentation('OKC_OIE_PVT');
2482        okc_debug.log('9700: Entered update_row', 2);
2483     END IF;
2484 
2485     OKC_API.init_msg_list(p_init_msg_list);
2486     -- Make sure PL/SQL table has records in it before passing
2487     IF (p_oiev_tbl.COUNT > 0) THEN
2488       i := p_oiev_tbl.FIRST;
2489       LOOP
2490         update_row (
2491           p_api_version                  => p_api_version,
2492           p_init_msg_list                => OKC_API.G_FALSE,
2493           x_return_status                => x_return_status,
2494           x_msg_count                    => x_msg_count,
2495           x_msg_data                     => x_msg_data,
2496           p_oiev_rec                      => p_oiev_tbl(i),
2497           x_oiev_rec                      => x_oiev_tbl(i));
2498 
2499           -- store the highest degree of error
2500           If x_return_status <> OKC_API.G_RET_STS_SUCCESS Then
2501              If l_overall_status <> OKC_API.G_RET_STS_UNEXP_ERROR Then
2502                 l_overall_status := x_return_status;
2503              End If;
2504           End If;
2505 
2506         EXIT WHEN (i = p_oiev_tbl.LAST);
2507         i := p_oiev_tbl.NEXT(i);
2508       END LOOP;
2509       -- return overall status
2510       x_return_status := l_overall_status;
2511     END IF;
2512 
2513  IF (l_debug = 'Y') THEN
2514     okc_debug.log('9800: Exiting update_row', 2);
2515     okc_debug.Reset_Indentation;
2516  END IF;
2517 
2518   EXCEPTION
2519     WHEN OKC_API.G_EXCEPTION_ERROR THEN
2520 
2521     IF (l_debug = 'Y') THEN
2522        okc_debug.log('9900: Exiting update_row:OKC_API.G_EXCEPTION_ERROR Exception', 2);
2523        okc_debug.Reset_Indentation;
2524     END IF;
2525 
2526       x_return_status := OKC_API.HANDLE_EXCEPTIONS
2527       (
2528         l_api_name,
2529         G_PKG_NAME,
2530         'OKC_API.G_RET_STS_ERROR',
2531         x_msg_count,
2532         x_msg_data,
2533         '_PVT'
2534       );
2535     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
2536 
2537     IF (l_debug = 'Y') THEN
2538        okc_debug.log('10000: Exiting update_row:OKC_API.G_EXCEPTION_UNEXPECTED_ERROR Exception', 2);
2539        okc_debug.Reset_Indentation;
2540     END IF;
2541 
2542       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2543       (
2544         l_api_name,
2545         G_PKG_NAME,
2546         'OKC_API.G_RET_STS_UNEXP_ERROR',
2547         x_msg_count,
2548         x_msg_data,
2549         '_PVT'
2550       );
2551     WHEN OTHERS THEN
2552 
2553     IF (l_debug = 'Y') THEN
2554        okc_debug.log('10100: Exiting update_row:OTHERS Exception', 2);
2555        okc_debug.Reset_Indentation;
2556     END IF;
2557 
2558       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2559       (
2560         l_api_name,
2561         G_PKG_NAME,
2562         'OTHERS',
2563         x_msg_count,
2564         x_msg_data,
2565         '_PVT'
2566       );
2567 
2568   END update_row;
2569 
2570   ---------------------------------------------------------------------------
2571   -- PROCEDURE delete_row
2572   ---------------------------------------------------------------------------
2573   --------------------------------------------
2574   -- delete_row for:OKC_OPERATION_INSTANCES --
2575   --------------------------------------------
2576   PROCEDURE delete_row(
2577     p_init_msg_list                IN VARCHAR2 ,
2578     x_return_status                OUT NOCOPY VARCHAR2,
2579     x_msg_count                    OUT NOCOPY NUMBER,
2580     x_msg_data                     OUT NOCOPY VARCHAR2,
2581     p_oie_rec                      IN oie_rec_type) IS
2582 
2583     l_api_version                 CONSTANT NUMBER := 1;
2584     l_api_name                     CONSTANT VARCHAR2(30) := 'INSTANCES_delete_row';
2585     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
2586     l_oie_rec                      oie_rec_type:= p_oie_rec;
2587     l_row_notfound                 BOOLEAN := TRUE;
2588   BEGIN
2589 
2590     IF (l_debug = 'Y') THEN
2591        okc_debug.Set_Indentation('OKC_OIE_PVT');
2592        okc_debug.log('10200: Entered delete_row', 2);
2593     END IF;
2594 
2595     l_return_status := OKC_API.START_ACTIVITY(l_api_name,
2596                                               p_init_msg_list,
2597                                               '_PVT',
2598                                               x_return_status);
2599     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2600       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2601     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2602       RAISE OKC_API.G_EXCEPTION_ERROR;
2603     END IF;
2604     DELETE FROM OKC_OPERATION_INSTANCES
2605      WHERE ID = l_oie_rec.id;
2606 
2607     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
2608 
2609     IF (l_debug = 'Y') THEN
2610        okc_debug.log('10300: Exiting delete_row', 2);
2611        okc_debug.Reset_Indentation;
2612     END IF;
2613 
2614   EXCEPTION
2615     WHEN OKC_API.G_EXCEPTION_ERROR THEN
2616 
2617     IF (l_debug = 'Y') THEN
2618        okc_debug.log('10400: Exiting delete_row:OKC_API.G_EXCEPTION_ERROR Exception', 2);
2619        okc_debug.Reset_Indentation;
2620     END IF;
2621 
2622       x_return_status := OKC_API.HANDLE_EXCEPTIONS
2623       (
2624         l_api_name,
2625         G_PKG_NAME,
2626         'OKC_API.G_RET_STS_ERROR',
2627         x_msg_count,
2628         x_msg_data,
2629         '_PVT'
2630       );
2631     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
2632 
2633     IF (l_debug = 'Y') THEN
2634        okc_debug.log('10500: Exiting delete_row:OKC_API.G_EXCEPTION_UNEXPECTED_ERROR Exception', 2);
2635        okc_debug.Reset_Indentation;
2636     END IF;
2637 
2638       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2639       (
2640         l_api_name,
2641         G_PKG_NAME,
2642         'OKC_API.G_RET_STS_UNEXP_ERROR',
2643         x_msg_count,
2644         x_msg_data,
2645         '_PVT'
2646       );
2647     WHEN OTHERS THEN
2648 
2649     IF (l_debug = 'Y') THEN
2650        okc_debug.log('10600: Exiting delete_row:OTHERS Exception', 2);
2651        okc_debug.Reset_Indentation;
2652     END IF;
2653 
2654       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2655       (
2656         l_api_name,
2657         G_PKG_NAME,
2658         'OTHERS',
2659         x_msg_count,
2660         x_msg_data,
2661         '_PVT'
2662       );
2663 
2664   END delete_row;
2665   ----------------------------------------------
2666   -- delete_row for:OKC_OPERATION_INSTANCES_V --
2667   ----------------------------------------------
2668   PROCEDURE delete_row(
2669     p_api_version                  IN NUMBER,
2670     p_init_msg_list                IN VARCHAR2 ,
2671     x_return_status                OUT NOCOPY VARCHAR2,
2672     x_msg_count                    OUT NOCOPY NUMBER,
2673     x_msg_data                     OUT NOCOPY VARCHAR2,
2674     p_oiev_rec                      IN oiev_rec_type) IS
2675 
2676     l_api_version                 CONSTANT NUMBER := 1;
2677     l_api_name                     CONSTANT VARCHAR2(30) := 'V_delete_row';
2678     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
2679     l_oiev_rec                      oiev_rec_type := p_oiev_rec;
2680     l_oie_rec                      oie_rec_type;
2681   BEGIN
2682 
2683     IF (l_debug = 'Y') THEN
2684        okc_debug.Set_Indentation('OKC_OIE_PVT');
2685        okc_debug.log('10700: Entered delete_row', 2);
2686     END IF;
2687 
2688     l_return_status := OKC_API.START_ACTIVITY(l_api_name,
2689                                               G_PKG_NAME,
2690                                               p_init_msg_list,
2691                                               l_api_version,
2692                                               p_api_version,
2693                                               '_PVT',
2694                                               x_return_status);
2695     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2696       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2697     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2698       RAISE OKC_API.G_EXCEPTION_ERROR;
2699     END IF;
2700     --------------------------------------
2701     -- Move VIEW record to "Child" records
2702     --------------------------------------
2703     migrate(l_oiev_rec, l_oie_rec);
2704     --------------------------------------------
2705     -- Call the DELETE_ROW for each child record
2706     --------------------------------------------
2707     delete_row(
2708       p_init_msg_list,
2709       x_return_status,
2710       x_msg_count,
2711       x_msg_data,
2712       l_oie_rec
2713     );
2714     IF (x_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2715       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2716     ELSIF (x_return_status = OKC_API.G_RET_STS_ERROR) THEN
2717       RAISE OKC_API.G_EXCEPTION_ERROR;
2718     END IF;
2719     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
2720 
2721     IF (l_debug = 'Y') THEN
2722        okc_debug.log('10800: Exiting delete_row', 2);
2723        okc_debug.Reset_Indentation;
2724     END IF;
2725 
2726   EXCEPTION
2727     WHEN OKC_API.G_EXCEPTION_ERROR THEN
2728 
2729     IF (l_debug = 'Y') THEN
2730        okc_debug.log('10900: Exiting delete_row:OKC_API.G_EXCEPTION_ERROR Exception', 2);
2731        okc_debug.Reset_Indentation;
2732     END IF;
2733 
2734       x_return_status := OKC_API.HANDLE_EXCEPTIONS
2735       (
2736         l_api_name,
2737         G_PKG_NAME,
2738         'OKC_API.G_RET_STS_ERROR',
2739         x_msg_count,
2740         x_msg_data,
2741         '_PVT'
2742       );
2743     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
2744 
2745     IF (l_debug = 'Y') THEN
2746        okc_debug.log('11000: Exiting delete_row:OKC_API.G_EXCEPTION_UNEXPECTED_ERROR Exception', 2);
2747        okc_debug.Reset_Indentation;
2748     END IF;
2749 
2750       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2751       (
2752         l_api_name,
2753         G_PKG_NAME,
2754         'OKC_API.G_RET_STS_UNEXP_ERROR',
2755         x_msg_count,
2756         x_msg_data,
2757         '_PVT'
2758       );
2759     WHEN OTHERS THEN
2760 
2761     IF (l_debug = 'Y') THEN
2762        okc_debug.log('11100: Exiting delete_row:OTHERS Exception', 2);
2763        okc_debug.Reset_Indentation;
2764     END IF;
2765 
2766       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2767       (
2768         l_api_name,
2769         G_PKG_NAME,
2770         'OTHERS',
2771         x_msg_count,
2772         x_msg_data,
2773         '_PVT'
2774       );
2775 
2776   END delete_row;
2777   ---------------------------------------
2778   -- PL/SQL TBL delete_row for:oiev_tbl --
2779   ---------------------------------------
2780   PROCEDURE delete_row(
2781     p_api_version                  IN NUMBER,
2782     p_init_msg_list                IN VARCHAR2 ,
2783     x_return_status                OUT NOCOPY VARCHAR2,
2784     x_msg_count                    OUT NOCOPY NUMBER,
2785     x_msg_data                     OUT NOCOPY VARCHAR2,
2786     p_oiev_tbl                      IN oiev_tbl_type) IS
2787 
2788     l_api_version                 CONSTANT NUMBER := 1;
2789     l_api_name                     CONSTANT VARCHAR2(30) := 'V_tbl_delete_row';
2790     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
2791     l_overall_status               VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
2792     i                              NUMBER := 0;
2793   BEGIN
2794 
2795     IF (l_debug = 'Y') THEN
2796        okc_debug.Set_Indentation('OKC_OIE_PVT');
2797        okc_debug.log('11200: Entered delete_row', 2);
2798     END IF;
2799 
2800     OKC_API.init_msg_list(p_init_msg_list);
2801     -- Make sure PL/SQL table has records in it before passing
2802     IF (p_oiev_tbl.COUNT > 0) THEN
2803       i := p_oiev_tbl.FIRST;
2804       LOOP
2805         delete_row (
2806           p_api_version                  => p_api_version,
2807           p_init_msg_list                => OKC_API.G_FALSE,
2808           x_return_status                => x_return_status,
2809           x_msg_count                    => x_msg_count,
2810           x_msg_data                     => x_msg_data,
2811           p_oiev_rec                      => p_oiev_tbl(i));
2812 
2813           -- store the highest degree of error
2814           If x_return_status <> OKC_API.G_RET_STS_SUCCESS Then
2815              If l_overall_status <> OKC_API.G_RET_STS_UNEXP_ERROR Then
2816                 l_overall_status := x_return_status;
2817              End If;
2818           End If;
2819 
2820         EXIT WHEN (i = p_oiev_tbl.LAST);
2821         i := p_oiev_tbl.NEXT(i);
2822       END LOOP;
2823       -- return overall status
2824       x_return_status := l_overall_status;
2825     END IF;
2826 
2827     IF (l_debug = 'Y') THEN
2828        okc_debug.log('11300: Exiting delete_row', 2);
2829        okc_debug.Reset_Indentation;
2830     END IF;
2831 
2832   EXCEPTION
2833     WHEN OKC_API.G_EXCEPTION_ERROR THEN
2834 
2835     IF (l_debug = 'Y') THEN
2836        okc_debug.log('11400: Exiting delete_row:OKC_API.G_EXCEPTION_ERROR Exception', 2);
2837        okc_debug.Reset_Indentation;
2838     END IF;
2839 
2840       x_return_status := OKC_API.HANDLE_EXCEPTIONS
2841       (
2842         l_api_name,
2843         G_PKG_NAME,
2844         'OKC_API.G_RET_STS_ERROR',
2845         x_msg_count,
2846         x_msg_data,
2847         '_PVT'
2848       );
2849     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
2850 
2851     IF (l_debug = 'Y') THEN
2852        okc_debug.log('11500: Exiting delete_row:OKC_API.G_EXCEPTION_UNEXPECTED_ERROR Exception', 2);
2853        okc_debug.Reset_Indentation;
2854     END IF;
2855 
2856       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2857       (
2858         l_api_name,
2859         G_PKG_NAME,
2860         'OKC_API.G_RET_STS_UNEXP_ERROR',
2861         x_msg_count,
2862         x_msg_data,
2863         '_PVT'
2864       );
2865     WHEN OTHERS THEN
2866 
2867     IF (l_debug = 'Y') THEN
2868        okc_debug.log('11600: Exiting delete_row:OTHERS Exception', 2);
2869        okc_debug.Reset_Indentation;
2870     END IF;
2871 
2872       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2873       (
2874         l_api_name,
2875         G_PKG_NAME,
2876         'OTHERS',
2877         x_msg_count,
2878         x_msg_data,
2879         '_PVT'
2880       );
2881 
2882   END delete_row;
2883 
2884 END OKC_OIE_PVT;