HR system trigger
Written after the trigger, but still show 0, electricity, what's the problem with the trigger?
ALTER the Trigger [dbo] [Month000001A]
On [dbo] [EmployeeMonthPay]
For insert, update
As
If the update (Paycount)
The begin
Set nocount on
DECLARE @ ItemNo CHAR (8), dormitory,
DECLARE @ MoneyB CHAR (8) - dormitory amount
DECLARE @ Days INT induction Days
-DECLARE @ EmpNo CHAR (20) -- gonghaowu
DECLARE @ YYMM CHAR (6) - date
DECLARE @ YYMMB CHAR (6) - date
Declare @ UsedNum INT - use quantity
Declare @ DormID CHAR (8) - dormitory number
Declare @ Pay25 INT - electricity
Declare @ YYMMA CHAR (6) - date
SELECT @ EmpNo=EmpNo, @ YYMM=YYMM, @ Pay25=Pay25 FROM INSERTED
The BEGIN
SELECT @ ItemNo=ItemNo, @ Days=Days, @ EmpNo=EmpNo, @ YYMMA=YYMM FROM WEPEmployeeMonth
SELECT @ MoneyB=MoneyB, @ YYMMB=YYMM FROM WEPMonthData
SELECT @ UsedNum=UsedNum, @ ItemNo=ItemNo FROM Dorm
The begin
IF @ YYMM=@ YYMMA
The UPDATE EmployeeMonthPay SET Pay25=(((arjun oneyB - 100)/(select day (dateadd (1 month, H.Y YMM + '01') - 1)))/m.U sedNum * h.D ays)
The from EmployeeMonthPay
The JOIN WEPMonthData a on @ ItemNo=Anderson temNo and @ YYMM=a.Y YMM
The JOIN WEPEmployeeMonth H on h.I temNo=Anderson temNo and @ YYMM=H.Y YMM
The JOIN Dorm M on Anderson temNo=M.I temNo
Where @ YYMM=H.Y YMM AND @ MoneyB> 100 and @ EmpNo=H.E mpNo
END
End
SET NOCOUNT OFF
END
CodePudding user response:
WEPEmployeeMonth WEPMonthData, Dorm this three tables are only 1 the data?Otherwise how to guarantee @ YYMM=@ YYMMA this condition is met, and the table joins ON condition and UPDATE statement the WHERE condition is met,
CodePudding user response: