大家帮我看一下这个存储过程为什么后半段无法执行??
下面是ASP代码:
petid = request.Form("petid")
hostid = request.Form("hostid")
petname = request.Form("petname")
skill = request.Form("skill")
fight = request.Form("fight")
attribute = request.Form("attribute")
'上面的数据已经保证不会为空
hit_ad_num = 100 '修改所需点击次数
petname_pay = 100 '修改所需积分数
Set mycomm = server.CreateObject("adodb.command")
with mycomm
.ActiveConnection = conn
.commandText = "pet_save"
.commandType = 4
.prepared = True
.parameters.append .createparameter("RETURN",2,4)
.parameters.append .createparameter("@pet_id",3,1,4,petid)
.parameters.append .createparameter("@host_id",3,1,4,hostid)
.parameters.append .createparameter("@hit_ad_num",3,1,4,hit_ad_num)
.parameters.append .createparameter("@petname_pay",3,1,4,petname_pay)
.parameters.append .createparameter("@skill",200,1,20,skill)
.parameters.append .createparameter("@attribute",200,1,20,attribute)
.parameters.append .createparameter("@petname",200,1,50,petname)
.parameters.append .createparameter("@fight",11,1,4,fight)
mycomm.execute
End with
If mycomm(0) Then web_info "您的积分或广告点击次数不够!",2
Set mycomm = Nothing
下面是存储过程代码:
CREATE PROCEDURE pet_save
@host_id int,
@pet_id int,
@petname_pay int,
@hit_ad_num int,
@skill nvarchar(20),
@attribute nvarchar(20),
@petname nvarchar(50),
@fight bit
AS
set nocount on
begin
declare @ad_num int
declare @pt_num int
select @ad_num=count(*) from ptcenter_tar where un=(select un from users where id=@host_id)
select @pt_num=pt from users where id=@host_id
if @ad_num<@hit_ad_num or @pt_num<@petname_pay return 1
update kennel_posture set skill=@skill,petname=@petname,fight=@fight,attribute=@attribute where id=@pet_id
end
GO
(本人初学存储过程,基本语法都成问题)问题在下面:
(1)
if @ad_num<@hit_ad_num or @pt_num<@petname_pay return 1
这一句只有or后面成立时返回值1,而前面个满足的时候并没有返回值.
(2)
我的fight值从提交页面过来是值是1,在存储过程里面和数据库里面的数据类型是bit,
.parameters.append .createparameter("@fight",11,1,4,fight)
我将fight的类型代码用11(好象是bool类型)不知道对不对,我这样运行的时候没有提示类型错误!
(3)
update kennel_posture set skill=@skill,petname=@petname,fight=@fight,attribute=@attribute where id=@pet_id
这一句根本没有执行但又不提示错误,头都搞大了!