我正在努力使用 case 表达式来确定要创建哪个更新语句。以下是否可能,或者我应该为每个更新制作单独的更新存储过程?
IF (SELECT pick FROM warehouse WHERE order_no = @order_no and pick = @pick) is null
CASE @pick
when 1 then
UPDATE warehouse
SET pick = @pick, startpickdate=@dchar, startpicktime=@tchar
where order_no=@order_no
when 2 then
UPDATE warehouse
SET pick = @pick, endpickdate=@dchar, endpicktime=@tchar
where order_no=@order_no
when 0 then
UPDATE warehouse
SET pick = @pick, endpickdate='', endpicktime='',startpickdate='', startpicktime=''
where order_no=@order_no
END
GO