どの更新ステートメントを作成するかを決定するためにケース式に苦労しています。以下は可能ですか、または更新ごとに個別の更新ストアドプロシージャを作成する必要がありますか?
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