DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_QSN_SHD

Source


1 Package Body hr_qsn_shd as
2 /* $Header: hrqsnrhi.pkb 120.6.12020000.2 2013/01/07 09:25:26 venksund ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)  := '  hr_qsn_shd.';  -- Global package name
9 --
10 --
11 -- ----------------------------------------------------------------------------
12 -- |---------------------------< constraint_error >---------------------------|
13 -- ----------------------------------------------------------------------------
14 Procedure constraint_error
15             (p_constraint_name in all_constraints.constraint_name%TYPE) Is
16 --
17   l_proc   varchar2(72) := g_package||'constraint_error';
18 --
19 Begin
20   hr_utility.set_location('Entering:'||l_proc, 5);
21   --
22   If (p_constraint_name = 'HR_QUESTIONNAIRES_FK') Then
23     fnd_message.set_name('PER','PER_52409_QSN_INVAL_BUS_GRP_ID');
24     fnd_message.raise_error;
25   ElsIf (p_constraint_name = 'HR_QUESTIONNAIRES_PK') Then
26     -- Unlikely to fail
27     fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
28     fnd_message.set_token('PROCEDURE',l_proc);
29     fnd_message.set_token('STEP','10');
30     fnd_message.raise_error;
31   ElsIf (p_constraint_name = 'HR_QUESTIONNAIRES_UK1') Then
32     fnd_message.set_name('PER', 'PER_52410_QSN_NAME_NOT_UNIQUE');
33     fnd_message.raise_error;
34   ElsIf (p_constraint_name = 'HR_QUEST_AVAILABLE_FLAG_CHK') Then
35     fnd_message.set_name('PER', 'PER_52411_QSN_AVAIL_FLAG_INVAL');
36     fnd_message.raise_error;
37   Else
38     hr_utility.set_message('PER', 'HR_7877_API_INVALID_CONSTRAINT');
39     hr_utility.set_message_token('PROCEDURE', l_proc);
40     hr_utility.set_message_token('CONSTRAINT_NAME', p_constraint_name);
41     hr_utility.raise_error;
42   End If;
43   --
44   hr_utility.set_location(' Leaving:'||l_proc, 10);
45 End constraint_error;
46 --
47 -- ----------------------------------------------------------------------------
48 -- |-----------------------------< api_updating >-----------------------------|
49 -- ----------------------------------------------------------------------------
50 Function api_updating
51   (
52   p_questionnaire_template_id          in number,
53   p_object_version_number              in number
54   )      Return Boolean Is
55 --
56   --
57   -- Cursor selects the 'current' row from the HR Schema
58   --
59   Cursor C_Sel1 is
60     select
61     questionnaire_template_id,
62   name,
63   text,
64   available_flag,
65   business_group_id,
66   quest_type_code,
67   object_version_number
68     from  hr_questionnaires
69     where  questionnaire_template_id = p_questionnaire_template_id;
70 --
71   l_proc  varchar2(72)  := g_package||'api_updating';
72   l_fct_ret  boolean;
73 --
74 Begin
75   hr_utility.set_location('Entering:'||l_proc, 5);
76   --
77   If (
78   p_questionnaire_template_id is null and
79   p_object_version_number is null
80      ) Then
81     --
82     -- One of the primary key arguments is null therefore we must
83     -- set the returning function value to false
84     --
85     l_fct_ret := false;
86   Else
87     If (
88   p_questionnaire_template_id = g_old_rec.questionnaire_template_id and
89   p_object_version_number = g_old_rec.object_version_number
90        ) Then
91       hr_utility.set_location(l_proc, 10);
92       --
93       -- The g_old_rec is current therefore we must
94       -- set the returning function to true
95       --
96       l_fct_ret := true;
97     Else
98       --
99       -- Select the current row into g_old_rec
100       --
101       Open C_Sel1;
102       Fetch C_Sel1 Into g_old_rec;
103       If C_Sel1%notfound Then
104         Close C_Sel1;
105         --
106         -- The primary key is invalid therefore we must error
107         --
108         hr_utility.set_message('PER', 'HR_7220_INVALID_PRIMARY_KEY');
109         hr_utility.raise_error;
110       End If;
111       Close C_Sel1;
112       If (p_object_version_number <> g_old_rec.object_version_number) Then
113         hr_utility.set_message('PER', 'HR_7155_OBJECT_INVALID');
114         hr_utility.raise_error;
115       End If;
116       hr_utility.set_location(l_proc, 15);
117       l_fct_ret := true;
118     End If;
119   End If;
120   hr_utility.set_location(' Leaving:'||l_proc, 20);
121   Return (l_fct_ret);
122 --
123 End api_updating;
124 --
125 -- ----------------------------------------------------------------------------
126 -- |---------------------------------< lck >----------------------------------|
127 -- ----------------------------------------------------------------------------
128 Procedure lck
129   (
130   p_questionnaire_template_id          in number,
131   p_object_version_number              in number
132   ) is
133 --
134 -- Cursor selects the 'current' row from the HR Schema
135 --
136   Cursor C_Sel1 is
137     select   questionnaire_template_id,
138   name,
139   text,
140   available_flag,
141   business_group_id,
142   quest_type_code,
143   object_version_number
144     from  hr_questionnaires
145     where  questionnaire_template_id = p_questionnaire_template_id
146     for  update nowait;
147 --
148   l_proc  varchar2(72) := g_package||'lck';
149 --
150 Begin
151   hr_utility.set_location('Entering:'||l_proc, 5);
152   --
153   -- Add any mandatory argument checking here:
154   -- Example:
155   -- hr_api.mandatory_arg_error
156   --   (p_api_name       => l_proc,
157   --    p_argument       => 'object_version_number',
158   --    p_argument_value => p_object_version_number);
159   --
160   hr_api.mandatory_arg_error
161     (p_api_name => l_proc
162     ,p_argument => 'questionnaire_template_id'
163     ,p_argument_value => p_questionnaire_template_id);
164   --
165   hr_api.mandatory_arg_error
166     (p_api_name => l_proc
167     ,p_argument => 'object_version_number'
168     ,p_argument_value => p_object_version_number
169     );
170   --
171   Open  C_Sel1;
172   Fetch C_Sel1 Into g_old_rec;
173   If C_Sel1%notfound then
174     Close C_Sel1;
175     --
176     -- The primary key is invalid therefore we must error
177     --
178     hr_utility.set_message('PER', 'HR_7220_INVALID_PRIMARY_KEY');
179     hr_utility.raise_error;
180   End If;
181   Close C_Sel1;
182   If (p_object_version_number <> g_old_rec.object_version_number) Then
183         hr_utility.set_message('PER', 'HR_7155_OBJECT_INVALID');
184         hr_utility.raise_error;
185       End If;
186 --
187   hr_utility.set_location(' Leaving:'||l_proc, 10);
188 --
189 -- We need to trap the ORA LOCK exception
190 --
191 Exception
192   When HR_Api.Object_Locked then
193     --
194     -- The object is locked therefore we need to supply a meaningful
195     -- error message.
196     --
197     hr_utility.set_message('PER', 'HR_7165_OBJECT_LOCKED');
198     hr_utility.set_message_token('TABLE_NAME', 'hr_questionnaires');
199     hr_utility.raise_error;
200 End lck;
201 --
202 -- ----------------------------------------------------------------------------
203 -- |-----------------------------< convert_args >-----------------------------|
204 -- ----------------------------------------------------------------------------
205 Function convert_args
206   (
207   p_questionnaire_template_id     in number,
208   p_name                          in varchar2,
209   p_text                          in CLOB,
210   p_available_flag                in varchar2,
211   p_business_group_id             in number,
212   p_quest_type_code                in varchar2,
213   p_object_version_number         in number
214   )
215   Return g_rec_type is
216 --
217   l_rec    g_rec_type;
218   l_proc  varchar2(72) := g_package||'convert_args';
219 --
220 Begin
221   --
222   hr_utility.set_location('Entering:'||l_proc, 5);
223   --
224   -- Convert arguments into local l_rec structure.
225   --
226   l_rec.questionnaire_template_id        := p_questionnaire_template_id;
227   l_rec.name                             := p_name;
228   l_rec.text                             := p_text;
229   l_rec.available_flag                   := p_available_flag;
230   l_rec.business_group_id                := p_business_group_id;
231   l_rec.quest_type_code                  := p_quest_type_code;
232   l_rec.object_version_number            := p_object_version_number;
233   --
234   -- Return the plsql record structure.
235   --
236   hr_utility.set_location(' Leaving:'||l_proc, 10);
237   Return(l_rec);
238 --
239 End convert_args;
240 --
241 end hr_qsn_shd;