一个存储过程的问题(部分语句不执行),解决马上给分
use zgwpjh
go
if exists(select top 1 name from sysobjects where name= 'Edit_product ' and type= 'p ')
drop proc Edit_product
go
Create Procedure [dbo].[Edit_product]
(
@pid int,
@pic varchar(150),
@wpmc varchar(50),
@xjcd int,
@wpsl int,
@catecode varchar(250),
@wpms text,
@isshow int,
@jhqy varchar(150),
@jhtj varchar(4000),
@wpproperty varchar(250),
@wpzr varchar(50),
@mycategory varchar(50)
)
as
declare @n int
declare @i int
declare @k int
declare @Lstr1 int
declare @Lstr2 int
declare @mycate varchar(200)
declare @property varchar(250)
set xact_abort on
begin tran
if @catecode <> ' '
--更新物品类别总量
select @Lstr1=len(物品类别)/4 from products where id=@pid --取得老类别
Set @i=0
WHILE @i < @Lstr1
BEGIN
Set @i =@i +1
Update Category set pcount=pcount-1 Where CateCode=Substring(@CateCode,1,@i*4) --老类别上减一
END
Set @Lstr2 = Len(@catecode)/4
Set @k=0
WHILE @k < @Lstr2
BEGIN
Set @k =@k +1
Update Category set pcount=pcount+1 Where CateCode=Substring(@CateCode,1,@k*4) --新类别上增一
END
--更新物品类别总量结束
--产品信息入库
if @pic= ' '
if @catecode= ' '
begin
update products set 物品名称=@wpmc,新旧程度=@xjcd,物品数量=@wpsl,物品描述=@wpms,前台可见=@isshow,期望交换区域=@jhqy,交换条件=@jhtj,属性=@wpproperty,我的类别=@mycategory where id=@pid
end
else
begin
update products set 物品名称=@wpmc,新旧程度=@xjcd,物品数量=@wpsl,物品描述=@wpms,前台可见=@isshow,期望交换区域=@jhqy,物品类别=@catecode,交换条件=@jhtj,属性=@wpproperty,我的类别=@mycategory where id=@pid
end
else
if @catecode= ' '
begin
update products set 物品图片=@pic,物品名称=@wpmc,新旧程度=@xjcd,物品数量=@wpsl,物品描述=@wpms,前台可见=@isshow,期望交换区域=@jhqy,交换条件=@jhtj,属性=@wpproperty,我的类别=@mycategory where id=@pid
end
else
begin
update products set 物品图片=@pic,物品名称=@wpmc,新旧程度=@xjcd,物品数量=@wpsl,物品描述=@wpms,前台可见=@isshow,期望交换区域=@jhqy,物品类别=@catecode,交换条件=@jhtj,属性=@wpproperty,我的类别=@mycategory where id=@pid
end
--产品入库结束
--更新当前物品的属性
select @property=属性 from products where id=@pid
if @property <> ' '
UPdate Cate_Property_value set pcount=pcount-1 where valueid in(@property)
if @wpproperty <> ' '
UPdate Cate_Property_value set pcount=pcount+1 where valueid in(@wpproperty)
--更新物品属性总量结束
select @mycate=我的类别 from products where id=@pid
update mycategory set pcount=pcount-1 where username=@wpzr and catename=@mycate
if @mycategory <> ' '
update mycategory set pcount=pcount+1 where username=@wpzr &