DBA Data[Home] [Help]

PACKAGE BODY: APPS.OKL_CGM_PVT

Source


1 PACKAGE BODY OKL_CGM_PVT AS
2 /* $Header: OKLSCGMB.pls 120.2 2006/12/07 06:16:42 ssdeshpa noship $ */
3   ---------------------------------------------------------------------------
4   -- FUNCTION get_seq_id
5   ---------------------------------------------------------------------------
6   FUNCTION get_seq_id RETURN NUMBER IS
7   BEGIN
8     RETURN(okc_p_util.raw_to_number(sys_guid()));
9   END get_seq_id;
10 
11   ---------------------------------------------------------------------------
12   -- PROCEDURE qc
13   ---------------------------------------------------------------------------
14   PROCEDURE qc IS
15   BEGIN
16     null;
17   END qc;
18 
19   ---------------------------------------------------------------------------
20   -- PROCEDURE change_version
21   ---------------------------------------------------------------------------
22   PROCEDURE change_version IS
23   BEGIN
24     null;
25   END change_version;
26 
27   ---------------------------------------------------------------------------
28   -- PROCEDURE api_copy
29   ---------------------------------------------------------------------------
30   PROCEDURE api_copy IS
31   BEGIN
32     null;
33   END api_copy;
34 
35   ---------------------------------------------------------------------------
36   -- FUNCTION get_rec for: OKL_CNTX_GRP_PRMTRS
37   ---------------------------------------------------------------------------
38   FUNCTION get_rec (
39     p_cgm_rec                      IN cgm_rec_type,
40     x_no_data_found                OUT NOCOPY BOOLEAN
41   ) RETURN cgm_rec_type IS
42     CURSOR okl_cntx_grp_prmtrs_b_pk_csr (p_id                 IN NUMBER) IS
43     SELECT
44             ID,
45             CGR_ID,
46             PMR_ID,
47             OBJECT_VERSION_NUMBER,
48             CREATED_BY,
49             CREATION_DATE,
50             LAST_UPDATED_BY,
51             LAST_UPDATE_DATE,
52             LAST_UPDATE_LOGIN
53       FROM Okl_Cntx_Grp_Prmtrs
54      WHERE okl_cntx_grp_prmtrs.id = p_id;
55     l_okl_cntx_grp_prmtrs_b_pk     okl_cntx_grp_prmtrs_b_pk_csr%ROWTYPE;
56     l_cgm_rec                      cgm_rec_type;
57   BEGIN
58     x_no_data_found := TRUE;
59     -- Get current database values
60     OPEN okl_cntx_grp_prmtrs_b_pk_csr (p_cgm_rec.id);
61     FETCH okl_cntx_grp_prmtrs_b_pk_csr INTO
62               l_cgm_rec.ID,
63               l_cgm_rec.CGR_ID,
64               l_cgm_rec.PMR_ID,
65               l_cgm_rec.OBJECT_VERSION_NUMBER,
66               l_cgm_rec.CREATED_BY,
67               l_cgm_rec.CREATION_DATE,
68               l_cgm_rec.LAST_UPDATED_BY,
69               l_cgm_rec.LAST_UPDATE_DATE,
70               l_cgm_rec.LAST_UPDATE_LOGIN;
71     x_no_data_found := okl_cntx_grp_prmtrs_b_pk_csr%NOTFOUND;
72     CLOSE okl_cntx_grp_prmtrs_b_pk_csr;
73     RETURN(l_cgm_rec);
74   END get_rec;
75 
76   FUNCTION get_rec (
77     p_cgm_rec                      IN cgm_rec_type
78   ) RETURN cgm_rec_type IS
79     l_row_notfound                 BOOLEAN := TRUE;
80   BEGIN
81     RETURN(get_rec(p_cgm_rec, l_row_notfound));
82   END get_rec;
83   ---------------------------------------------------------------------------
84   -- FUNCTION get_rec for: OKL_CNTX_GRP_PRMTRS_V
85   ---------------------------------------------------------------------------
86   FUNCTION get_rec (
87     p_cgmv_rec                     IN cgmv_rec_type,
88     x_no_data_found                OUT NOCOPY BOOLEAN
89   ) RETURN cgmv_rec_type IS
90     CURSOR okl_cgmv_pk_csr (p_id                 IN NUMBER) IS
91     SELECT
92             ID,
93             OBJECT_VERSION_NUMBER,
94             CGR_ID,
95             PMR_ID,
96             CREATED_BY,
97             CREATION_DATE,
98             LAST_UPDATED_BY,
99             LAST_UPDATE_DATE,
100             LAST_UPDATE_LOGIN
101       FROM Okl_Cntx_Grp_Prmtrs_V
102      WHERE okl_cntx_grp_prmtrs_v.id = p_id;
103     l_okl_cgmv_pk                  okl_cgmv_pk_csr%ROWTYPE;
104     l_cgmv_rec                     cgmv_rec_type;
105   BEGIN
106     x_no_data_found := TRUE;
107     -- Get current database values
108     OPEN okl_cgmv_pk_csr (p_cgmv_rec.id);
109     FETCH okl_cgmv_pk_csr INTO
110               l_cgmv_rec.ID,
111               l_cgmv_rec.OBJECT_VERSION_NUMBER,
112               l_cgmv_rec.CGR_ID,
113               l_cgmv_rec.PMR_ID,
114               l_cgmv_rec.CREATED_BY,
115               l_cgmv_rec.CREATION_DATE,
116               l_cgmv_rec.LAST_UPDATED_BY,
117               l_cgmv_rec.LAST_UPDATE_DATE,
118               l_cgmv_rec.LAST_UPDATE_LOGIN;
119     x_no_data_found := okl_cgmv_pk_csr%NOTFOUND;
120     CLOSE okl_cgmv_pk_csr;
121     RETURN(l_cgmv_rec);
122   END get_rec;
123 
124   FUNCTION get_rec (
125     p_cgmv_rec                     IN cgmv_rec_type
126   ) RETURN cgmv_rec_type IS
127     l_row_notfound                 BOOLEAN := TRUE;
128   BEGIN
129     RETURN(get_rec(p_cgmv_rec, l_row_notfound));
130   END get_rec;
131 
132   -----------------------------------------------------------
133   -- FUNCTION null_out_defaults for: OKL_CNTX_GRP_PRMTRS_V --
134   -----------------------------------------------------------
135   FUNCTION null_out_defaults (
136     p_cgmv_rec	IN cgmv_rec_type
137   ) RETURN cgmv_rec_type IS
138     l_cgmv_rec	cgmv_rec_type := p_cgmv_rec;
139   BEGIN
140     IF (l_cgmv_rec.object_version_number = OKC_API.G_MISS_NUM) THEN
141       l_cgmv_rec.object_version_number := NULL;
142     END IF;
143     IF (l_cgmv_rec.cgr_id = OKC_API.G_MISS_NUM) THEN
144       l_cgmv_rec.cgr_id := NULL;
145     END IF;
146     IF (l_cgmv_rec.pmr_id = OKC_API.G_MISS_NUM) THEN
147       l_cgmv_rec.pmr_id := NULL;
148     END IF;
149     IF (l_cgmv_rec.created_by = OKC_API.G_MISS_NUM) THEN
150       l_cgmv_rec.created_by := NULL;
151     END IF;
152     IF (l_cgmv_rec.creation_date = OKC_API.G_MISS_DATE) THEN
153       l_cgmv_rec.creation_date := NULL;
154     END IF;
155     IF (l_cgmv_rec.last_updated_by = OKC_API.G_MISS_NUM) THEN
156       l_cgmv_rec.last_updated_by := NULL;
157     END IF;
158     IF (l_cgmv_rec.last_update_date = OKC_API.G_MISS_DATE) THEN
159       l_cgmv_rec.last_update_date := NULL;
160     END IF;
161     IF (l_cgmv_rec.last_update_login = OKC_API.G_MISS_NUM) THEN
162       l_cgmv_rec.last_update_login := NULL;
163     END IF;
164     RETURN(l_cgmv_rec);
165   END null_out_defaults;
166 
167   /** Commented out nocopy generated code in favor of hand written code *** SBALASHA001 Start ***
168 
169   ---------------------------------------------------------------------------
170   -- PROCEDURE Validate_Attributes
171   ---------------------------------------------------------------------------
172   ---------------------------------------------------
173   -- Validate_Attributes for:OKL_CNTX_GRP_PRMTRS_V --
174   ---------------------------------------------------
175   FUNCTION Validate_Attributes (
176     p_cgmv_rec IN  cgmv_rec_type
177   ) RETURN VARCHAR2 IS
178     l_return_status	VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
179   BEGIN
180     IF p_cgmv_rec.id = OKC_API.G_MISS_NUM OR
181        p_cgmv_rec.id IS NULL
182     THEN
183       OKC_API.set_message(G_APP_NAME, G_REQUIRED_VALUE,G_COL_NAME_TOKEN,'id');
184       l_return_status := OKC_API.G_RET_STS_ERROR;
185     ELSIF p_cgmv_rec.object_version_number = OKC_API.G_MISS_NUM OR
186           p_cgmv_rec.object_version_number IS NULL
187     THEN
188       OKC_API.set_message(G_APP_NAME, G_REQUIRED_VALUE,G_COL_NAME_TOKEN,'object_version_number');
189       l_return_status := OKC_API.G_RET_STS_ERROR;
190     ELSIF p_cgmv_rec.cgr_id = OKC_API.G_MISS_NUM OR
191           p_cgmv_rec.cgr_id IS NULL
192     THEN
193       OKC_API.set_message(G_APP_NAME, G_REQUIRED_VALUE,G_COL_NAME_TOKEN,'cgr_id');
194       l_return_status := OKC_API.G_RET_STS_ERROR;
195     ELSIF p_cgmv_rec.pmr_id = OKC_API.G_MISS_NUM OR
196           p_cgmv_rec.pmr_id IS NULL
197     THEN
198       OKC_API.set_message(G_APP_NAME, G_REQUIRED_VALUE,G_COL_NAME_TOKEN,'pmr_id');
199       l_return_status := OKC_API.G_RET_STS_ERROR;
200     END IF;
201     RETURN(l_return_status);
202   END Validate_Attributes;
203 
204   ---------------------------------------------------------------------------
205   -- PROCEDURE Validate_Record
206   ---------------------------------------------------------------------------
207   -----------------------------------------------
208   -- Validate_Record for:OKL_CNTX_GRP_PRMTRS_V --
209   -----------------------------------------------
210   FUNCTION Validate_Record (
211     p_cgmv_rec IN cgmv_rec_type
212   ) RETURN VARCHAR2 IS
213     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
214   BEGIN
215     RETURN (l_return_status);
216   END Validate_Record;
217 
218   *** SBALASHA001 End *** **/
219 
220  /** SBALASHA001 Start *** -
221       INFO: hand coded function related to validate_attribute  **/
222 
223   ---------------------------------------------------------------------------
224   -- PROCEDURE Validate_Object_Version_Number
225   ---------------------------------------------------------------------------
226   -- Start of comments
227   --
228   -- Procedure Name  : Validate_Object_Version_Number
229   -- Description     :
230   -- Business Rules  :
231   -- Parameters      :
232   -- Version         : 1.0
233   -- End of comments
234   ---------------------------------------------------------------------------
235   PROCEDURE Validate_Object_Version_Number(x_return_status OUT NOCOPY  VARCHAR2
236                                           ,p_cgmv_rec      IN   cgmv_rec_type)
237   IS
238 
239   l_return_status         VARCHAR2(1)  := OKC_API.G_RET_STS_SUCCESS;
240 
241   BEGIN
242     -- initialize return status
243     x_return_status := OKC_API.G_RET_STS_SUCCESS;
244 
245     -- check for data before processing
246     IF ( p_cgmv_rec.object_version_number IS NULL ) OR
247        ( p_cgmv_rec.object_version_Number = OKC_API.G_MISS_NUM ) THEN
248        OKC_API.SET_MESSAGE( p_app_name       => g_app_name,
249                             p_msg_name       => g_required_value,
250                             p_token1         => g_col_name_token,
251                             p_token1_value   => 'object_version_number' );
252        x_return_status    := OKC_API.G_RET_STS_ERROR;
253        RAISE G_EXCEPTION_HALT_VALIDATION;
254     END IF;
255 
256   EXCEPTION
257     WHEN G_EXCEPTION_HALT_VALIDATION THEN
258     -- no processing necessary; validation can continue
259     -- with the next column
260     NULL;
261 
262     WHEN OTHERS THEN
263       -- store SQL error message on message stack for caller
264       OKC_API.SET_MESSAGE( p_app_name     => g_app_name,
265                           p_msg_name     => g_unexpected_error,
266                           p_token1       => g_sqlcode_token,
267                           p_token1_value => sqlcode,
268                           p_token2       => g_sqlerrm_token,
269                           p_token2_value => sqlerrm );
270 
271       -- notify caller of an UNEXPECTED error
272       x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
273 
274   END Validate_Object_Version_Number;
275 
276   ---------------------------------------------------------------------------
277   -- PROCEDURE Validate_Pmr_Id
278   ---------------------------------------------------------------------------
279   -- Start of comments
280   --
281   -- Procedure Name  : Validate_Pmr_Id
282   -- Description     :
283   -- Business Rules  :
284   -- Parameters      :
285   -- Version         : 1.0
286   -- End of comments
287   ---------------------------------------------------------------------------
288   PROCEDURE Validate_Pmr_Id(
289     x_return_status OUT NOCOPY  VARCHAR2,
290     p_cgmv_rec      IN   cgmv_rec_type
291   ) IS
292 
293   l_dummy                 VARCHAR2(1) := '?';
294   l_row_not_found             Boolean := False;
295 
296   -- Cursor For OKL_CGM_PMR_FK - Foreign Key Constraint
297   CURSOR okl_pmrv_pk_csr (p_id IN OKL_CNTX_GRP_PRMTRS_V.pmr_id%TYPE) IS
298   SELECT '1'
299     FROM OKL_PARAMETERS_V
300    WHERE OKL_PARAMETERS_V.id = p_id;
301 
302   BEGIN
303     -- initialize return status
304     x_return_status := OKC_API.G_RET_STS_SUCCESS;
305 
306     IF p_cgmv_rec.cgr_id = OKC_API.G_MISS_NUM OR
307        p_cgmv_rec.cgr_id IS NULL
308     THEN
309       OKC_API.set_message(G_APP_NAME, G_REQUIRED_VALUE,G_COL_NAME_TOKEN,'pmr_id');
310       x_return_status := OKC_API.G_RET_STS_ERROR;
311       RAISE G_EXCEPTION_HALT_VALIDATION;
312     END IF;
313 
314     OPEN okl_pmrv_pk_csr(p_cgmv_rec.pmr_id);
315     FETCH okl_pmrv_pk_csr INTO l_dummy;
316     l_row_not_found := okl_pmrv_pk_csr%NOTFOUND;
317     CLOSE okl_pmrv_pk_csr;
318 
319     IF l_row_not_found then
320       OKC_API.set_message(G_APP_NAME,G_INVALID_VALUE,G_COL_NAME_TOKEN,'pmr_id');
321       x_return_status := OKC_API.G_RET_STS_ERROR;
322     END IF;
323 
324   EXCEPTION
325     WHEN G_EXCEPTION_HALT_VALIDATION THEN
326     -- no processing necessary; validation can continue
327     -- with the next column
328     NULL;
329 
330     WHEN OTHERS THEN
331       -- store SQL error message on message stack for caller
332       OKC_API.SET_MESSAGE(p_app_name     => G_APP_NAME
333                          ,p_msg_name     => G_UNEXPECTED_ERROR
334                          ,p_token1       => G_SQLCODE_TOKEN
335                          ,p_token1_value => SQLCODE
336                          ,p_token2       => G_SQLERRM_TOKEN
337                          ,p_token2_value => SQLERRM);
338 
339       -- notify caller of an UNEXPECTED error
340       x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
341 
342       -- verify that the cursor was closed
343       IF okl_pmrv_pk_csr%ISOPEN THEN
344         CLOSE okl_pmrv_pk_csr;
345       END IF;
346   END Validate_Pmr_Id;
347 
348   ---------------------------------------------------------------------------
349   -- PROCEDURE Validate_Cgr_Id
350   ---------------------------------------------------------------------------
351   -- Start of comments
352   --
353   -- Procedure Name  : Validate_Cgr_Id
354   -- Description     :
355   -- Business Rules  :
356   -- Parameters      :
357   -- Version         : 1.0
358   -- End of comments
359   ---------------------------------------------------------------------------
360   PROCEDURE Validate_Cgr_Id(
361     x_return_status OUT NOCOPY  VARCHAR2,
362     p_cgmv_rec      IN   cgmv_rec_type
363   ) IS
364 
365   l_dummy                 VARCHAR2(1) := '?';
366   l_row_not_found             Boolean := False;
367 
368   -- Cursor For OKL_CGM_CGR_FK - Foreign Key Constraint
369   CURSOR okl_cgrv_pk_csr (p_id IN OKL_CNTX_GRP_PRMTRS_V.cgr_id%TYPE) IS
370   SELECT '1'
371     FROM OKL_CONTEXT_GROUPS_V
372    WHERE OKL_CONTEXT_GROUPS_V.id = p_id;
373 
374   BEGIN
375     -- initialize return status
376     x_return_status := OKC_API.G_RET_STS_SUCCESS;
377 
378     IF p_cgmv_rec.cgr_id = OKC_API.G_MISS_NUM OR
379        p_cgmv_rec.cgr_id IS NULL
380     THEN
381       OKC_API.set_message(G_APP_NAME, G_REQUIRED_VALUE,G_COL_NAME_TOKEN,'cgr_id');
382       x_return_status := OKC_API.G_RET_STS_ERROR;
383       RAISE G_EXCEPTION_HALT_VALIDATION;
384     END IF;
385 
386     OPEN okl_cgrv_pk_csr(p_cgmv_rec.cgr_id);
387     FETCH okl_cgrv_pk_csr INTO l_dummy;
388     l_row_not_found := okl_cgrv_pk_csr%NOTFOUND;
389     CLOSE okl_cgrv_pk_csr;
390 
391     IF l_row_not_found then
392       OKC_API.set_message(G_APP_NAME,G_INVALID_VALUE,G_COL_NAME_TOKEN,'cgr_id');
393       x_return_status := OKC_API.G_RET_STS_ERROR;
394     END IF;
395 
396   EXCEPTION
397     WHEN G_EXCEPTION_HALT_VALIDATION THEN
398     -- no processing necessary; validation can continue
399     -- with the next column
400     NULL;
401 
402     WHEN OTHERS THEN
403       -- store SQL error message on message stack for caller
404       OKC_API.SET_MESSAGE(p_app_name     => G_APP_NAME
405                          ,p_msg_name     => G_UNEXPECTED_ERROR
406                          ,p_token1       => G_SQLCODE_TOKEN
407                          ,p_token1_value => SQLCODE
408                          ,p_token2       => G_SQLERRM_TOKEN
409                          ,p_token2_value => SQLERRM);
410 
411       -- notify caller of an UNEXPECTED error
412       x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
413 
414       -- verify that the cursor was closed
415       IF okl_cgrv_pk_csr%ISOPEN THEN
416         CLOSE okl_cgrv_pk_csr;
417       END IF;
418   END Validate_Cgr_Id;
419 
420 
421 
422   ---------------------------------------------------------------------------
423   -- PROCEDURE Validate_Attributes
424   ---------------------------------------------------------------------------
425   -- Start of comments
426   --
427   -- Procedure Name  : Validate_Attributes
428   -- Description     :
429   -- Business Rules  :
430   -- Parameters      :
431   -- Version         : 1.0
432   -- End of comments
433   ---------------------------------------------------------------------------
434 
435   FUNCTION Validate_Attributes (
436     p_cgmv_rec IN  cgmv_rec_type
437   ) RETURN VARCHAR2 IS
438     x_return_status	VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
439     l_return_status	VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
440   BEGIN
441 
442 
443   	-- call each column-level validation
444 
445 	-- Validate ID
446     IF p_cgmv_rec.id = OKC_API.G_MISS_NUM OR
447        p_cgmv_rec.id IS NULL
448     THEN
449       OKC_API.set_message( G_APP_NAME,
450 	  					  G_REQUIRED_VALUE,
451 						  G_COL_NAME_TOKEN, 'id' );
452       l_return_status := OKC_API.G_RET_STS_ERROR;
453 	END IF;
454 
455 	-- Valid object_version_number
456 	IF ( p_cgmv_rec.object_version_number IS NOT NULL ) AND
457 	( p_cgmv_rec.object_version_number <> OKC_API.G_MISS_NUM ) THEN
458 		Validate_Object_Version_Number( x_return_status, p_cgmv_rec );
459 		IF ( x_return_status <> OKC_API.G_RET_STS_SUCCESS ) THEN
460 			IF ( x_return_status = OKC_API.G_RET_STS_UNEXP_ERROR ) THEN
461 				-- need to leave
462 				l_return_status := x_return_status;
463 				RAISE G_EXCEPTION_HALT_VALIDATION;
464 			ELSE
465 				-- record that there was an error
466 				l_return_status := x_return_status;
467 			END IF;
468 		END IF;
469 	END IF;
470 
471 	-- Valid Cgr_Id
472 	IF ( p_cgmv_rec.cgr_id IS NOT NULL ) AND
473 	( p_cgmv_rec.cgr_id <> OKC_API.G_MISS_NUM ) THEN
474 		Validate_Cgr_Id( x_return_status, p_cgmv_rec );
475 		IF ( x_return_status <> OKC_API.G_RET_STS_SUCCESS ) THEN
476 			IF ( x_return_status = OKC_API.G_RET_STS_UNEXP_ERROR ) THEN
477 				-- need to leave
478 				l_return_status := x_return_status;
479 				RAISE G_EXCEPTION_HALT_VALIDATION;
480 			ELSE
481 				-- record that there was an error
482 				l_return_status := x_return_status;
483 			END IF;
484 		END IF;
485 	END IF;
486 
487 	-- Valid Pmr_Id
488 	IF ( p_cgmv_rec.pmr_id IS NOT NULL ) AND
489 	( p_cgmv_rec.pmr_id <> OKC_API.G_MISS_NUM ) THEN
490 		Validate_Pmr_Id( x_return_status, p_cgmv_rec );
491 		IF ( x_return_status <> OKC_API.G_RET_STS_SUCCESS ) THEN
492 			IF ( x_return_status = OKC_API.G_RET_STS_UNEXP_ERROR ) THEN
493 				-- need to leave
494 				l_return_status := x_return_status;
495 				RAISE G_EXCEPTION_HALT_VALIDATION;
496 			ELSE
497 				-- record that there was an error
498 				l_return_status := x_return_status;
499 			END IF;
500 		END IF;
501 	END IF;
502 
503     RETURN(l_return_status);
504 	EXCEPTION
505     WHEN G_EXCEPTION_HALT_VALIDATION THEN
506        -- just come out with return status
507        NULL;
508        RETURN (l_return_status);
509 
510     WHEN OTHERS THEN
511        -- store SQL error message on message stack for caller
512        OKC_API.SET_MESSAGE(p_app_name         => g_app_name,
513                            p_msg_name         => g_unexpected_error,
514                            p_token1           => g_sqlcode_token,
515                            p_token1_value     => sqlcode,
516                            p_token2           => g_sqlerrm_token,
517                            p_token2_value     => sqlerrm);
518        -- notify caller of an UNEXPECTED error
519        l_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
520        RETURN(l_return_status);
521 
522   END Validate_Attributes;
523 
524 
525 
526 /**  *** SBALASHA001 End ***  **/
527 
528 
529 
530 /**  *** SBALASHA002 Start *** -
531       INFO: hand coded function related to validate_record **/
532 
533 
534   ---------------------------------------------------------------------------
535   -- PROCEDURE Validate_Unique_Dsf_Record
536   ---------------------------------------------------------------------------
537   -- Start of comments
538   --
539   -- Procedure Name  : Validate_Unique_Cgm_Record
540   -- Description     :
541   -- Business Rules  :
542   -- Parameters      :
543   -- Version         : 1.0
544   -- End of comments
545   ---------------------------------------------------------------------------
546   PROCEDURE Validate_Unique_Cgm_Record(
547                                   x_return_status OUT NOCOPY     VARCHAR2,
548                                   p_cgmv_rec      IN      cgmv_rec_type)
549   IS
550 
551   l_return_status         VARCHAR2(1)  := OKC_API.G_RET_STS_SUCCESS;
552   l_unq_tbl               OKC_UTIL.unq_tbl_type;
553   l_dummy                 VARCHAR2(1);
554   l_row_found             Boolean := False;
555   CURSOR c1( p_cgr_id okl_cntx_grp_prmtrs_v.cgr_id%TYPE
556   		 	 , p_pmr_id okl_cntx_grp_prmtrs_v.pmr_id%TYPE
557   		 	 , p_id okl_cntx_grp_prmtrs_v.id%TYPE ) is
558   SELECT 1
559   FROM okl_cntx_grp_prmtrs_v
560   WHERE  p_cgr_id = cgr_id
561   and p_pmr_id = pmr_id
562   and id <> nvl( p_cgmv_rec.id, -9999 );
563 
564   BEGIN
565 
566     -- initialize return status
567     x_return_status := OKC_API.G_RET_STS_SUCCESS;
568 
569     OPEN c1( p_cgmv_rec.cgr_id, p_cgmv_rec.pmr_id, p_cgmv_rec.id );
570     FETCH c1 into l_dummy;
571     l_row_found := c1%FOUND;
572     CLOSE c1;
573     IF l_row_found then
574 		OKC_API.set_message( G_APP_NAME, G_UNQS, G_TABLE_TOKEN, 'Okl_Cntx_Grp_Prmtrs_V' );
575 		x_return_status := OKC_API.G_RET_STS_ERROR;
576     END IF;
577 
578   EXCEPTION
579     WHEN G_EXCEPTION_HALT_VALIDATION THEN
580     -- no processing necessary;  validation can continue
581     -- with the next column
582     NULL;
583 
584     WHEN OTHERS THEN
585       -- store SQL error message on message stack for caller
586       OKC_API.SET_MESSAGE( p_app_name     => g_app_name,
587                           p_msg_name     => g_unexpected_error,
588                           p_token1       => g_sqlcode_token,
589                           p_token1_value => sqlcode,
590                           p_token2       => g_sqlerrm_token,
591                           p_token2_value => sqlerrm );
592 
593       -- notify caller of an UNEXPECTED error
594       x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
595 
596   END Validate_Unique_Cgm_Record;
597 
598 
599   ---------------------------------------------------------------------------
600   -- FUNCTION Validate_Record
601   ---------------------------------------------------------------------------
602   -- Start of comments
603   --
604   -- Procedure Name  : Validate_Record
605   -- Description     :
606   -- Business Rules  :
607   -- Parameters      :
608   -- Version         : 1.0
609   -- End of comments
610   ---------------------------------------------------------------------------
611 
612   FUNCTION Validate_Record (
613     p_cgmv_rec IN cgmv_rec_type
614   ) RETURN VARCHAR2 IS
615     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
616     x_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
617   BEGIN
618 
619 	-- Validate_Unique_Dsf_Record
620 	Validate_Unique_Cgm_Record( x_return_status, p_cgmv_rec );
621 	-- store the highest degree of error
622 	IF ( x_return_status <> OKC_API.G_RET_STS_SUCCESS ) THEN
623 	  IF ( x_return_status <> OKC_API.G_RET_STS_UNEXP_ERROR ) THEN
624 	      -- need to leave
625 	      l_return_status := x_return_status;
626 	      RAISE G_EXCEPTION_HALT_VALIDATION;
627 	      ELSE
628 	      -- record that there was an error
629 	      l_return_status := x_return_status;
630 	  END IF;
631 	END IF;
632 	RETURN( l_return_status );
633 
634   EXCEPTION
635     WHEN G_EXCEPTION_HALT_VALIDATION THEN
636     -- no processing necessary;  validation can continue
637     -- with the next column
638     NULL;
639     RETURN ( l_return_status );
640 
641     WHEN OTHERS THEN
642       -- store SQL error message on message stack for caller
643       OKC_API.SET_MESSAGE( p_app_name     => g_app_name,
644                           p_msg_name     => g_unexpected_error,
645                           p_token1       => g_sqlcode_token,
646                           p_token1_value => sqlcode,
647                           p_token2       => g_sqlerrm_token,
648                           p_token2_value => sqlerrm );
649 
650       -- notify caller of an UNEXPECTED error
651       x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
652 
653   END Validate_Record;
654 
655 
656 /** *** SBALASHA002 End *** **/
657 
658   ---------------------------------------------------------------------------
659   -- PROCEDURE Migrate
660   ---------------------------------------------------------------------------
661   PROCEDURE migrate (
662     p_from	IN cgmv_rec_type,
663     p_to	IN OUT NOCOPY cgm_rec_type
664   ) IS
665   BEGIN
666     p_to.id := p_from.id;
667     p_to.cgr_id := p_from.cgr_id;
668     p_to.pmr_id := p_from.pmr_id;
669     p_to.object_version_number := p_from.object_version_number;
670     p_to.created_by := p_from.created_by;
671     p_to.creation_date := p_from.creation_date;
672     p_to.last_updated_by := p_from.last_updated_by;
673     p_to.last_update_date := p_from.last_update_date;
674     p_to.last_update_login := p_from.last_update_login;
675   END migrate;
676   PROCEDURE migrate (
677     p_from	IN cgm_rec_type,
678     p_to	OUT NOCOPY cgmv_rec_type
679   ) IS
680   BEGIN
681     p_to.id := p_from.id;
682     p_to.cgr_id := p_from.cgr_id;
683     p_to.pmr_id := p_from.pmr_id;
684     p_to.object_version_number := p_from.object_version_number;
685     p_to.created_by := p_from.created_by;
686     p_to.creation_date := p_from.creation_date;
687     p_to.last_updated_by := p_from.last_updated_by;
688     p_to.last_update_date := p_from.last_update_date;
689     p_to.last_update_login := p_from.last_update_login;
690   END migrate;
691 
692   ---------------------------------------------------------------------------
693   -- PROCEDURE validate_row
694   ---------------------------------------------------------------------------
695   --------------------------------------------
696   -- validate_row for:OKL_CNTX_GRP_PRMTRS_V --
697   --------------------------------------------
698   PROCEDURE validate_row(
699     p_api_version                  IN NUMBER,
700     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
701     x_return_status                OUT NOCOPY VARCHAR2,
702     x_msg_count                    OUT NOCOPY NUMBER,
703     x_msg_data                     OUT NOCOPY VARCHAR2,
704     p_cgmv_rec                     IN cgmv_rec_type) IS
705 
706     l_api_version                 CONSTANT NUMBER := 1;
707     l_api_name                     CONSTANT VARCHAR2(30) := 'V_validate_row';
708     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
709     l_cgmv_rec                     cgmv_rec_type := p_cgmv_rec;
710     l_cgm_rec                      cgm_rec_type;
711   BEGIN
712     l_return_status := OKC_API.START_ACTIVITY(l_api_name,
713                                               G_PKG_NAME,
714                                               p_init_msg_list,
715                                               l_api_version,
716                                               p_api_version,
717                                               '_PVT',
718                                               x_return_status);
719     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
720       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
721     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
722       RAISE OKC_API.G_EXCEPTION_ERROR;
723     END IF;
724     --- Validate all non-missing attributes (Item Level Validation)
725     l_return_status := Validate_Attributes(l_cgmv_rec);
726     --- If any errors happen abort API
727     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
728       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
729     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
730       RAISE OKC_API.G_EXCEPTION_ERROR;
731     END IF;
732     l_return_status := Validate_Record(l_cgmv_rec);
733     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
734       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
735     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
736       RAISE OKC_API.G_EXCEPTION_ERROR;
737     END IF;
738     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
739   EXCEPTION
740     WHEN OKC_API.G_EXCEPTION_ERROR THEN
741       x_return_status := OKC_API.HANDLE_EXCEPTIONS
742       (
743         l_api_name,
744         G_PKG_NAME,
745         'OKC_API.G_RET_STS_ERROR',
746         x_msg_count,
747         x_msg_data,
748         '_PVT'
749       );
750     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
751       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
752       (
753         l_api_name,
754         G_PKG_NAME,
755         'OKC_API.G_RET_STS_UNEXP_ERROR',
756         x_msg_count,
757         x_msg_data,
758         '_PVT'
759       );
760     WHEN OTHERS THEN
761       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
762       (
763         l_api_name,
764         G_PKG_NAME,
765         'OTHERS',
766         x_msg_count,
767         x_msg_data,
768         '_PVT'
769       );
770   END validate_row;
771   ------------------------------------------
772   -- PL/SQL TBL validate_row for:CGMV_TBL --
773   ------------------------------------------
774   PROCEDURE validate_row(
775     p_api_version                  IN NUMBER,
776     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
777     x_return_status                OUT NOCOPY VARCHAR2,
778     x_msg_count                    OUT NOCOPY NUMBER,
779     x_msg_data                     OUT NOCOPY VARCHAR2,
780     p_cgmv_tbl                     IN cgmv_tbl_type) IS
781 
782     l_api_version                 CONSTANT NUMBER := 1;
783     l_api_name                     CONSTANT VARCHAR2(30) := 'V_tbl_validate_row';
784     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
785     i                              NUMBER := 0;
786     l_overall_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
787   BEGIN
788     OKC_API.init_msg_list(p_init_msg_list);
789     -- Make sure PL/SQL table has records in it before passing
790     IF (p_cgmv_tbl.COUNT > 0) THEN
791       i := p_cgmv_tbl.FIRST;
792       LOOP
793         validate_row (
794           p_api_version                  => p_api_version,
795           p_init_msg_list                => OKC_API.G_FALSE,
796           x_return_status                => x_return_status,
797           x_msg_count                    => x_msg_count,
798           x_msg_data                     => x_msg_data,
799           p_cgmv_rec                     => p_cgmv_tbl(i));
800 		-- store the highest degree of error
801 		IF x_return_status <> OKC_API.G_RET_STS_SUCCESS THEN
802 			IF l_overall_status <> OKC_API.G_RET_STS_UNEXP_ERROR THEN
803 				l_overall_status := x_return_status;
804 			END IF;
805 		END IF;
806 
807         EXIT WHEN (i = p_cgmv_tbl.LAST);
808         i := p_cgmv_tbl.NEXT(i);
809       END LOOP;
810 	-- return overall status
811 	x_return_status := l_overall_status;
812 
813     END IF;
814   EXCEPTION
815     WHEN OKC_API.G_EXCEPTION_ERROR THEN
816       x_return_status := OKC_API.HANDLE_EXCEPTIONS
817       (
818         l_api_name,
819         G_PKG_NAME,
820         'OKC_API.G_RET_STS_ERROR',
821         x_msg_count,
822         x_msg_data,
823         '_PVT'
824       );
825     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
826       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
827       (
828         l_api_name,
829         G_PKG_NAME,
830         'OKC_API.G_RET_STS_UNEXP_ERROR',
831         x_msg_count,
832         x_msg_data,
833         '_PVT'
834       );
835     WHEN OTHERS THEN
836       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
837       (
838         l_api_name,
839         G_PKG_NAME,
840         'OTHERS',
841         x_msg_count,
842         x_msg_data,
843         '_PVT'
844       );
845   END validate_row;
846 
847   ---------------------------------------------------------------------------
848   -- PROCEDURE insert_row
849   ---------------------------------------------------------------------------
850   ----------------------------------------
851   -- insert_row for:OKL_CNTX_GRP_PRMTRS --
852   ----------------------------------------
853   PROCEDURE insert_row(
854     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
855     x_return_status                OUT NOCOPY VARCHAR2,
856     x_msg_count                    OUT NOCOPY NUMBER,
857     x_msg_data                     OUT NOCOPY VARCHAR2,
858     p_cgm_rec                      IN cgm_rec_type,
859     x_cgm_rec                      OUT NOCOPY cgm_rec_type) IS
860 
861     l_api_version                 CONSTANT NUMBER := 1;
862     l_api_name                     CONSTANT VARCHAR2(30) := 'PRMTRS_insert_row';
863     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
864     l_cgm_rec                      cgm_rec_type := p_cgm_rec;
865     l_def_cgm_rec                  cgm_rec_type;
866     --------------------------------------------
867     -- Set_Attributes for:OKL_CNTX_GRP_PRMTRS --
868     --------------------------------------------
869     FUNCTION Set_Attributes (
870       p_cgm_rec IN  cgm_rec_type,
871       x_cgm_rec OUT NOCOPY cgm_rec_type
872     ) RETURN VARCHAR2 IS
873       l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
874     BEGIN
875       x_cgm_rec := p_cgm_rec;
876       RETURN(l_return_status);
877     END Set_Attributes;
878   BEGIN
879     l_return_status := OKC_API.START_ACTIVITY(l_api_name,
880                                               p_init_msg_list,
881                                               '_PVT',
882                                               x_return_status);
883     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
884       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
885     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
886       RAISE OKC_API.G_EXCEPTION_ERROR;
887     END IF;
888     --- Setting item attributes
889     l_return_status := Set_Attributes(
890       p_cgm_rec,                         -- IN
891       l_cgm_rec);                        -- OUT
892     --- If any errors happen abort API
893     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
894       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
895     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
896       RAISE OKC_API.G_EXCEPTION_ERROR;
897     END IF;
898     INSERT INTO OKL_CNTX_GRP_PRMTRS(
899         id,
900         cgr_id,
901         pmr_id,
902         object_version_number,
903         created_by,
904         creation_date,
905         last_updated_by,
906         last_update_date,
907         last_update_login)
908       VALUES (
909         l_cgm_rec.id,
910         l_cgm_rec.cgr_id,
911         l_cgm_rec.pmr_id,
912         l_cgm_rec.object_version_number,
913         l_cgm_rec.created_by,
914         l_cgm_rec.creation_date,
915         l_cgm_rec.last_updated_by,
916         l_cgm_rec.last_update_date,
917         l_cgm_rec.last_update_login);
918     -- Set OUT values
919     x_cgm_rec := l_cgm_rec;
920     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
921   EXCEPTION
922     WHEN OKC_API.G_EXCEPTION_ERROR THEN
923       x_return_status := OKC_API.HANDLE_EXCEPTIONS
924       (
925         l_api_name,
926         G_PKG_NAME,
927         'OKC_API.G_RET_STS_ERROR',
928         x_msg_count,
929         x_msg_data,
930         '_PVT'
931       );
932     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
933       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
934       (
935         l_api_name,
936         G_PKG_NAME,
937         'OKC_API.G_RET_STS_UNEXP_ERROR',
938         x_msg_count,
939         x_msg_data,
940         '_PVT'
941       );
942     WHEN OTHERS THEN
943       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
944       (
945         l_api_name,
946         G_PKG_NAME,
947         'OTHERS',
948         x_msg_count,
949         x_msg_data,
950         '_PVT'
951       );
952   END insert_row;
953   ------------------------------------------
954   -- insert_row for:OKL_CNTX_GRP_PRMTRS_V --
955   ------------------------------------------
956   PROCEDURE insert_row(
957     p_api_version                  IN NUMBER,
958     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
959     x_return_status                OUT NOCOPY VARCHAR2,
960     x_msg_count                    OUT NOCOPY NUMBER,
961     x_msg_data                     OUT NOCOPY VARCHAR2,
962     p_cgmv_rec                     IN cgmv_rec_type,
963     x_cgmv_rec                     OUT NOCOPY cgmv_rec_type) IS
964 
965     l_api_version                 CONSTANT NUMBER := 1;
966     l_api_name                     CONSTANT VARCHAR2(30) := 'V_insert_row';
967     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
968     l_cgmv_rec                     cgmv_rec_type;
969     l_def_cgmv_rec                 cgmv_rec_type;
970     l_cgm_rec                      cgm_rec_type;
971     lx_cgm_rec                     cgm_rec_type;
972     -------------------------------
973     -- FUNCTION fill_who_columns --
974     -------------------------------
975     FUNCTION fill_who_columns (
976       p_cgmv_rec	IN cgmv_rec_type
977     ) RETURN cgmv_rec_type IS
978       l_cgmv_rec	cgmv_rec_type := p_cgmv_rec;
979     BEGIN
980       l_cgmv_rec.CREATION_DATE := SYSDATE;
981       l_cgmv_rec.CREATED_BY := FND_GLOBAL.USER_ID;
982       l_cgmv_rec.LAST_UPDATE_DATE := l_cgmv_rec.CREATION_DATE;
983       l_cgmv_rec.LAST_UPDATED_BY := FND_GLOBAL.USER_ID;
984       l_cgmv_rec.LAST_UPDATE_LOGIN := FND_GLOBAL.LOGIN_ID;
985       RETURN(l_cgmv_rec);
986     END fill_who_columns;
987     ----------------------------------------------
988     -- Set_Attributes for:OKL_CNTX_GRP_PRMTRS_V --
989     ----------------------------------------------
990     FUNCTION Set_Attributes (
991       p_cgmv_rec IN  cgmv_rec_type,
992       x_cgmv_rec OUT NOCOPY cgmv_rec_type
993     ) RETURN VARCHAR2 IS
994       l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
995     BEGIN
996       x_cgmv_rec := p_cgmv_rec;
997       x_cgmv_rec.OBJECT_VERSION_NUMBER := 1;
998       RETURN(l_return_status);
999     END Set_Attributes;
1000   BEGIN
1001     l_return_status := OKC_API.START_ACTIVITY(l_api_name,
1002                                               G_PKG_NAME,
1003                                               p_init_msg_list,
1004                                               l_api_version,
1005                                               p_api_version,
1006                                               '_PVT',
1007                                               x_return_status);
1008     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1009       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1010     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1011       RAISE OKC_API.G_EXCEPTION_ERROR;
1012     END IF;
1013     l_cgmv_rec := null_out_defaults(p_cgmv_rec);
1014     -- Set primary key value
1015     l_cgmv_rec.ID := get_seq_id;
1016     --- Setting item attributes
1017     l_return_status := Set_Attributes(
1018       l_cgmv_rec,                        -- IN
1019       l_def_cgmv_rec);                   -- OUT
1020     --- If any errors happen abort API
1021     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1022       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1023     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1024       RAISE OKC_API.G_EXCEPTION_ERROR;
1025     END IF;
1026     l_def_cgmv_rec := fill_who_columns(l_def_cgmv_rec);
1027     --- Validate all non-missing attributes (Item Level Validation)
1028     l_return_status := Validate_Attributes(l_def_cgmv_rec);
1029     --- If any errors happen abort API
1030     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1031       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1032     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1033       RAISE OKC_API.G_EXCEPTION_ERROR;
1034     END IF;
1035     l_return_status := Validate_Record(l_def_cgmv_rec);
1036     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1037       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1038     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1039       RAISE OKC_API.G_EXCEPTION_ERROR;
1040     END IF;
1041     --------------------------------------
1042     -- Move VIEW record to "Child" records
1043     --------------------------------------
1044     migrate(l_def_cgmv_rec, l_cgm_rec);
1045     --------------------------------------------
1046     -- Call the INSERT_ROW for each child record
1047     --------------------------------------------
1048     insert_row(
1049       p_init_msg_list,
1050       x_return_status,
1051       x_msg_count,
1052       x_msg_data,
1053       l_cgm_rec,
1054       lx_cgm_rec
1055     );
1056     IF (x_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1057       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1058     ELSIF (x_return_status = OKC_API.G_RET_STS_ERROR) THEN
1059       RAISE OKC_API.G_EXCEPTION_ERROR;
1060     END IF;
1061     migrate(lx_cgm_rec, l_def_cgmv_rec);
1062     -- Set OUT values
1063     x_cgmv_rec := l_def_cgmv_rec;
1064     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
1065   EXCEPTION
1066     WHEN OKC_API.G_EXCEPTION_ERROR THEN
1067       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1068       (
1069         l_api_name,
1070         G_PKG_NAME,
1071         'OKC_API.G_RET_STS_ERROR',
1072         x_msg_count,
1073         x_msg_data,
1074         '_PVT'
1075       );
1076     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1077       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1078       (
1079         l_api_name,
1080         G_PKG_NAME,
1081         'OKC_API.G_RET_STS_UNEXP_ERROR',
1082         x_msg_count,
1083         x_msg_data,
1084         '_PVT'
1085       );
1086     WHEN OTHERS THEN
1087       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1088       (
1089         l_api_name,
1090         G_PKG_NAME,
1091         'OTHERS',
1092         x_msg_count,
1093         x_msg_data,
1094         '_PVT'
1095       );
1096   END insert_row;
1097   ----------------------------------------
1098   -- PL/SQL TBL insert_row for:CGMV_TBL --
1099   ----------------------------------------
1100   PROCEDURE insert_row(
1101     p_api_version                  IN NUMBER,
1102     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
1103     x_return_status                OUT NOCOPY VARCHAR2,
1104     x_msg_count                    OUT NOCOPY NUMBER,
1105     x_msg_data                     OUT NOCOPY VARCHAR2,
1106     p_cgmv_tbl                     IN cgmv_tbl_type,
1107     x_cgmv_tbl                     OUT NOCOPY cgmv_tbl_type) IS
1108 
1109     l_api_version                 CONSTANT NUMBER := 1;
1110     l_api_name                     CONSTANT VARCHAR2(30) := 'V_tbl_insert_row';
1111     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1112     i                              NUMBER := 0;
1113 	l_overall_status				VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1114   BEGIN
1115     OKC_API.init_msg_list(p_init_msg_list);
1116     -- Make sure PL/SQL table has records in it before passing
1117     IF (p_cgmv_tbl.COUNT > 0) THEN
1118       i := p_cgmv_tbl.FIRST;
1119       LOOP
1120         insert_row (
1121           p_api_version                  => p_api_version,
1122           p_init_msg_list                => OKC_API.G_FALSE,
1123           x_return_status                => x_return_status,
1124           x_msg_count                    => x_msg_count,
1125           x_msg_data                     => x_msg_data,
1126           p_cgmv_rec                     => p_cgmv_tbl(i),
1127           x_cgmv_rec                     => x_cgmv_tbl(i));
1128 		-- store the highest degree of error
1129 		IF x_return_status <> OKC_API.G_RET_STS_SUCCESS THEN
1130 			IF l_overall_status <> OKC_API.G_RET_STS_UNEXP_ERROR THEN
1131 				l_overall_status := x_return_status;
1132 			END IF;
1133 		END IF;
1134 
1135         EXIT WHEN (i = p_cgmv_tbl.LAST);
1136         i := p_cgmv_tbl.NEXT(i);
1137       END LOOP;
1138 	-- return overall status
1139 	x_return_status := l_overall_status;
1140 
1141     END IF;
1142   EXCEPTION
1143     WHEN OKC_API.G_EXCEPTION_ERROR THEN
1144       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1145       (
1146         l_api_name,
1147         G_PKG_NAME,
1148         'OKC_API.G_RET_STS_ERROR',
1149         x_msg_count,
1150         x_msg_data,
1151         '_PVT'
1152       );
1153     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1154       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1155       (
1156         l_api_name,
1157         G_PKG_NAME,
1158         'OKC_API.G_RET_STS_UNEXP_ERROR',
1159         x_msg_count,
1160         x_msg_data,
1161         '_PVT'
1162       );
1163     WHEN OTHERS THEN
1164       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1165       (
1166         l_api_name,
1167         G_PKG_NAME,
1168         'OTHERS',
1169         x_msg_count,
1170         x_msg_data,
1171         '_PVT'
1172       );
1173   END insert_row;
1174 
1175   ---------------------------------------------------------------------------
1176   -- PROCEDURE lock_row
1177   ---------------------------------------------------------------------------
1178   --------------------------------------
1179   -- lock_row for:OKL_CNTX_GRP_PRMTRS --
1180   --------------------------------------
1181   PROCEDURE lock_row(
1182     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
1183     x_return_status                OUT NOCOPY VARCHAR2,
1184     x_msg_count                    OUT NOCOPY NUMBER,
1185     x_msg_data                     OUT NOCOPY VARCHAR2,
1186     p_cgm_rec                      IN cgm_rec_type) IS
1187 
1188     E_Resource_Busy               EXCEPTION;
1189     PRAGMA EXCEPTION_INIT(E_Resource_Busy, -00054);
1190     CURSOR lock_csr (p_cgm_rec IN cgm_rec_type) IS
1191     SELECT OBJECT_VERSION_NUMBER
1192       FROM OKL_CNTX_GRP_PRMTRS
1193      WHERE ID = p_cgm_rec.id
1194        AND OBJECT_VERSION_NUMBER = p_cgm_rec.object_version_number
1195     FOR UPDATE OF OBJECT_VERSION_NUMBER NOWAIT;
1196 
1197     CURSOR  lchk_csr (p_cgm_rec IN cgm_rec_type) IS
1198     SELECT OBJECT_VERSION_NUMBER
1199       FROM OKL_CNTX_GRP_PRMTRS
1200     WHERE ID = p_cgm_rec.id;
1201     l_api_version                 CONSTANT NUMBER := 1;
1202     l_api_name                     CONSTANT VARCHAR2(30) := 'PRMTRS_lock_row';
1203     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1204     l_object_version_number       OKL_CNTX_GRP_PRMTRS.OBJECT_VERSION_NUMBER%TYPE;
1205     lc_object_version_number      OKL_CNTX_GRP_PRMTRS.OBJECT_VERSION_NUMBER%TYPE;
1206     l_row_notfound                BOOLEAN := FALSE;
1207     lc_row_notfound               BOOLEAN := FALSE;
1208   BEGIN
1209     l_return_status := OKC_API.START_ACTIVITY(l_api_name,
1210                                               p_init_msg_list,
1211                                               '_PVT',
1212                                               x_return_status);
1213     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1214       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1215     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1216       RAISE OKC_API.G_EXCEPTION_ERROR;
1217     END IF;
1218     BEGIN
1219       OPEN lock_csr(p_cgm_rec);
1220       FETCH lock_csr INTO l_object_version_number;
1221       l_row_notfound := lock_csr%NOTFOUND;
1222       CLOSE lock_csr;
1223     EXCEPTION
1224       WHEN E_Resource_Busy THEN
1225         IF (lock_csr%ISOPEN) THEN
1226           CLOSE lock_csr;
1227         END IF;
1228         OKC_API.set_message(G_FND_APP,G_FORM_UNABLE_TO_RESERVE_REC);
1229         RAISE APP_EXCEPTIONS.RECORD_LOCK_EXCEPTION;
1230     END;
1231 
1232     IF ( l_row_notfound ) THEN
1233       OPEN lchk_csr(p_cgm_rec);
1234       FETCH lchk_csr INTO lc_object_version_number;
1235       lc_row_notfound := lchk_csr%NOTFOUND;
1236       CLOSE lchk_csr;
1237     END IF;
1238     IF (lc_row_notfound) THEN
1239       OKC_API.set_message(G_FND_APP,G_FORM_RECORD_DELETED);
1240       RAISE OKC_API.G_EXCEPTION_ERROR;
1241     ELSIF lc_object_version_number > p_cgm_rec.object_version_number THEN
1242       OKC_API.set_message(G_FND_APP,G_FORM_RECORD_CHANGED);
1243       RAISE OKC_API.G_EXCEPTION_ERROR;
1244     ELSIF lc_object_version_number <> p_cgm_rec.object_version_number THEN
1245       OKC_API.set_message(G_FND_APP,G_FORM_RECORD_CHANGED);
1246       RAISE OKC_API.G_EXCEPTION_ERROR;
1247     ELSIF lc_object_version_number = -1 THEN
1248       OKC_API.set_message(G_APP_NAME,G_RECORD_LOGICALLY_DELETED);
1249       RAISE OKC_API.G_EXCEPTION_ERROR;
1250     END IF;
1251     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
1252   EXCEPTION
1253     WHEN OKC_API.G_EXCEPTION_ERROR THEN
1254       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1255       (
1256         l_api_name,
1257         G_PKG_NAME,
1258         'OKC_API.G_RET_STS_ERROR',
1259         x_msg_count,
1260         x_msg_data,
1261         '_PVT'
1262       );
1263     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1264       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1265       (
1266         l_api_name,
1267         G_PKG_NAME,
1268         'OKC_API.G_RET_STS_UNEXP_ERROR',
1269         x_msg_count,
1270         x_msg_data,
1271         '_PVT'
1272       );
1273     WHEN OTHERS THEN
1274       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1275       (
1276         l_api_name,
1277         G_PKG_NAME,
1278         'OTHERS',
1279         x_msg_count,
1280         x_msg_data,
1281         '_PVT'
1282       );
1283   END lock_row;
1284   ----------------------------------------
1285   -- lock_row for:OKL_CNTX_GRP_PRMTRS_V --
1286   ----------------------------------------
1287   PROCEDURE lock_row(
1288     p_api_version                  IN NUMBER,
1289     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
1290     x_return_status                OUT NOCOPY VARCHAR2,
1291     x_msg_count                    OUT NOCOPY NUMBER,
1292     x_msg_data                     OUT NOCOPY VARCHAR2,
1293     p_cgmv_rec                     IN cgmv_rec_type) IS
1294 
1295     l_api_version                 CONSTANT NUMBER := 1;
1296     l_api_name                     CONSTANT VARCHAR2(30) := 'V_lock_row';
1297     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1298     l_cgm_rec                      cgm_rec_type;
1299   BEGIN
1300     l_return_status := OKC_API.START_ACTIVITY(l_api_name,
1301                                               G_PKG_NAME,
1302                                               p_init_msg_list,
1303                                               l_api_version,
1304                                               p_api_version,
1305                                               '_PVT',
1306                                               x_return_status);
1307     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1308       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1309     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1310       RAISE OKC_API.G_EXCEPTION_ERROR;
1311     END IF;
1312     --------------------------------------
1313     -- Move VIEW record to "Child" records
1314     --------------------------------------
1315     migrate(p_cgmv_rec, l_cgm_rec);
1316     --------------------------------------------
1317     -- Call the LOCK_ROW for each child record
1318     --------------------------------------------
1319     lock_row(
1320       p_init_msg_list,
1321       x_return_status,
1322       x_msg_count,
1323       x_msg_data,
1324       l_cgm_rec
1325     );
1326     IF (x_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1327       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1328     ELSIF (x_return_status = OKC_API.G_RET_STS_ERROR) THEN
1329       RAISE OKC_API.G_EXCEPTION_ERROR;
1330     END IF;
1331     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
1332   EXCEPTION
1333     WHEN OKC_API.G_EXCEPTION_ERROR THEN
1334       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1335       (
1336         l_api_name,
1337         G_PKG_NAME,
1338         'OKC_API.G_RET_STS_ERROR',
1339         x_msg_count,
1340         x_msg_data,
1341         '_PVT'
1342       );
1343     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1344       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1345       (
1346         l_api_name,
1347         G_PKG_NAME,
1348         'OKC_API.G_RET_STS_UNEXP_ERROR',
1349         x_msg_count,
1350         x_msg_data,
1351         '_PVT'
1352       );
1353     WHEN OTHERS THEN
1354       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1355       (
1356         l_api_name,
1357         G_PKG_NAME,
1358         'OTHERS',
1359         x_msg_count,
1360         x_msg_data,
1361         '_PVT'
1362       );
1363   END lock_row;
1364   --------------------------------------
1365   -- PL/SQL TBL lock_row for:CGMV_TBL --
1366   --------------------------------------
1367   PROCEDURE lock_row(
1368     p_api_version                  IN NUMBER,
1369     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
1370     x_return_status                OUT NOCOPY VARCHAR2,
1371     x_msg_count                    OUT NOCOPY NUMBER,
1372     x_msg_data                     OUT NOCOPY VARCHAR2,
1373     p_cgmv_tbl                     IN cgmv_tbl_type) IS
1374 
1375     l_api_version                 CONSTANT NUMBER := 1;
1376     l_api_name                     CONSTANT VARCHAR2(30) := 'V_tbl_lock_row';
1377     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1378     i                              NUMBER := 0;
1379 	l_overall_status				VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1380   BEGIN
1381     OKC_API.init_msg_list(p_init_msg_list);
1382     -- Make sure PL/SQL table has records in it before passing
1383     IF (p_cgmv_tbl.COUNT > 0) THEN
1384       i := p_cgmv_tbl.FIRST;
1385       LOOP
1386         lock_row (
1387           p_api_version                  => p_api_version,
1388           p_init_msg_list                => OKC_API.G_FALSE,
1389           x_return_status                => x_return_status,
1390           x_msg_count                    => x_msg_count,
1391           x_msg_data                     => x_msg_data,
1392           p_cgmv_rec                     => p_cgmv_tbl(i));
1393 		-- store the highest degree of error
1394 		IF x_return_status <> OKC_API.G_RET_STS_SUCCESS THEN
1395 			IF l_overall_status <> OKC_API.G_RET_STS_UNEXP_ERROR THEN
1396 				l_overall_status := x_return_status;
1397 			END IF;
1398 		END IF;
1399 
1400         EXIT WHEN (i = p_cgmv_tbl.LAST);
1401         i := p_cgmv_tbl.NEXT(i);
1402       END LOOP;
1403 	-- return overall status
1404 	x_return_status := l_overall_status;
1405 
1406     END IF;
1407   EXCEPTION
1408     WHEN OKC_API.G_EXCEPTION_ERROR THEN
1409       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1410       (
1411         l_api_name,
1412         G_PKG_NAME,
1413         'OKC_API.G_RET_STS_ERROR',
1414         x_msg_count,
1415         x_msg_data,
1416         '_PVT'
1417       );
1418     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1419       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1420       (
1421         l_api_name,
1422         G_PKG_NAME,
1423         'OKC_API.G_RET_STS_UNEXP_ERROR',
1424         x_msg_count,
1425         x_msg_data,
1426         '_PVT'
1427       );
1428     WHEN OTHERS THEN
1429       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1430       (
1431         l_api_name,
1432         G_PKG_NAME,
1433         'OTHERS',
1434         x_msg_count,
1435         x_msg_data,
1436         '_PVT'
1437       );
1438   END lock_row;
1439 
1440   ---------------------------------------------------------------------------
1441   -- PROCEDURE update_row
1442   ---------------------------------------------------------------------------
1443   ----------------------------------------
1444   -- update_row for:OKL_CNTX_GRP_PRMTRS --
1445   ----------------------------------------
1446   PROCEDURE update_row(
1447     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
1448     x_return_status                OUT NOCOPY VARCHAR2,
1449     x_msg_count                    OUT NOCOPY NUMBER,
1450     x_msg_data                     OUT NOCOPY VARCHAR2,
1451     p_cgm_rec                      IN cgm_rec_type,
1452     x_cgm_rec                      OUT NOCOPY cgm_rec_type) IS
1453 
1454     l_api_version                 CONSTANT NUMBER := 1;
1455     l_api_name                     CONSTANT VARCHAR2(30) := 'PRMTRS_update_row';
1456     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1457     l_cgm_rec                      cgm_rec_type := p_cgm_rec;
1458     l_def_cgm_rec                  cgm_rec_type;
1459     l_row_notfound                 BOOLEAN := TRUE;
1460     ----------------------------------
1461     -- FUNCTION populate_new_record --
1462     ----------------------------------
1463     FUNCTION populate_new_record (
1464       p_cgm_rec	IN cgm_rec_type,
1465       x_cgm_rec	OUT NOCOPY cgm_rec_type
1466     ) RETURN VARCHAR2 IS
1467       l_cgm_rec                      cgm_rec_type;
1468       l_row_notfound                 BOOLEAN := TRUE;
1469       l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1470     BEGIN
1471       x_cgm_rec := p_cgm_rec;
1472       -- Get current database values
1473       l_cgm_rec := get_rec(p_cgm_rec, l_row_notfound);
1474       IF (l_row_notfound) THEN
1475         l_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
1476       END IF;
1477       IF (x_cgm_rec.id = OKC_API.G_MISS_NUM)
1478       THEN
1479         x_cgm_rec.id := l_cgm_rec.id;
1480       END IF;
1481       IF (x_cgm_rec.cgr_id = OKC_API.G_MISS_NUM)
1482       THEN
1483         x_cgm_rec.cgr_id := l_cgm_rec.cgr_id;
1484       END IF;
1485       IF (x_cgm_rec.pmr_id = OKC_API.G_MISS_NUM)
1486       THEN
1487         x_cgm_rec.pmr_id := l_cgm_rec.pmr_id;
1488       END IF;
1489       IF (x_cgm_rec.object_version_number = OKC_API.G_MISS_NUM)
1490       THEN
1491         x_cgm_rec.object_version_number := l_cgm_rec.object_version_number;
1492       END IF;
1493       IF (x_cgm_rec.created_by = OKC_API.G_MISS_NUM)
1494       THEN
1495         x_cgm_rec.created_by := l_cgm_rec.created_by;
1496       END IF;
1497       IF (x_cgm_rec.creation_date = OKC_API.G_MISS_DATE)
1498       THEN
1499         x_cgm_rec.creation_date := l_cgm_rec.creation_date;
1500       END IF;
1501       IF (x_cgm_rec.last_updated_by = OKC_API.G_MISS_NUM)
1502       THEN
1503         x_cgm_rec.last_updated_by := l_cgm_rec.last_updated_by;
1504       END IF;
1505       IF (x_cgm_rec.last_update_date = OKC_API.G_MISS_DATE)
1506       THEN
1507         x_cgm_rec.last_update_date := l_cgm_rec.last_update_date;
1508       END IF;
1509       IF (x_cgm_rec.last_update_login = OKC_API.G_MISS_NUM)
1510       THEN
1511         x_cgm_rec.last_update_login := l_cgm_rec.last_update_login;
1512       END IF;
1513       RETURN(l_return_status);
1514     END populate_new_record;
1515     --------------------------------------------
1516     -- Set_Attributes for:OKL_CNTX_GRP_PRMTRS --
1517     --------------------------------------------
1518     FUNCTION Set_Attributes (
1519       p_cgm_rec IN  cgm_rec_type,
1520       x_cgm_rec OUT NOCOPY cgm_rec_type
1521     ) RETURN VARCHAR2 IS
1522       l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1523     BEGIN
1524       x_cgm_rec := p_cgm_rec;
1525       RETURN(l_return_status);
1526     END Set_Attributes;
1527   BEGIN
1528     l_return_status := OKC_API.START_ACTIVITY(l_api_name,
1529                                               p_init_msg_list,
1530                                               '_PVT',
1531                                               x_return_status);
1532     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1533       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1534     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1535       RAISE OKC_API.G_EXCEPTION_ERROR;
1536     END IF;
1537     --- Setting item attributes
1538     l_return_status := Set_Attributes(
1539       p_cgm_rec,                         -- IN
1540       l_cgm_rec);                        -- OUT
1541     --- If any errors happen abort API
1542     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1543       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1544     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1545       RAISE OKC_API.G_EXCEPTION_ERROR;
1546     END IF;
1547     l_return_status := populate_new_record(l_cgm_rec, l_def_cgm_rec);
1548     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1549       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1550     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1551       RAISE OKC_API.G_EXCEPTION_ERROR;
1552     END IF;
1553     UPDATE  OKL_CNTX_GRP_PRMTRS
1554     SET CGR_ID = l_def_cgm_rec.cgr_id,
1555         PMR_ID = l_def_cgm_rec.pmr_id,
1556         OBJECT_VERSION_NUMBER = l_def_cgm_rec.object_version_number,
1557         CREATED_BY = l_def_cgm_rec.created_by,
1558         CREATION_DATE = l_def_cgm_rec.creation_date,
1559         LAST_UPDATED_BY = l_def_cgm_rec.last_updated_by,
1560         LAST_UPDATE_DATE = l_def_cgm_rec.last_update_date,
1561         LAST_UPDATE_LOGIN = l_def_cgm_rec.last_update_login
1562     WHERE ID = l_def_cgm_rec.id;
1563 
1564     x_cgm_rec := l_def_cgm_rec;
1565     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
1566   EXCEPTION
1567     WHEN OKC_API.G_EXCEPTION_ERROR THEN
1568       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1569       (
1570         l_api_name,
1571         G_PKG_NAME,
1572         'OKC_API.G_RET_STS_ERROR',
1573         x_msg_count,
1574         x_msg_data,
1575         '_PVT'
1576       );
1577     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1578       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1579       (
1580         l_api_name,
1581         G_PKG_NAME,
1582         'OKC_API.G_RET_STS_UNEXP_ERROR',
1583         x_msg_count,
1584         x_msg_data,
1585         '_PVT'
1586       );
1587     WHEN OTHERS THEN
1588       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1589       (
1590         l_api_name,
1591         G_PKG_NAME,
1592         'OTHERS',
1593         x_msg_count,
1594         x_msg_data,
1595         '_PVT'
1596       );
1597   END update_row;
1598   ------------------------------------------
1599   -- update_row for:OKL_CNTX_GRP_PRMTRS_V --
1600   ------------------------------------------
1601   PROCEDURE update_row(
1602     p_api_version                  IN NUMBER,
1603     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
1604     x_return_status                OUT NOCOPY VARCHAR2,
1605     x_msg_count                    OUT NOCOPY NUMBER,
1606     x_msg_data                     OUT NOCOPY VARCHAR2,
1607     p_cgmv_rec                     IN cgmv_rec_type,
1608     x_cgmv_rec                     OUT NOCOPY cgmv_rec_type) IS
1609 
1610     l_api_version                 CONSTANT NUMBER := 1;
1611     l_api_name                     CONSTANT VARCHAR2(30) := 'V_update_row';
1612     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1613     l_cgmv_rec                     cgmv_rec_type := p_cgmv_rec;
1614     l_def_cgmv_rec                 cgmv_rec_type;
1615     l_cgm_rec                      cgm_rec_type;
1616     lx_cgm_rec                     cgm_rec_type;
1617     -------------------------------
1618     -- FUNCTION fill_who_columns --
1619     -------------------------------
1620     FUNCTION fill_who_columns (
1621       p_cgmv_rec	IN cgmv_rec_type
1622     ) RETURN cgmv_rec_type IS
1623       l_cgmv_rec	cgmv_rec_type := p_cgmv_rec;
1624     BEGIN
1625       l_cgmv_rec.LAST_UPDATE_DATE := SYSDATE;
1626       l_cgmv_rec.LAST_UPDATED_BY := FND_GLOBAL.USER_ID;
1627       l_cgmv_rec.LAST_UPDATE_LOGIN := FND_GLOBAL.LOGIN_ID;
1628       RETURN(l_cgmv_rec);
1629     END fill_who_columns;
1630     ----------------------------------
1631     -- FUNCTION populate_new_record --
1632     ----------------------------------
1633     FUNCTION populate_new_record (
1634       p_cgmv_rec	IN cgmv_rec_type,
1635       x_cgmv_rec	OUT NOCOPY cgmv_rec_type
1636     ) RETURN VARCHAR2 IS
1637       l_cgmv_rec                     cgmv_rec_type;
1638       l_row_notfound                 BOOLEAN := TRUE;
1639       l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1640     BEGIN
1641       x_cgmv_rec := p_cgmv_rec;
1642       -- Get current database values
1643       l_cgmv_rec := get_rec(p_cgmv_rec, l_row_notfound);
1644       IF (l_row_notfound) THEN
1645         l_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
1646       END IF;
1647       IF (x_cgmv_rec.id = OKC_API.G_MISS_NUM)
1648       THEN
1649         x_cgmv_rec.id := l_cgmv_rec.id;
1650       END IF;
1651       IF (x_cgmv_rec.object_version_number = OKC_API.G_MISS_NUM)
1652       THEN
1653         x_cgmv_rec.object_version_number := l_cgmv_rec.object_version_number;
1654       END IF;
1655       IF (x_cgmv_rec.cgr_id = OKC_API.G_MISS_NUM)
1656       THEN
1657         x_cgmv_rec.cgr_id := l_cgmv_rec.cgr_id;
1658       END IF;
1659       IF (x_cgmv_rec.pmr_id = OKC_API.G_MISS_NUM)
1660       THEN
1661         x_cgmv_rec.pmr_id := l_cgmv_rec.pmr_id;
1662       END IF;
1663       IF (x_cgmv_rec.created_by = OKC_API.G_MISS_NUM)
1664       THEN
1665         x_cgmv_rec.created_by := l_cgmv_rec.created_by;
1666       END IF;
1667       IF (x_cgmv_rec.creation_date = OKC_API.G_MISS_DATE)
1668       THEN
1669         x_cgmv_rec.creation_date := l_cgmv_rec.creation_date;
1670       END IF;
1671       IF (x_cgmv_rec.last_updated_by = OKC_API.G_MISS_NUM)
1672       THEN
1673         x_cgmv_rec.last_updated_by := l_cgmv_rec.last_updated_by;
1674       END IF;
1675       IF (x_cgmv_rec.last_update_date = OKC_API.G_MISS_DATE)
1676       THEN
1677         x_cgmv_rec.last_update_date := l_cgmv_rec.last_update_date;
1678       END IF;
1679       IF (x_cgmv_rec.last_update_login = OKC_API.G_MISS_NUM)
1680       THEN
1681         x_cgmv_rec.last_update_login := l_cgmv_rec.last_update_login;
1682       END IF;
1683       RETURN(l_return_status);
1684     END populate_new_record;
1685     ----------------------------------------------
1686     -- Set_Attributes for:OKL_CNTX_GRP_PRMTRS_V --
1687     ----------------------------------------------
1688     FUNCTION Set_Attributes (
1689       p_cgmv_rec IN  cgmv_rec_type,
1690       x_cgmv_rec OUT NOCOPY cgmv_rec_type
1691     ) RETURN VARCHAR2 IS
1692       l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1693     BEGIN
1694       x_cgmv_rec := p_cgmv_rec;
1695       x_cgmv_rec.OBJECT_VERSION_NUMBER := NVL(x_cgmv_rec.OBJECT_VERSION_NUMBER, 0) + 1;
1696       RETURN(l_return_status);
1697     END Set_Attributes;
1698   BEGIN
1699     l_return_status := OKC_API.START_ACTIVITY(l_api_name,
1700                                               G_PKG_NAME,
1701                                               p_init_msg_list,
1702                                               l_api_version,
1703                                               p_api_version,
1704                                               '_PVT',
1705                                               x_return_status);
1706     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1707       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1708     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1709       RAISE OKC_API.G_EXCEPTION_ERROR;
1710     END IF;
1711     --- Setting item attributes
1712     l_return_status := Set_Attributes(
1713       p_cgmv_rec,                        -- IN
1714       l_cgmv_rec);                       -- OUT
1715     --- If any errors happen abort API
1716     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1717       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1718     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1719       RAISE OKC_API.G_EXCEPTION_ERROR;
1720     END IF;
1721     l_return_status := populate_new_record(l_cgmv_rec, l_def_cgmv_rec);
1722     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1723       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1724     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1725       RAISE OKC_API.G_EXCEPTION_ERROR;
1726     END IF;
1727     l_def_cgmv_rec := fill_who_columns(l_def_cgmv_rec);
1728     --- Validate all non-missing attributes (Item Level Validation)
1729     l_return_status := Validate_Attributes(l_def_cgmv_rec);
1730     --- If any errors happen abort API
1731     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1732       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1733     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1734       RAISE OKC_API.G_EXCEPTION_ERROR;
1735     END IF;
1736     l_return_status := Validate_Record(l_def_cgmv_rec);
1737     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1738       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1739     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1740       RAISE OKC_API.G_EXCEPTION_ERROR;
1741     END IF;
1742 
1743     --------------------------------------
1744     -- Move VIEW record to "Child" records
1745     --------------------------------------
1746     migrate(l_def_cgmv_rec, l_cgm_rec);
1747     --------------------------------------------
1748     -- Call the UPDATE_ROW for each child record
1749     --------------------------------------------
1750     update_row(
1751       p_init_msg_list,
1752       x_return_status,
1753       x_msg_count,
1754       x_msg_data,
1755       l_cgm_rec,
1756       lx_cgm_rec
1757     );
1758     IF (x_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1759       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1760     ELSIF (x_return_status = OKC_API.G_RET_STS_ERROR) THEN
1761       RAISE OKC_API.G_EXCEPTION_ERROR;
1762     END IF;
1763     migrate(lx_cgm_rec, l_def_cgmv_rec);
1764     x_cgmv_rec := l_def_cgmv_rec;
1765     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
1766   EXCEPTION
1767     WHEN OKC_API.G_EXCEPTION_ERROR THEN
1768       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1769       (
1770         l_api_name,
1771         G_PKG_NAME,
1772         'OKC_API.G_RET_STS_ERROR',
1773         x_msg_count,
1774         x_msg_data,
1775         '_PVT'
1776       );
1777     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1778       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1779       (
1780         l_api_name,
1781         G_PKG_NAME,
1782         'OKC_API.G_RET_STS_UNEXP_ERROR',
1783         x_msg_count,
1784         x_msg_data,
1785         '_PVT'
1786       );
1787     WHEN OTHERS THEN
1788       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1789       (
1790         l_api_name,
1791         G_PKG_NAME,
1792         'OTHERS',
1793         x_msg_count,
1794         x_msg_data,
1795         '_PVT'
1796       );
1797   END update_row;
1798   ----------------------------------------
1799   -- PL/SQL TBL update_row for:CGMV_TBL --
1800   ----------------------------------------
1801   PROCEDURE update_row(
1802     p_api_version                  IN NUMBER,
1803     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
1804     x_return_status                OUT NOCOPY VARCHAR2,
1805     x_msg_count                    OUT NOCOPY NUMBER,
1806     x_msg_data                     OUT NOCOPY VARCHAR2,
1807     p_cgmv_tbl                     IN cgmv_tbl_type,
1808     x_cgmv_tbl                     OUT NOCOPY cgmv_tbl_type) IS
1809 
1810     l_api_version                 CONSTANT NUMBER := 1;
1811     l_api_name                     CONSTANT VARCHAR2(30) := 'V_tbl_update_row';
1812     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1813     i                              NUMBER := 0;
1814 	l_overall_status				VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1815   BEGIN
1816     OKC_API.init_msg_list(p_init_msg_list);
1817     -- Make sure PL/SQL table has records in it before passing
1818     IF (p_cgmv_tbl.COUNT > 0) THEN
1819       i := p_cgmv_tbl.FIRST;
1820       LOOP
1821         update_row (
1822           p_api_version                  => p_api_version,
1823           p_init_msg_list                => OKC_API.G_FALSE,
1824           x_return_status                => x_return_status,
1825           x_msg_count                    => x_msg_count,
1826           x_msg_data                     => x_msg_data,
1827           p_cgmv_rec                     => p_cgmv_tbl(i),
1828           x_cgmv_rec                     => x_cgmv_tbl(i));
1829 		-- store the highest degree of error
1830 		IF x_return_status <> OKC_API.G_RET_STS_SUCCESS THEN
1831 			IF l_overall_status <> OKC_API.G_RET_STS_UNEXP_ERROR THEN
1832 				l_overall_status := x_return_status;
1833 			END IF;
1834 		END IF;
1835 
1836         EXIT WHEN (i = p_cgmv_tbl.LAST);
1837         i := p_cgmv_tbl.NEXT(i);
1838       END LOOP;
1839 	-- return overall status
1840 	x_return_status := l_overall_status;
1841 
1842     END IF;
1843   EXCEPTION
1844     WHEN OKC_API.G_EXCEPTION_ERROR THEN
1845       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1846       (
1847         l_api_name,
1848         G_PKG_NAME,
1849         'OKC_API.G_RET_STS_ERROR',
1850         x_msg_count,
1851         x_msg_data,
1852         '_PVT'
1853       );
1854     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1855       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1856       (
1857         l_api_name,
1858         G_PKG_NAME,
1859         'OKC_API.G_RET_STS_UNEXP_ERROR',
1860         x_msg_count,
1861         x_msg_data,
1862         '_PVT'
1863       );
1864     WHEN OTHERS THEN
1865       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1866       (
1867         l_api_name,
1868         G_PKG_NAME,
1869         'OTHERS',
1870         x_msg_count,
1871         x_msg_data,
1872         '_PVT'
1873       );
1874   END update_row;
1875 
1876   ---------------------------------------------------------------------------
1877   -- PROCEDURE delete_row
1878   ---------------------------------------------------------------------------
1879   ----------------------------------------
1880   -- delete_row for:OKL_CNTX_GRP_PRMTRS --
1881   ----------------------------------------
1882   PROCEDURE delete_row(
1883     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
1884     x_return_status                OUT NOCOPY VARCHAR2,
1885     x_msg_count                    OUT NOCOPY NUMBER,
1886     x_msg_data                     OUT NOCOPY VARCHAR2,
1887     p_cgm_rec                      IN cgm_rec_type) IS
1888 
1889     l_api_version                 CONSTANT NUMBER := 1;
1890     l_api_name                     CONSTANT VARCHAR2(30) := 'PRMTRS_delete_row';
1891     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1892     l_cgm_rec                      cgm_rec_type:= p_cgm_rec;
1893     l_row_notfound                 BOOLEAN := TRUE;
1894   BEGIN
1895     l_return_status := OKC_API.START_ACTIVITY(l_api_name,
1896                                               p_init_msg_list,
1897                                               '_PVT',
1898                                               x_return_status);
1899     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1900       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1901     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1902       RAISE OKC_API.G_EXCEPTION_ERROR;
1903     END IF;
1904     DELETE FROM OKL_CNTX_GRP_PRMTRS
1905      WHERE ID = l_cgm_rec.id;
1906 
1907     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
1908   EXCEPTION
1909     WHEN OKC_API.G_EXCEPTION_ERROR THEN
1910       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1911       (
1912         l_api_name,
1913         G_PKG_NAME,
1914         'OKC_API.G_RET_STS_ERROR',
1915         x_msg_count,
1916         x_msg_data,
1917         '_PVT'
1918       );
1919     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1920       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1921       (
1922         l_api_name,
1923         G_PKG_NAME,
1924         'OKC_API.G_RET_STS_UNEXP_ERROR',
1925         x_msg_count,
1926         x_msg_data,
1927         '_PVT'
1928       );
1929     WHEN OTHERS THEN
1930       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1931       (
1932         l_api_name,
1933         G_PKG_NAME,
1934         'OTHERS',
1935         x_msg_count,
1936         x_msg_data,
1937         '_PVT'
1938       );
1939   END delete_row;
1940   ------------------------------------------
1941   -- delete_row for:OKL_CNTX_GRP_PRMTRS_V --
1942   ------------------------------------------
1943   PROCEDURE delete_row(
1944     p_api_version                  IN NUMBER,
1945     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
1946     x_return_status                OUT NOCOPY VARCHAR2,
1947     x_msg_count                    OUT NOCOPY NUMBER,
1948     x_msg_data                     OUT NOCOPY VARCHAR2,
1949     p_cgmv_rec                     IN cgmv_rec_type) IS
1950 
1951     l_api_version                 CONSTANT NUMBER := 1;
1952     l_api_name                     CONSTANT VARCHAR2(30) := 'V_delete_row';
1953     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1954     l_cgmv_rec                     cgmv_rec_type := p_cgmv_rec;
1955     l_cgm_rec                      cgm_rec_type;
1956   BEGIN
1957     l_return_status := OKC_API.START_ACTIVITY(l_api_name,
1958                                               G_PKG_NAME,
1959                                               p_init_msg_list,
1960                                               l_api_version,
1961                                               p_api_version,
1962                                               '_PVT',
1963                                               x_return_status);
1964     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1965       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1966     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1967       RAISE OKC_API.G_EXCEPTION_ERROR;
1968     END IF;
1969     --------------------------------------
1970     -- Move VIEW record to "Child" records
1971     --------------------------------------
1972     migrate(l_cgmv_rec, l_cgm_rec);
1973     --------------------------------------------
1974     -- Call the DELETE_ROW for each child record
1975     --------------------------------------------
1976     delete_row(
1977       p_init_msg_list,
1978       x_return_status,
1979       x_msg_count,
1980       x_msg_data,
1981       l_cgm_rec
1982     );
1983     IF (x_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1984       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1985     ELSIF (x_return_status = OKC_API.G_RET_STS_ERROR) THEN
1986       RAISE OKC_API.G_EXCEPTION_ERROR;
1987     END IF;
1988     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
1989   EXCEPTION
1990     WHEN OKC_API.G_EXCEPTION_ERROR THEN
1991       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1992       (
1993         l_api_name,
1994         G_PKG_NAME,
1995         'OKC_API.G_RET_STS_ERROR',
1996         x_msg_count,
1997         x_msg_data,
1998         '_PVT'
1999       );
2000     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
2001       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2002       (
2003         l_api_name,
2004         G_PKG_NAME,
2005         'OKC_API.G_RET_STS_UNEXP_ERROR',
2006         x_msg_count,
2007         x_msg_data,
2008         '_PVT'
2009       );
2010     WHEN OTHERS THEN
2011       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2012       (
2013         l_api_name,
2014         G_PKG_NAME,
2015         'OTHERS',
2016         x_msg_count,
2017         x_msg_data,
2018         '_PVT'
2019       );
2020   END delete_row;
2021   ----------------------------------------
2022   -- PL/SQL TBL delete_row for:CGMV_TBL --
2023   ----------------------------------------
2024   PROCEDURE delete_row(
2025     p_api_version                  IN NUMBER,
2026     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
2027     x_return_status                OUT NOCOPY VARCHAR2,
2028     x_msg_count                    OUT NOCOPY NUMBER,
2029     x_msg_data                     OUT NOCOPY VARCHAR2,
2030     p_cgmv_tbl                     IN cgmv_tbl_type) IS
2031 
2032     l_api_version                 CONSTANT NUMBER := 1;
2033     l_api_name                     CONSTANT VARCHAR2(30) := 'V_tbl_delete_row';
2034     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
2035     i                              NUMBER := 0;
2036 	l_overall_status				VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
2037   BEGIN
2038     OKC_API.init_msg_list(p_init_msg_list);
2039     -- Make sure PL/SQL table has records in it before passing
2040     IF (p_cgmv_tbl.COUNT > 0) THEN
2041       i := p_cgmv_tbl.FIRST;
2042       LOOP
2043         delete_row (
2044           p_api_version                  => p_api_version,
2045           p_init_msg_list                => OKC_API.G_FALSE,
2046           x_return_status                => x_return_status,
2047           x_msg_count                    => x_msg_count,
2048           x_msg_data                     => x_msg_data,
2049           p_cgmv_rec                     => p_cgmv_tbl(i));
2050 		-- store the highest degree of error
2051 		IF x_return_status <> OKC_API.G_RET_STS_SUCCESS THEN
2052 			IF l_overall_status <> OKC_API.G_RET_STS_UNEXP_ERROR THEN
2053 				l_overall_status := x_return_status;
2054 			END IF;
2055 		END IF;
2056 
2057         EXIT WHEN (i = p_cgmv_tbl.LAST);
2058         i := p_cgmv_tbl.NEXT(i);
2059       END LOOP;
2060 	-- return overall status
2061 	x_return_status := l_overall_status;
2062 
2063     END IF;
2064   EXCEPTION
2065     WHEN OKC_API.G_EXCEPTION_ERROR THEN
2066       x_return_status := OKC_API.HANDLE_EXCEPTIONS
2067       (
2068         l_api_name,
2069         G_PKG_NAME,
2070         'OKC_API.G_RET_STS_ERROR',
2071         x_msg_count,
2072         x_msg_data,
2073         '_PVT'
2074       );
2075     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
2076       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2077       (
2078         l_api_name,
2079         G_PKG_NAME,
2080         'OKC_API.G_RET_STS_UNEXP_ERROR',
2081         x_msg_count,
2082         x_msg_data,
2083         '_PVT'
2084       );
2085     WHEN OTHERS THEN
2086       x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2087       (
2088         l_api_name,
2089         G_PKG_NAME,
2090         'OTHERS',
2091         x_msg_count,
2092         x_msg_data,
2093         '_PVT'
2094       );
2095   END delete_row;
2096 
2097  ----------------------------------------
2098  -- Procedure LOAD_SEED_ROW
2099  ----------------------------------------
2100 
2101  PROCEDURE LOAD_SEED_ROW(
2102   	 p_CNTX_GRP_PRMTR_ID      IN  VARCHAR2,
2103  	 p_CGR_ID                 IN  VARCHAR2,
2104  	 p_PMR_ID                 IN  VARCHAR2,
2105  	 p_OBJECT_VERSION_NUMBER  IN  VARCHAR2,
2106  	 p_OWNER                  IN  VARCHAR2,
2107  	 p_LAST_UPDATE_DATE       IN  VARCHAR2)IS
2108 
2109     id        NUMBER;
2110     f_luby    NUMBER;  -- entity owner in file
2111     f_ludate  DATE;    -- entity update date in file
2112     db_luby   NUMBER;  -- entity owner in db
2113     db_ludate DATE;    -- entity update date in db
2114 
2115   BEGIN
2116     -- Translate owner to file_last_updated_by
2117     f_luby := fnd_load_util.owner_id(p_owner);
2118     -- Translate char last_update_date to date
2119     f_ludate := nvl(to_date(p_last_update_date, 'YYYY/MM/DD'), sysdate);
2120     BEGIN
2121      SELECT ID , LAST_UPDATED_BY, LAST_UPDATE_DATE
2122      into id, db_luby, db_ludate
2123      from OKL_CNTX_GRP_PRMTRS
2124      where ID = p_cntx_grp_prmtr_id;
2125 
2126      IF(fnd_load_util.upload_test(f_luby, f_ludate, db_luby,
2127                                   db_ludate, '')) then
2128         UPDATE OKL_CNTX_GRP_PRMTRS
2129         SET
2130           cgr_id = TO_NUMBER(p_cgr_id),
2131           pmr_id = TO_NUMBER(p_pmr_id),
2132           object_version_number = TO_NUMBER(p_object_version_number),
2133           last_update_date = f_ludate,
2134           last_updated_by = f_luby,
2135           last_update_login = 0
2136         WHERE id = TO_NUMBER(p_cntx_grp_prmtr_id);
2137       END IF;
2138      END;
2139   	EXCEPTION
2140   	  WHEN NO_DATA_FOUND THEN
2141   	      INSERT INTO OKL_CNTX_GRP_PRMTRS
2142           (
2143             ID,
2144             CGR_ID,
2145             PMR_ID,
2146             OBJECT_VERSION_NUMBER,
2147             CREATED_BY,
2148             CREATION_DATE,
2149             LAST_UPDATED_BY,
2150             LAST_UPDATE_DATE,
2151             LAST_UPDATE_LOGIN
2152 		   )
2153            VALUES
2154            (TO_NUMBER(p_cntx_grp_prmtr_id),
2155             TO_NUMBER(p_cgr_id),
2156             TO_NUMBER(p_pmr_id),
2157             TO_NUMBER(p_object_version_number),
2158             f_luby,
2159             f_ludate,
2160             f_luby,
2161             f_ludate,
2162             0);
2163 
2164  END LOAD_SEED_ROW;
2165 
2166 END OKL_CGM_PVT;