DBA Data[Home] [Help]

PACKAGE BODY: APPS.FND_SECURITY_GROUPS_API

Source


1 package body Fnd_Security_Groups_Api as
2 /* $Header: AFSCGPAB.pls 115.4 99/07/16 23:28:29 porting sh $ */
3 
4 --
5 -- Generic_Error (Internal)
6 --
7 -- Set error message and raise exception for unexpected sql errors.
8 --
9 procedure Generic_Error(
10   routine in varchar2,
11   errcode in number,
12   errmsg in varchar2)
13 is
14 begin
15     fnd_message.set_name('FND', 'SQL_PLSQL_ERROR');
16     fnd_message.set_token('ROUTINE', routine);
17     fnd_message.set_token('ERRNO', errcode);
18     fnd_message.set_token('REASON', errmsg);
19     app_exception.raise_exception;
20 end;
21 
22 --
23 -- Id_Exists
24 --   Check if security group with given id exists
25 -- IN
26 --   security_group_id - Id number of security group
27 -- RETURN
28 --   TRUE if security group exists with given name
29 --
30 function Id_Exists(
31   security_group_id in number)
32 return boolean
33 is
34   dummy number;
35 begin
36   select count(1)
37   into dummy
38   from FND_SECURITY_GROUPS
39   where SECURITY_GROUP_ID = Id_Exists.security_group_id;
40 
41   return(TRUE);
42 exception
43   when no_data_found then
44     return(FALSE);
45   when others then
46     Generic_Error('FND_SECURITY_GROUPS_API.ID_EXISTS',
47         sqlcode, sqlerrm);
48 end Id_Exists;
49 
50 --
51 -- Key_Exists
52 --   Check if security group with given key exists
53 -- IN
54 --   security_group_key - internal name of security group
55 -- RETURN
56 --   TRUE if security group exists with given name
57 --
58 function Key_Exists(
59   security_group_key in varchar2)
60 return boolean
61 is
62   dummy number;
63 begin
64   select 1
65   into dummy
66   from FND_SECURITY_GROUPS
67   where SECURITY_GROUP_KEY = Key_Exists.security_group_key;
68 
69   return(TRUE);
70 exception
71   when no_data_found then
72     return(FALSE);
73   when others then
74     Generic_Error('FND_SECURITY_GROUPS_API.KEY_EXISTS',
75         sqlcode, sqlerrm);
76 end Key_Exists;
77 
78 --
79 -- Name_Exists
80 --   Check if security group with given username exists
81 -- IN
82 --   security_group_name - user name of security group
83 -- RETURN
84 --   TRUE if security group exists with given username
85 --
86 function Name_Exists(
87   security_group_name in varchar2)
88 return boolean
89 is
90   dummy number;
91 begin
92   select 1
93   into dummy
94   from FND_SECURITY_GROUPS_VL
95   where SECURITY_GROUP_NAME = Name_Exists.security_group_name;
96 
97   return(TRUE);
98 exception
99   when no_data_found then
100     return(FALSE);
101   when others then
102     Generic_Error('FND_SECURITY_GROUPS_API.NAME_EXISTS',
103         sqlcode, sqlerrm);
104 end Name_Exists;
105 
106 --
107 -- Create_Group
108 --   Create a new security group
109 -- IN
110 --   security_group_key - internal name of security group
111 --   security_group_name - user name of security group
112 --   description - security group description
113 -- RETURNS
114 --   security_group_id of new security group created
115 --   Raise exception if any errors encountered.
116 --
117 function Create_Group(
118   security_group_key in varchar2,
119   security_group_name in varchar2,
120   description in varchar2)
121 return number
122 is
123   security_group_id number;
124   row_id varchar2(64);
125 begin
126   -- Pull of a new id from sequence
127   select FND_SECURITY_GROUPS_S.NEXTVAL
128   into security_group_id
129   from SYS.DUAL;
130 
131   -- Insert new row in security groups
132   Fnd_Security_Groups_Pkg.Insert_Row(
133     row_id,
134     security_group_id,
135     security_group_key,
136     security_group_name,
137     description,
138     sysdate,
139     Fnd_Global.User_Id,
140     sysdate,
141     Fnd_Global.User_Id,
142     Fnd_Global.Login_Id);
143 
144   return security_group_id;
145 exception
146   when others then
147     Generic_Error('FND_SECURITY_GROUPS_API.CREATE_GROUP',
148         sqlcode, sqlerrm);
149 end Create_Group;
150 
151 --
152 -- Update_Group
153 --   Update values in existing security group
154 -- IN
155 --   security_group_key -  internal name of security group to update
156 --   security_group_name - NEW user name of security group
157 --   description - NEW security group description
158 --
159 procedure Update_Group(
160   security_group_key in varchar2,
161   security_group_name in varchar2,
162   description in varchar2)
163 is
164   security_group_id number;
165 begin
166   -- Get id of group.
167   -- Allow no_data_found error to trickle up.
168   select FSG.SECURITY_GROUP_ID
169   into security_group_id
170   from FND_SECURITY_GROUPS FSG
171   where FSG.SECURITY_GROUP_KEY = Update_Group.security_group_key;
172 
173   Fnd_Security_Groups_Pkg.Update_Row(
174     security_group_id,
175     security_group_key,
176     security_group_name,
177     description,
178     sysdate,
179     Fnd_Global.User_Id,
180     Fnd_Global.Login_Id);
181 exception
182   when others then
183     Generic_Error('FND_SECURITY_GROUPS_API.UPDATE_GROUP',
184         sqlcode, sqlerrm);
185 end Update_Group;
186 
187 end Fnd_Security_Groups_Api;