Home > database >  HR system trigger
HR system trigger

Time:11-11


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:

reference 1st floor RINK_1 response:
WEPEmployeeMonth, WEPMonthData, Dorm this three tables are only 1 the data?

Otherwise how to guarantee @ YYMM=@ YYMMA this condition is met, and UPDATE statement ON tables in the connection condition and the WHERE condition is met,


Yes, @ YYMM 202006, for example, Dorm this table is mainly to obtain the total number of room UsedNum, corresponding to the Dorm number ItemNo
WEPMonthData MoneyB dormitory total electricity, there is a corresponding ItemNo dormitory,
WEPEmployeeMonth Days accommodation Days, employees gonghaowu EmpNo, there is a corresponding ItemNo dormitory,

CodePudding user response:

See you define several are char, char if not enough digits automatically fill zero, you need not trigger, next to manually executed by the statement, update statement implemented successfully

CodePudding user response:

reference 3rd floor big watermelon cut a piece of a kilo of reply:
see you define several are char, char if not enough digits automatically fill zero, you need not trigger, instead of the statements performed manually, have update statement execution success


This query is that no problem

Select (((MoneyB - 100)/(select day (dateadd (1 month, H.Y YMM + '01') - 1)))/M.U sedNum * H.D ays) from v_WEPMonthData A
LEFT the JOIN Dorm M ON Anderson temNo=M.I temNo
LEFT the JOIN WEPEmployeeMonth H ON Anderson temNo=H.I temNo
Where H.Y YMM='202006' AND MONEYB>=100
  • Related