コードの最初の部分だけが実行されている理由を理解するのに苦労しています。問題がある場所に「--この時点以降は何も実行されていません」というステートメントを挿入しました。どんな助けでも大歓迎です
IF @i_numrecs = 0
BEGIN
SET @nextid = dbo.Timesheetgetnextid(@EMP, @DATE)
IF @mode = @c_current
BEGIN
INSERT INTO timedetail (
ppenddate,tsdate,empnum,task1,
task2,task3,hours,minutes,
doecode,duration,SOURCE,enteredby,
enteredon,approved,completed,timein,
timeout,id)
VALUES(
@DATE,@DATE,@EMP,' ',
' ',' ',0,0,
' ',0,'BROWSER',@UID,
@actiondate,'N','Y',' ',
' ',@nextid)
END
ELSE
BEGIN
INSERT INTO adjst_timedetail (
ppenddate,tsdate,empnum,task1,
task2,task3,hours,minutes,
doecode,duration,SOURCE,enteredby,
enteredon,approved,completed,timein,
timeout,id)
VALUES (
@DATE,@DATE,@EMP,' ',
' ',' ',0,0,
' ',0,'BROWSER',@UID,
@actiondate,'N','Y',' ',
' ',@nextid)
END
--Nothing after this point is executing
INSERT INTO timesheetchangelog (
empnum,tsdate,tdid,changedate,
changeby,SOURCE,changetype)
VALUES(
@emp,@date,@nextid,@actiondate,
@UID,@TCPIP,'COMPLETION INSERT')
SELECT @changelogid = Scope_identity()
EXEC Auditrecordaction
@emp,
@date,
@payfrequency,
@c_insertaction,
@actiondate,
@UID,
@actionid OUT,
@doaudit OUT
SELECT @doaudit DoAudit, @actionid ActionID
IF Isnull(@doaudit, 0) > 0
BEGIN
IF @mode = @c_current
BEGIN
INSERT INTO timedetail_audit (
EMPNUM,PPENDDATE,TSDATE,TASK1,
TASK2,TASK3,HOURS,MINUTES,
DOECODE,DURATION,SOURCE,TSGROUP,
DEPTCHRG,PAYRATE,TIMEIN,TIMEOUT,
ERRORS,COMPLETED,APPROVED,VERIFIED,
DELETED,PROCESSEDBYPAYROLL,ID,ENTEREDBY,
ENTEREDON,APPROVEDBY,APPROVEDON,PROCESSEDON,
QUANTITY,SHIFT,processed_pd,RUNNUMBER,
overnight,actionid,logid)
SELECT
EMPNUM,PPENDDATE,TSDATE,TASK1,
TASK2,TASK3,HOURS,MINUTES,
DOECODE,DURATION,SOURCE,TSGROUP,
DEPTCHRG,PAYRATE,TIMEIN,TIMEOUT,
ERRORS,COMPLETED,APPROVED,VERIFIED,
DELETED,PROCESSEDBYPAYROLL,ID,ENTEREDBY,
ENTEREDON,APPROVEDBY,APPROVEDON,PROCESSEDON,
QUANTITY,SHIFT,processed_pd,RUNNUMBER,
overnight,@actionid,@changelogid
FROM timedetail
WHERE empnum = @EMP
AND tsdate = @DATE
AND id = @nextid
END
ELSE
BEGIN
INSERT INTO timedetail_audit (
EMPNUM,PPENDDATE,TSDATE,TASK1,
TASK2,TASK3,HOURS,MINUTES,
DOECODE,DURATION,SOURCE,TSGROUP,
DEPTCHRG,PAYRATE,TIMEIN,TIMEOUT,
ERRORS,COMPLETED,APPROVED,VERIFIED,
DELETED,PROCESSEDBYPAYROLL,ID,ENTEREDBY,
ENTEREDON,APPROVEDBY,APPROVEDON,PROCESSEDON,
QUANTITY,SHIFT,processed_pd,RUNNUMBER,
overnight,actionid,logid)
SELECT
EMPNUM,PPENDDATE,TSDATE,TASK1,
TASK2,TASK3,HOURS,MINUTES,
DOECODE,DURATION,SOURCE,TSGROUP,
DEPTCHRG,PAYRATE,TIMEIN,TIMEOUT,
ERRORS,COMPLETED,APPROVED,VERIFIED,
DELETED,PROCESSEDBYPAYROLL,ID,ENTEREDBY,
ENTEREDON,APPROVEDBY,APPROVEDON,PROCESSEDON,
QUANTITY,SHIFT,processed_pd,RUNNUMBER,
overnight,@actionid,@changelogid
FROM adjst_timedetail
WHERE empnum = @EMP
AND tsdate = @DATE
AND id = @nextid
END
END
END