DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_SNP_SHD

Source


1 Package Body hr_snp_shd as
2 /* $Header: hrsnprhi.pkb 120.0 2005/05/31 02:52:28 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  hr_snp_shd.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |---------------------------< constraint_error >---------------------------|
12 -- ----------------------------------------------------------------------------
13 Procedure constraint_error
14   (p_constraint_name in all_constraints.constraint_name%TYPE
15   ) Is
16 --
17   l_proc        varchar2(72) := g_package||'constraint_error';
18 --
19 Begin
20   --
21   If (p_constraint_name = 'SNAPSHOT_ID_PK') Then
22     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
23     fnd_message.set_token('PROCEDURE', l_proc);
24     fnd_message.set_token('STEP','5');
25     fnd_message.raise_error;
26   ElsIf (p_constraint_name = 'TRANSACTION_ID_FK') Then
27     fnd_message.set_name('PAY', '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   Else
32     fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
33     fnd_message.set_token('PROCEDURE', l_proc);
34     fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
35     fnd_message.raise_error;
36   End If;
37   --
38 End constraint_error;
39 
40 -- ----------------------------------------------------------------------------
41 -- |-----------------------------< api_updating >-----------------------------|
42 -- ----------------------------------------------------------------------------
43 Function api_updating
44   (p_snapshot_id                          in     number
45   ,p_object_version_number                in     number
46   )
47   Return Boolean Is
48   --
49   --
50   -- Cursor selects the 'current' row from the HR Schema
51   --
52   Cursor C_Sel1 is
53     select
54        snapshot_id
55       ,object_version_number
56       ,document
57       ,object_name
58       ,object_identifier
59 
60     from        hr_transaction_snapshot
61     where       snapshot_id = p_snapshot_id;
62   --
63   l_fct_ret     boolean;
64   --
65 Begin
66   --
67   If (p_snapshot_id is null and
68       p_object_version_number is null
69      ) Then
70     --
71     -- One of the primary key arguments is null therefore we must
72     -- set the returning function value to false
73     --
74     l_fct_ret := false;
75   Else
76     If (p_snapshot_id
77         = hr_snp_shd.g_old_rec.snapshot_id and
78         p_object_version_number
79         = hr_snp_shd.g_old_rec.object_version_number
80        ) Then
81       --
82       -- The g_old_rec is current therefore we must
83       -- set the returning function to true
84       --
85       l_fct_ret := true;
86     Else
87       --
88       -- Select the current row into g_old_rec
89       --
90       Open C_Sel1;
91       Fetch C_Sel1 Into hr_snp_shd.g_old_rec;
92       If C_Sel1%notfound Then
93         Close C_Sel1;
94         --
95         -- The primary key is invalid therefore we must error
96         --
97         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
98         fnd_message.raise_error;
99       End If;
100       Close C_Sel1;
101       If (p_object_version_number
102           <> hr_snp_shd.g_old_rec.object_version_number) Then
103         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
104         fnd_message.raise_error;
105       End If;
106       l_fct_ret := true;
107     End If;
108   End If;
109   Return (l_fct_ret);
110 --
111 End api_updating;
112 --
113 -- ----------------------------------------------------------------------------
114 -- |---------------------------------< lck >----------------------------------|
115 -- ----------------------------------------------------------------------------
116 --
117 -- ----------------------------------------------------------------------------
118 -- |
119 Procedure lck
120   (p_snapshot_id                          in     number
121   ,p_object_version_number                in     number
122   ) is
123 --
124 -- Cursor selects the 'current' row from the HR Schema
125 --
126   Cursor C_Sel1 is
127     select
128        snapshot_id
129       ,object_version_number
130       ,document
131       ,object_name
132       ,object_identifier
133     from        hr_transaction_snapshot
134     where       snapshot_id = p_snapshot_id
135     for update nowait;
136 --
137   l_proc        varchar2(72) := g_package||'lck';
138 --
139 Begin
140   hr_utility.set_location('Entering:'||l_proc, 5);
141   --
142   hr_api.mandatory_arg_error
143     (p_api_name           => l_proc
144     ,p_argument           => 'SNAPSHOT_ID'
145     ,p_argument_value     => p_snapshot_id
146     );
147   hr_utility.set_location(l_proc,6);
148   hr_api.mandatory_arg_error
149     (p_api_name           => l_proc
150     ,p_argument           => 'OBJECT_VERSION_NUMBER'
151     ,p_argument_value     => p_object_version_number
152     );
153   --
154   Open  C_Sel1;
155   Fetch C_Sel1 Into hr_snp_shd.g_old_rec;
156   If C_Sel1%notfound then
157     Close C_Sel1;
158     --
159     -- The primary key is invalid therefore we must error
160     --
161     fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
162     fnd_message.raise_error;
163   End If;
164   Close C_Sel1;
165   If (p_object_version_number
166       <> hr_snp_shd.g_old_rec.object_version_number) Then
167         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
168         fnd_message.raise_error;
169   End If;
170   --
171   hr_utility.set_location(' Leaving:'||l_proc, 10);
172   --
173   -- We need to trap the ORA LOCK exception
174   --
175 Exception
176   When HR_Api.Object_Locked then
177     --
178     -- The object is locked therefore we need to supply a meaningful
179     -- error message.
180     --
181     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
182     fnd_message.set_token('TABLE_NAME', 'hr_transaction_snapshot');
183     fnd_message.raise_error;
184 End lck;
185 -----------------------------< convert_args >-----------------------------|
186 -- ----------------------------------------------------------------------------
187 --
188 Function convert_args
189   (p_snapshot_id                    in number
190   ,p_object_version_number          in number
191   ,p_document                       in clob
192   ,p_object_name                    in varchar2
193   ,p_object_identifier                in varchar2
194   )
195   Return g_rec_type is
196 --
197   l_rec   g_rec_type;
198 --
199 Begin
200   --
201   -- Convert arguments into local l_rec structure.
202   --
203   l_rec.snapshot_id                      := p_snapshot_id;
204   l_rec.object_version_number            := p_object_version_number;
205   l_rec.document                         := p_document;
206   l_rec.object_name                      := p_object_name;
207   l_rec.object_identifier                := p_object_identifier;
208   --
209   -- Return the plsql record structure.
210   --
211   Return(l_rec);
212 --
213 End convert_args;
214 --
215 
216 end hr_snp_shd;