You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
1.9 KiB
74 lines
1.9 KiB
|
|
|
|
|
|
begin tran
|
|
|
|
DECLARE @BillId BIGINT
|
|
DECLARE @OldCourseId BIGINT
|
|
DECLARE @NewCourseId BIGINT
|
|
DECLARE @OldItemId BIGINT
|
|
DECLARE @NewItemId BIGINT
|
|
DECLARE @MemId BIGINT
|
|
DECLARE @MemCourseId BIGINT
|
|
|
|
SELECT @MemId = FId FROM TMember WHERE FNo = 'A040473'
|
|
SELECT @BillId = FBillId FROM TMemberSaleBill WHERE FBillNo = '0021508260006' AND FMemId = @MemId
|
|
SELECT @OldCourseId = FId ,@OldItemId = FItemId FROM TCourse WHERE FNo = 'B3013L1'
|
|
SELECT @NewCourseId = FId ,@NewItemId = FItemId FROM TCourse WHERE FNo = 'B3033L1'
|
|
SELECT @MemCourseId = FId FROM TMemberCourse WHERE FMemId = @MemId AND FCourseId = @OldCourseId AND FTransId = @BillId
|
|
|
|
PRINT @MemId
|
|
PRINT @BillId
|
|
PRINT @OldCourseId
|
|
PRINT @NewCourseId
|
|
PRINT @MemCourseId
|
|
|
|
--SELECT * FROM TConsumeItem WHERE FMemCourseId = @MemCourseId
|
|
|
|
IF @BillId IS NULL OR @MemId IS NULL OR @OldCourseId IS NULL OR @NewCourseId IS NULL OR @MemCourseId IS NULL
|
|
BEGIN
|
|
PRINT 'ERRR'
|
|
RETURN
|
|
END
|
|
|
|
UPDATE TMemberSaleCourse
|
|
SET FCourseId = @NewCourseId,
|
|
FItemId = @NewItemId
|
|
WHERE FBillId = @BillId
|
|
AND FCourseId = @OldCourseId
|
|
|
|
--½»Ò×ÀúÊ·
|
|
UPDATE TMemberTransHist
|
|
SET FContentId = @NewCourseId
|
|
WHERE FTransId = @BillId
|
|
AND FContentId = @OldCourseId
|
|
|
|
UPDATE TMemberCourse
|
|
SET FCourseId = @NewCourseId,
|
|
FItemId = @NewItemId
|
|
WHERE FMemId = @MemId
|
|
AND FCourseId = @OldCourseId
|
|
|
|
SELECT * FROM TMemberCourse WHERE FMemId = (SELECT FId FROM TMember WHERE FNo = 'A040473')
|
|
SELECT * FROM TMemberCourseHist WHERE FMemCourseId = 5048572987552797220
|
|
UPDATE TMemberCourse SET FItemId = 4690334084436222271 WHERE Fid = 6062167234465898084
|
|
|
|
SELECT * FROM TMemberCourse WHERE FCourseId = 4781753040197801705
|
|
|
|
SELECT * FROM TCourse WHERE FNo = 'B1L1'
|
|
|
|
|
|
UPDATE TMemberCourseHist
|
|
SET FCourseId = @NewCourseId
|
|
WHERE FMemId = @MemId
|
|
AND FMemCourseId = @MemCourseId
|
|
|
|
|
|
UPDATE TConsumeItem
|
|
SET FItemId = @NewItemId
|
|
WHERE FMemCourseId = @MemCourseId
|
|
|
|
|
|
commit tran
|
|
|
|
rollback tran |