删除WHS_SELECT
读入
CREATE proc WHS_SELECT
@op int,
@Accountid varchar(10)
as
set nocount on
declare @aid varchar(10)
,@cknum int
if @op=1 begin --读取ID,检查仓库是否存在
SELECT @aid=AccountID,@cknum=NeedExtCK FROM warehouse WHERE AccountID=@accountid
if @cknum is null begin --打开主仓库
INSERT INTO warehouse (AccountID, Items, Money, EndUseDate, DbVersion)
VALUES (@accountid,cast(REPLICATE(char(0xff),1200) as varbinary(1200))
,0, getdate(), 1)
Select @accountid AS AccountID
end else begin
Update warehouse Set ExtCKNum=NeedExtCK WHERE AccountID=@accountid
if @cknum=0
Select @aid AS AccountID
else begin
if not EXISTS (select AccountID FROM ExtWareHouse WHERE AccountID=@accountid and Number=@cknum) begin
INSERT INTO ExtWarehouse (AccountID,Number,Items, Money, EndUseDate, DbVersion)
VALUES (@accountid,@cknum,cast(REPLICATE(char(0xff),1200) as varbinary(1200))
,0, getdate(), 1)
end
Select @accountid AS AccountID
end
end
end else if @op=2 begin
SELECT @cknum=ExtCKNum FROM warehouse WHERE AccountID=@accountid
if @cknum=0
SELECT Items from warehouse where AccountID=@accountid
else
SELECT Items from ExtWareHouse WHERE AccountID=@Accountid AND Number=@cknum
end else begin
SELECT @cknum=ExtCKNum FROM warehouse WHERE AccountID=@accountid
if @cknum=0
SELECT Money, DbVersion, pw from warehouse where AccountID=@accountid
else
SELECT Money, DbVersion, pw from ExtWareHouse where AccountID=@accountid AND Number=@cknum
end
set nocount off
GO
即可!!