Project

General

Profile

Support #1713 » PMSAPPRAISER1_20230202.sql

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

 
1
??USE [MinovaES_Arita_Dev]
2

3
GO
4

5
/****** Object:  StoredProcedure [dbo].[PMSAPPRAISER1]    Script Date: 02/02/2023 11.26.05 ******/
6

7
SET ANSI_NULLS ON
8

9
GO
10

11
SET QUOTED_IDENTIFIER ON
12

13
GO
14

15
ALTER PROCEDURE [dbo].[PMSAPPRAISER1] 
16

17
(
18

19
	@EmployeeID VARCHAr(20)
20

21
	,@EndDate VARCHAR(20)
22

23
)
24

25
AS 
26

27

28

29
--DECLARE @EmployeeID VARCHAr(20) = '00000074'
30

31
--DECLARE @EndDate VARCHAR(20) = '20221231'
32

33

34

35
DECLARE @Pos VARCHAR(20)
36

37
DECLARE @Org VARCHAR(20)
38

39
DECLARE @now VARCHAR(20) = CONVERT(VARCHAR, GETDATE(), 112) 
40

41
SELECT DISTINCT @Org = Organization, @Pos = Position FROM dbo.PHRPA0002 WHERE EmployeeID = @EmployeeID
42

43
SELECT DISTINCT @EmployeeID AS EmployeeID, '' AS AppraisalType, '' AS HeaderSequence, '' AS Sequence,
44

45
				pa2.EmployeeID AS AppraisalD, 'DS' AS AppraiserType, 100 AS KPIWeight, 100 AS QualificationWeight, 'App1' AS AppraiserNo,
46

47
				pa1.FullName AS AppraiserName
48

49
FROM dbo.PHROM0002  AS om2
50

51
LEFT JOIN dbo.PHROM0001 AS om1
52

53
	ON om1.ObjectClass = 'P'
54

55
	AND om1.ObjectID = om2.RelationshipObject
56

57
	AND om1.StartDate <= @now AND om1.EndDate >= @now 
58

59
LEFT JOIN dbo.PHRPA0002 AS pa2
60

61
	ON pa2.Position = om2.RelationshipObject
62

63
	AND pa2.StartDate <= @now AND pa2.EndDate >= @now 
64

65
LEFT JOIN PHRPA0001 AS pa1
66

67
	On pa1.EmployeeID = pa2.EmployeeID
68

69
	AND pa1.StartDate <= @now AND pa1.EndDate >= @now 
70

71
WHERE om2.ObjectClass = 'O' AND om2.RelationshipClass = 'P' AND om2.ObjectID = @Org AND om1.PositionHead = '1'
72

73
	AND om2.StartDate <= @now AND om2.EndDate >= @now
74

75

76

77

(9-9/10)