DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_INCOMPATIBILITY_RULES_PKG

Source


1 package body HR_INCOMPATIBILITY_RULES_PKG as
2 /* $Header: hrwirlct.pkb 115.2 2002/12/11 11:17:12 raranjan noship $ */
3 procedure INSERT_ROW (
4   X_ROWID in out nocopy VARCHAR2,
5   X_FROM_NAV_UNIT_ID in NUMBER,
6   X_TO_NAV_UNIT_ID in NUMBER
7 ) is
8   cursor C is select ROWID from HR_INCOMPATIBILITY_RULES
9     where FROM_NAV_UNIT_ID = X_FROM_NAV_UNIT_ID
10     and TO_NAV_UNIT_ID = X_TO_NAV_UNIT_ID
11     ;
12 begin
13   insert into HR_INCOMPATIBILITY_RULES (
14     FROM_NAV_UNIT_ID,
15     TO_NAV_UNIT_ID
16   ) values (
17     X_FROM_NAV_UNIT_ID,
18     X_TO_NAV_UNIT_ID);
19 
20   open c;
21   fetch c into X_ROWID;
22   if (c%notfound) then
23     close c;
24     raise no_data_found;
25   end if;
26   close c;
27 
28 end INSERT_ROW;
29 
30 procedure LOCK_ROW (
31   X_FROM_NAV_UNIT_ID in NUMBER,
32   X_TO_NAV_UNIT_ID in NUMBER
33 ) is
34   cursor c1 is select
35       TO_NAV_UNIT_ID
36     from HR_INCOMPATIBILITY_RULES
37     where FROM_NAV_UNIT_ID = X_FROM_NAV_UNIT_ID
38     and TO_NAV_UNIT_ID = X_TO_NAV_UNIT_ID
39     for update of FROM_NAV_UNIT_ID nowait;
40 begin
41   for tlinfo in c1 loop
42       if (    (tlinfo.TO_NAV_UNIT_ID = X_TO_NAV_UNIT_ID)
43       ) then
44         null;
45       else
46         fnd_message.set_name('FND', 'FORM_RECORD_CHANGED');
47         app_exception.raise_exception;
48       end if;
49   end loop;
50   return;
51 end LOCK_ROW;
52 
53 procedure UPDATE_ROW (
54   X_FROM_NAV_UNIT_ID in NUMBER,
55   X_TO_NAV_UNIT_ID in NUMBER
56 ) is
57 begin
58   update HR_INCOMPATIBILITY_RULES set
59     TO_NAV_UNIT_ID = X_TO_NAV_UNIT_ID
60   where FROM_NAV_UNIT_ID = X_FROM_NAV_UNIT_ID
61   and TO_NAV_UNIT_ID = X_TO_NAV_UNIT_ID;
62 
63   if (sql%notfound) then
64     raise no_data_found;
65   end if;
66 end UPDATE_ROW;
67 
68 procedure DELETE_ROW (
69   X_FROM_NAV_UNIT_ID in NUMBER,
70   X_TO_NAV_UNIT_ID in NUMBER
71 ) is
72 begin
73   delete from HR_INCOMPATIBILITY_RULES
74   where FROM_NAV_UNIT_ID = X_FROM_NAV_UNIT_ID
75   and TO_NAV_UNIT_ID = X_TO_NAV_UNIT_ID;
76 
77   if (sql%notfound) then
78     raise no_data_found;
79   end if;
80 
81 end DELETE_ROW;
82 
83 procedure LOAD_ROW(
84   X_FROM_FORM_NAME in VARCHAR2,
85   X_FROM_BLOCK_NAME in VARCHAR2,
86   X_TO_FORM_NAME in VARCHAR2,
87   X_TO_BLOCK_NAME in VARCHAR2,
88   X_NAV_FLAG  in varchar2
89 ) is
90 X_ROWID VARCHAR2(30);
91 X_FROM_NAV_UNIT_ID NUMBER;
92 X_TO_NAV_UNIT_ID NUMBER;
93 l_flag varchar2(1) := 'Y';
94 begin
95 
96 -- Note that for incompatibility rules, the upload will fail if either
97 -- of the nav_unit_id's have not been extracted in the download or are
98 -- not already present on the remote site.  This can happen because a
99 -- navigation unit can exist across taskflows and therefore need not
100 -- be extracted for a particular taskflow.  However, to ensure that
101 -- this does not stop the data upload on the remote site, the uploader
102 -- traps and surpresses any error raised because of this.  Since the
103 -- downloader downloads for the occurrence of navigation unit in both
104 -- from and to nav_unit_id columns, the relevant records will get
105 -- populated when the other navigation unit is being loaded.
106 -- x_nav_flag is used to raise an application error if no data is
107 -- found when 'to' navigation units are being handled.  The l_flag
108 -- is used to surpress errors when 'from' navigtion units are being
109 -- handled.
110 
111   if hr_workflows_pkg.g_load_taskflow <> 'N' then
112 
113     l_flag := 'Y';
114 
115     begin
116 
117       select NAV_UNIT_ID
118       into X_FROM_NAV_UNIT_ID
119       from HR_NAVIGATION_UNITS
120       where FORM_NAME = X_FROM_FORM_NAME
121       and nvl(BLOCK_NAME,hr_api.g_varchar2)  = nvl(X_FROM_BLOCK_NAME,hr_api.g_varchar2);
122 
123     exception
124       when no_data_found then
125         if x_nav_flag = 'FROM' then
126           raise;
127         else
128           l_flag := 'N';
129         end if;
130     end;
131 
132 
133     begin
134 
135       select NAV_UNIT_ID
136       into X_TO_NAV_UNIT_ID
137       from HR_NAVIGATION_UNITS
138       where FORM_NAME = X_TO_FORM_NAME
139       and nvl(BLOCK_NAME,hr_api.g_varchar2)  = nvl(X_TO_BLOCK_NAME,hr_api.g_varchar2);
140 
141     exception
142       when no_data_found then
143         if x_nav_flag = 'TO' then
144           raise;
145         else
146           l_flag := 'N';
147         end if;
148     end;
149 
150     if l_flag = 'Y' then
151 
152       begin
153         UPDATE_ROW(
154           X_FROM_NAV_UNIT_ID,
155           X_TO_NAV_UNIT_ID
156         );
157       exception
158           when no_data_found then
159             INSERT_ROW(
160               X_ROWID,
161               X_FROM_NAV_UNIT_ID,
162               X_TO_NAV_UNIT_ID
163               );
164       end;
165 
166     end if;
167 
168   end if;
169 
170 end LOAD_ROW;
171 
172 end HR_INCOMPATIBILITY_RULES_PKG;