Project

General

Profile

Feature #1710 » PMSGETDEFAULTQUALIFICATION_20230202.sql

Tri Rizqiaty, 02/02/2023 03:25 PM

 
1
??USE [MinovaES_Arita_Dev]
2

3
GO
4

5
/****** Object:  StoredProcedure [dbo].[PMSGETDEFAULTQUALIFICATION]    Script Date: 02/02/2023 10.34.04 ******/
6

7
SET ANSI_NULLS ON
8

9
GO
10

11
SET QUOTED_IDENTIFIER ON
12

13
GO
14

15
ALTER PROCEDURE [dbo].[PMSGETDEFAULTQUALIFICATION]
16

17
(
18

19
	@EmployeeID VARCHAR(20)
20

21
	,@StartDate VARCHAR(20)
22

23
	,@EndDate VARCHAR(20)
24

25
	,@AppraisalType VARCHAR(20)
26

27
)
28

29
AS
30

31

32

33
----DECLARE @EmployeeID VARCHAR(20) = '00000074'
34

35
----DECLARE @StartDate VARCHAR(20) = '20220101'
36

37
----DECLARE @EndDate VARCHAR(20) = '20221231'
38

39
----DECLARE @AppraisalType VARCHAR(20) = 'F'
40

41

42

43
DECLARE @Job VARCHAR(20)
44

45
SELECT DISTINCT @Job = Job FROM PHRPA0002 WHERE EmployeeID = @EmployeeID AND StartDate <= @EndDate AND EndDate >= @EndDate
46

47

48

49
DECLARE @AppraisalID VARCHAR(20)
50

51
SELECT DISTINCT @AppraisalID = AppraisalID
52

53
FROM PHROM0018 AS om18
54

55
WHERE om18.ObjectID = @Job
56

57
	AND om18.StartDate <= @EndDate AND om18.EndDate >= @EndDate
58

59

60

61
IF(@AppraisalID <> '')
62

63
BEGIN
64

65
	SELECT DISTINCT @EmployeeID AS  [EmployeeID]
66

67
				,@AppraisalType AS [AppraisalType]
68

69
				,'' AS [HeaderSequence]
70

71
				,om8.Sequence AS [Sequence]
72

73
				,'0' AS [SequenceSub]
74

75
				,om8.Qualification AS QualificationID
76

77
				,om2.RelationshipObject AS QualificationGroup
78

79
				,om8.Weight AS [Weight]
80

81
				,om8.Proficiency AS [TargetProficiency]
82

83
				,'' AS [SelfLevel]
84

85
				,'' AS [App1Level]
86

87
				,'' AS [App2Level]
88

89
				,'' AS [App3Level]
90

91
				,'' AS [App4Level]
92

93
				,'' AS [App5Level]
94

95
				,'' AS [App6Level]
96

97
				,'' AS [App7Level]
98

99
				,'' AS [App8Level]
100

101
				,'' AS [App9Level]
102

103
				,'' AS [App10Level]
104

105
				,'' AS [SelfScore]
106

107
				,'' AS [App1Score]
108

109
				,'' AS [App2Score]
110

111
				,'' AS [App3Score]
112

113
				,'' AS [App4Score]
114

115
				,'' AS [App5Score]
116

117
				,'' AS [App6Score]
118

119
				,'' AS [App7Score]
120

121
				,'' AS [App8Score]
122

123
				,'' AS [App9Score]
124

125
				,'' AS [App10Score]
126

127
				,'' AS [AppraiserScore]
128

129
				,'' AS [WeightedScore]
130

131
				,'' AS [Notes]
132

133
				,'' AS [Description]
134

135
				,'' AS [Level1_sum_qual]
136

137
				,'' AS [Level2_sum_qual]
138

139
				,'' AS [Level3_sum_qual]
140

141
				,'' AS [Level4_sum_qual]
142

143
				,'' AS [Level5_sum_qual]
144

145
				,'' AS [NotesApr1]
146

147
				,'' AS [NotesApr2]
148

149
				,'' AS [NotesNHA]
150

151
	FROM PHROM0008 AS om8
152

153
	LEFT JOIN dbo.PHROM0002 AS om2
154

155
	ON om2.ObjectID = om8.Qualification 
156

157
		AND om2.ObjectClass = 'Q' AND om2.RelationshipClass = 'QG'
158

159
		AND om2.StartDate <= @EndDate AND om2.EndDate >= @EndDate
160

161
	LEFT JOIN dbo.PHROM0001 AS om1
162

163
		ON om1.ObjectID = om8.Qualification
164

165
		AND om1.ObjectClass = 'Q'
166

167
		AND om1.StartDate <= @EndDate	 AND om1.EndDate >= @EndDate
168

169
	WHERE om8.ObjectID = @AppraisalID 
170

171
		AND om8.ObjectClass = 'AP'
172

173
		AND om8.StartDate <= @EndDate AND om8.EndDate >= @EndDate
174

175
END
176

177
ELSE
178

179
BEGIN
180

181
	SELECT DISTINCT @EmployeeID AS  [EmployeeID]
182

183
				,@AppraisalType AS [AppraisalType]
184

185
				,'' AS [HeaderSequence]
186

187
				,om8.Sequence AS [Sequence]
188

189
				,'0' AS [SequenceSub]
190

191
				,om8.Qualification AS QualificationID
192

193
				,om2.RelationshipObject AS QualificationGroup
194

195
				,om8.Weight AS [Weight]
196

197
				,om8.Proficiency AS [TargetProficiency]
198

199
				,'' AS [SelfLevel]
200

201
				,'' AS [App1Level]
202

203
				,'' AS [App2Level]
204

205
				,'' AS [App3Level]
206

207
				,'' AS [App4Level]
208

209
				,'' AS [App5Level]
210

211
				,'' AS [App6Level]
212

213
				,'' AS [App7Level]
214

215
				,'' AS [App8Level]
216

217
				,'' AS [App9Level]
218

219
				,'' AS [App10Level]
220

221
				,'' AS [SelfScore]
222

223
				,'' AS [App1Score]
224

225
				,'' AS [App2Score]
226

227
				,'' AS [App3Score]
228

229
				,'' AS [App4Score]
230

231
				,'' AS [App5Score]
232

233
				,'' AS [App6Score]
234

235
				,'' AS [App7Score]
236

237
				,'' AS [App8Score]
238

239
				,'' AS [App9Score]
240

241
				,'' AS [App10Score]
242

243
				,'' AS [AppraiserScore]
244

245
				,'' AS [WeightedScore]
246

247
				,'' AS [Notes]
248

249
				,'' AS [Description]
250

251
				,'' AS [Level1_sum_qual]
252

253
				,'' AS [Level2_sum_qual]
254

255
				,'' AS [Level3_sum_qual]
256

257
				,'' AS [Level4_sum_qual]
258

259
				,'' AS [Level5_sum_qual]
260

261
				,'' AS [NotesApr1]
262

263
				,'' AS [NotesApr2]
264

265
				,'' AS [NotesNHA] 
266

267
	FROM PHROM0008 AS om8
268

269
	LEFT JOIN dbo.PHROM0002 AS om2
270

271
	ON om2.ObjectID = om8.Qualification
272

273
		AND om2.ObjectClass = 'Q' AND om2.RelationshipClass = 'QG'
274

275
		AND om2.StartDate <= @EndDate AND om2.EndDate >= @EndDate
276

277
	LEFT JOIN dbo.PHROM0001 AS om1
278

279
		ON om1.ObjectID = om8.Qualification
280

281
		AND om1.ObjectClass = 'Q'
282

283
		AND om1.StartDate <= @EndDate	 AND om1.EndDate >= @EndDate
284

285
	WHERE om8.ObjectID = @Job 
286

287
		AND om8.ObjectClass = 'J'
288

289
		AND om8.StartDate <= @EndDate AND om8.EndDate >= @EndDate
290

291
END
292

293

(5-5/6)