DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_QSF_SHD

Source


1 Package Body hr_qsf_shd as
2 /* $Header: hrqsfrhi.pkb 115.11 2003/08/27 00:16:45 hpandya ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)  := '  hr_qsf_shd.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |---------------------------< constraint_error >---------------------------|
12 -- ----------------------------------------------------------------------------
13 Procedure constraint_error
14             (p_constraint_name in all_constraints.constraint_name%TYPE) Is
15 --
16   l_proc   varchar2(72) := g_package||'constraint_error';
17 --
18 Begin
19   hr_utility.set_location('Entering:'||l_proc, 5);
20   --
21   If (p_constraint_name = 'HR_QUEST_FIELDS_FK') Then
22     fnd_message.set_name('PER', 'PER_52416_QSF_INVAL_TEMP_ID');
23     fnd_message.raise_error;
24   ElsIf (p_constraint_name = 'HR_QUEST_FIELDS_PK') Then
25     -- Unlikely to fail.
26     hr_utility.set_message('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
27     hr_utility.set_message_token('PROCEDURE', l_proc);
28     hr_utility.set_message_token('STEP','10');
29     hr_utility.raise_error;
30   ElsIf (p_constraint_name = 'HR_QUEST_FIELDS_SQL_FLAG_CHK') Then
31     fnd_message.set_name('PER', 'PER_52417_QSF_REQD_FLAG_INVAL');
32     fnd_message.raise_error;
33   ElsIf (p_constraint_name = 'HR_QUEST_FIELDS_TYPE_CHK') Then
34     fnd_message.set_name('PER', 'PER_52418_QSF_TYPE_INVALID');
35     fnd_message.raise_error;
36   Else
37     hr_utility.set_message('PER', 'HR_7877_API_INVALID_CONSTRAINT');
38     hr_utility.set_message_token('PROCEDURE', l_proc);
39     hr_utility.set_message_token('CONSTRAINT_NAME', p_constraint_name);
40     hr_utility.raise_error;
41   End If;
42   --
43   hr_utility.set_location(' Leaving:'||l_proc, 10);
44 End constraint_error;
45 --
46 -- ----------------------------------------------------------------------------
47 -- |-----------------------------< api_updating >-----------------------------|
48 -- ----------------------------------------------------------------------------
49 Function api_updating
50   (
51   p_field_id                           in number,
52   p_object_version_number              in number
53   )      Return Boolean Is
54 --
55   --
56   -- Cursor selects the 'current' row from the HR Schema
57   --
58   Cursor C_Sel1 is
59     select
60     field_id,
61   questionnaire_template_id,
62   name,
63   type,
64   html_text,
65   sql_required_flag,
66   sql_text,
67   object_version_number
68     from  hr_quest_fields
69     where  field_id = p_field_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_field_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_field_id = g_old_rec.field_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_field_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   field_id,
138   questionnaire_template_id,
139   name,
140   type,
141   html_text,
142   sql_required_flag,
143   sql_text,
144   object_version_number
145     from  hr_quest_fields
146     where  field_id = p_field_id
147     for  update nowait;
148 --
149   l_proc  varchar2(72) := g_package||'lck';
150 --
151 Begin
152   hr_utility.set_location('Entering:'||l_proc, 5);
153   --
154   hr_api.mandatory_arg_error
155     (p_api_name  => l_proc
156     ,p_argument  => 'field_id'
157     ,p_argument_value => p_field_id);
158   --
159   hr_api.mandatory_arg_error
160     (p_api_name  => l_proc
161     ,p_argument  => 'object_version_number'
162     ,p_argument_value => p_object_version_number);
163   --
164   Open  C_Sel1;
165   Fetch C_Sel1 Into g_old_rec;
166   If C_Sel1%notfound then
167     Close C_Sel1;
168     --
169     -- The primary key is invalid therefore we must error
170     --
171     hr_utility.set_message('PER', 'HR_7220_INVALID_PRIMARY_KEY');
172     hr_utility.raise_error;
173   End If;
174   Close C_Sel1;
175   If (p_object_version_number <> g_old_rec.object_version_number) Then
176         hr_utility.set_message('PER', 'HR_7155_OBJECT_INVALID');
177         hr_utility.raise_error;
178       End If;
179 --
180   hr_utility.set_location(' Leaving:'||l_proc, 10);
181 --
182 -- We need to trap the ORA LOCK exception
183 --
184 Exception
185   When HR_Api.Object_Locked then
186     --
187     -- The object is locked therefore we need to supply a meaningful
188     -- error message.
189     --
190     hr_utility.set_message('PER', 'HR_7165_OBJECT_LOCKED');
191     hr_utility.set_message_token('TABLE_NAME', 'hr_quest_fields');
192     hr_utility.raise_error;
193 End lck;
194 --
195 -- ----------------------------------------------------------------------------
196 -- |-----------------------------< convert_args >-----------------------------|
197 -- ----------------------------------------------------------------------------
198 Function convert_args
199   (
200   p_field_id                      in number,
201   p_questionnaire_template_id     in number,
202   p_name                          in varchar2,
203   p_type                          in varchar2,
204   p_html_text                     in varchar2,
205   p_sql_required_flag             in varchar2,
206   p_sql_text                      in varchar2,
207   p_object_version_number         in number
208   )
209   Return g_rec_type is
210 --
211   l_rec    g_rec_type;
212   l_proc  varchar2(72) := g_package||'convert_args';
213 --
214 Begin
215   --
216   hr_utility.set_location('Entering:'||l_proc, 5);
217   --
218   -- Convert arguments into local l_rec structure.
219   --
220   l_rec.field_id                         := p_field_id;
221   l_rec.questionnaire_template_id        := p_questionnaire_template_id;
222   l_rec.name                             := p_name;
223   l_rec.type                             := p_type;
224   l_rec.html_text                        := p_html_text;
225   l_rec.sql_required_flag                := p_sql_required_flag;
226   l_rec.sql_text                         := p_sql_text;
227   l_rec.object_version_number            := p_object_version_number;
228   --
229   -- Return the plsql record structure.
230   --
231   hr_utility.set_location(' Leaving:'||l_proc, 10);
232   Return(l_rec);
233 --
234 End convert_args;
235 --
236 end hr_qsf_shd;