DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_QSN_SHD

Source


1 Package Body hr_qsn_shd as
2 /* $Header: hrqsnrhi.pkb 120.4.12010000.3 2008/11/05 09:57:56 rsykam 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   object_version_number
67     from  hr_questionnaires
68     where  questionnaire_template_id = p_questionnaire_template_id;
69 --
70   l_proc  varchar2(72)  := g_package||'api_updating';
71   l_fct_ret  boolean;
72 --
73 Begin
74   hr_utility.set_location('Entering:'||l_proc, 5);
75   --
76   If (
77   p_questionnaire_template_id is null and
78   p_object_version_number is null
79      ) Then
80     --
81     -- One of the primary key arguments is null therefore we must
82     -- set the returning function value to false
83     --
84     l_fct_ret := false;
85   Else
86     If (
87   p_questionnaire_template_id = g_old_rec.questionnaire_template_id and
88   p_object_version_number = g_old_rec.object_version_number
89        ) Then
90       hr_utility.set_location(l_proc, 10);
91       --
92       -- The g_old_rec is current therefore we must
93       -- set the returning function to true
94       --
95       l_fct_ret := true;
96     Else
97       --
98       -- Select the current row into g_old_rec
99       --
100       Open C_Sel1;
101       Fetch C_Sel1 Into g_old_rec;
102       If C_Sel1%notfound Then
103         Close C_Sel1;
104         --
105         -- The primary key is invalid therefore we must error
106         --
107         hr_utility.set_message('PER', 'HR_7220_INVALID_PRIMARY_KEY');
108         hr_utility.raise_error;
109       End If;
110       Close C_Sel1;
111       If (p_object_version_number <> g_old_rec.object_version_number) Then
112         hr_utility.set_message('PER', 'HR_7155_OBJECT_INVALID');
113         hr_utility.raise_error;
114       End If;
115       hr_utility.set_location(l_proc, 15);
116       l_fct_ret := true;
117     End If;
118   End If;
119   hr_utility.set_location(' Leaving:'||l_proc, 20);
120   Return (l_fct_ret);
121 --
122 End api_updating;
123 --
124 -- ----------------------------------------------------------------------------
125 -- |---------------------------------< lck >----------------------------------|
126 -- ----------------------------------------------------------------------------
127 Procedure lck
128   (
129   p_questionnaire_template_id          in number,
130   p_object_version_number              in number
131   ) is
132 --
133 -- Cursor selects the 'current' row from the HR Schema
134 --
135   Cursor C_Sel1 is
136     select   questionnaire_template_id,
137   name,
138   text,
139   available_flag,
140   business_group_id,
141   object_version_number
142     from  hr_questionnaires
143     where  questionnaire_template_id = p_questionnaire_template_id
144     for  update nowait;
145 --
146   l_proc  varchar2(72) := g_package||'lck';
147 --
148 Begin
149   hr_utility.set_location('Entering:'||l_proc, 5);
150   --
151   -- Add any mandatory argument checking here:
152   -- Example:
153   -- hr_api.mandatory_arg_error
154   --   (p_api_name       => l_proc,
155   --    p_argument       => 'object_version_number',
156   --    p_argument_value => p_object_version_number);
157   --
158   hr_api.mandatory_arg_error
159     (p_api_name => l_proc
160     ,p_argument => 'questionnaire_template_id'
161     ,p_argument_value => p_questionnaire_template_id);
162   --
163   hr_api.mandatory_arg_error
164     (p_api_name => l_proc
165     ,p_argument => 'object_version_number'
166     ,p_argument_value => p_object_version_number
167     );
168   --
169   Open  C_Sel1;
170   Fetch C_Sel1 Into g_old_rec;
171   If C_Sel1%notfound then
172     Close C_Sel1;
173     --
174     -- The primary key is invalid therefore we must error
175     --
176     hr_utility.set_message('PER', 'HR_7220_INVALID_PRIMARY_KEY');
177     hr_utility.raise_error;
178   End If;
179   Close C_Sel1;
180   If (p_object_version_number <> g_old_rec.object_version_number) Then
181         hr_utility.set_message('PER', 'HR_7155_OBJECT_INVALID');
182         hr_utility.raise_error;
183       End If;
184 --
185   hr_utility.set_location(' Leaving:'||l_proc, 10);
186 --
187 -- We need to trap the ORA LOCK exception
188 --
189 Exception
190   When HR_Api.Object_Locked then
191     --
192     -- The object is locked therefore we need to supply a meaningful
193     -- error message.
194     --
195     hr_utility.set_message('PER', 'HR_7165_OBJECT_LOCKED');
196     hr_utility.set_message_token('TABLE_NAME', 'hr_questionnaires');
197     hr_utility.raise_error;
198 End lck;
199 --
200 -- ----------------------------------------------------------------------------
201 -- |-----------------------------< convert_args >-----------------------------|
202 -- ----------------------------------------------------------------------------
203 Function convert_args
204   (
205   p_questionnaire_template_id     in number,
206   p_name                          in varchar2,
207   p_text                          in CLOB,
208   p_available_flag                in varchar2,
209   p_business_group_id             in number,
210   p_object_version_number         in number
211   )
212   Return g_rec_type is
213 --
214   l_rec    g_rec_type;
215   l_proc  varchar2(72) := g_package||'convert_args';
216 --
217 Begin
218   --
219   hr_utility.set_location('Entering:'||l_proc, 5);
220   --
221   -- Convert arguments into local l_rec structure.
222   --
223   l_rec.questionnaire_template_id        := p_questionnaire_template_id;
224   l_rec.name                             := p_name;
225   l_rec.text                             := p_text;
226   l_rec.available_flag                   := p_available_flag;
227   l_rec.business_group_id                := p_business_group_id;
228   l_rec.object_version_number            := p_object_version_number;
229   --
230   -- Return the plsql record structure.
231   --
232   hr_utility.set_location(' Leaving:'||l_proc, 10);
233   Return(l_rec);
234 --
235 End convert_args;
236 --
237 end hr_qsn_shd;