H
hujunyi
Unregistered / Unconfirmed
GUEST, unregistred user!
我建了一个存储过程,在SyBase的SQL Advantage中能执行,并能正确的返回Return值,可是在Delphi4里就不能返回正确的Return值。而且有时候能插入数据,有时不能插入,传入的参数都是一样的。请问各位大仙,请是什么。
为什么受伤的总是我?
这是我的代码:
StoredProc1.ParamByName('@S_jj').Value := '2000000001402001000';
StoredProc1.ParamByName('@S_dkqx').Value := '120';
StoredProc1.ParamByName('@czyh').Value := '01010101';
StoredProc1.ExecProc; (StoreProc11.Open我也试过了)
Caption := StoredProc1.ParamByName('Result').AsString;
//这就是我那可恨的Proc
create proc p_dkzq (@S_jj char(20),@S_dkqx char(3),@czyh char(8))
as
declare @xh char(10),@jgh char(5),@yqx char(3),@d_hkr char(10),@mqhkr char(8)
declare @zhtbm char(20)
declare @chtbm char(20)
declare @khh char(10)
declare @dkzl char(2)
declare @xjj char(20)
declare @hm char(30)
declare @qsrq char(8)
declare @je decimal(16,2)
declare @jkzl char(2)
declare @yjzyll decimal(6,4),@jzyll decimal(6,4),@jkll decimal(6,4)
declare @fdl decimal(4,2)
declare @jkqx char(3)
declare @yqll decimal(6,4)
declare @hkfs char(3),@hkfs1 char(1),@hkfs2 char(3),@hkfs3 char(1),@hkfs4 char(1)
declare @mm char(6)
declare @ffzh char(18),@dkzh char(18),@kkzh char(18)
select * from T_gw
select @kkzh=T_jkcht.kkzh,@khh=T_jkcht.jkrbm,@ffzh=T_jkzht.skrzh,@dkzh=T_jkzht.dkzh,@mm=T_jkcht.dkmm,@hkfs1=T_jkzht.hkfsbm,@hkfs2=T_jkzht.ydsj,
@hkfs3=T_jkzht.hkr,@jkll=T_jj.jkll,@jkqx=T_jj.jkqx,@jkzl=T_jkzht.jkzl,@je=T_jj.jkje,@qsrq=T_jj.jkr,@hm=T_grzl.mc
from T_grzl,T_jkcht,T_jkzht,T_jj where T_jj.bm=@S_jj and T_jj.zhtbm=T_jkzht.bm and T_jkzht.chtbm=T_jkcht.bm
and T_jkcht.jkrbm=T_grzl.bm
select @hkfs4=""
if convert(int,@hkfs2)=1
select @hkfs4="y"
if convert(int,@hkfs2)=3
select @hkfs4="J"
if convert(int,@hkfs2)=6
select @hkfs4="B"
if convert(int,@hkfs2)=12
select @hkfs4="N"
select @hkfs=@hkfs1+@hkfs4+@hkfs3
select @jzyll=min(jzyll) from T_dkll where dkzlbm=@jkzl and convert(int,dkqx)>=convert(int,@S_dkqx)
if (@jzyll is null)
begin
select @jzyll=max(jzyll) from T_dkll where dkzlbm=@jkzl
end
select @yjzyll=min(jzyll) from T_dkll where dkzlbm=@jkzl and convert(int,dkqx)>=convert(int,@jkqx)
if (@yjzyll is null)
begin
select @yjzyll=max(jzyll) from T_dkll where dkzlbm=@jkzl
end
select @fdl=convert(decimal(4,2),((@jkll/@yjzyll)-1)/100.0)
select @yqll=convert(decimal(6,4),sj) from T_xtsz where lx="Rate" and xm="Over"
begin tran tr_dkzq
/*补充借据*/
select @jgh=ssjgh from T_xdry where bm=@czyh
if (@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 1
end
select @xh=xygbm from T_bmxd where bm="T_jj" and xm=@jgh
if (@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 2
end
select @zhtbm=zhtbm,@yqx=jkqx,@mqhkr=mqhkr from T_jj
where (bm=@S_jj and ybm is null) or (bm!=@S_jj and ybm=@S_jj)
if(@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 3
end
select * from T_jj where ybm=@S_jj
if (@@error!=0 or @@rowcount>0)
begin
rollback tran tr_dkzq
return 4
end
insert T_Tjj select * from T_jj
where (bm=@S_jj and ybm is null) or (bm!=@S_jj and ybm=@S_jj)
if (@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 5
end
update T_bmxd set xygbm=stuff("0000",5-len(ltrim(rtrim(convert(char(4),convert(int,@xh)+1)))),len(ltrim(rtrim(convert(char(4),convert(int,@xh)+1)))),ltrim(rtrim(convert(char(4),convert(int,@xh)+1))))
where bm="T_jj" and xm=@jgh
if(@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 6
end
select @zhtbm=zhtbm,@yqx=jkqx,@mqhkr=mqhkr from T_jj
where (bm=@S_jj and ybm is null) or (bm!=@S_jj and ybm=@S_jj)
if(@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 7
end
select @d_hkr=convert(char(10),dateadd(mm,convert(int,@S_dkqx)-convert(int,@yqx),convert(datetime,substring(@mqhkr,1,4)+"."+substring(@mqhkr,5,2)+"."+substring(@mqhkr,7,2))),102)
select @mqhkr=substring(@d_hkr,1,4)+substring(@d_hkr,6,2)+substring(@d_hkr,9,2)
select @xjj=convert(char(4),datepart(yy,getdate()))+substring(@S_jj,5,9)+stuff("0000",5-len(ltrim(rtrim(@xh))),len(ltrim(rtrim(@xh))),ltrim(rtrim(@xh)))+"00"
update T_Tjj set
bm=@xjj,
ybm=@S_jj,
jkqx=@S_dkqx,
jkll=@jzyll*(1+@fdl),
mqhkr=@mqhkr
where bm=@S_jj
if (@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 8
end
/*补充主合同*/
select @dkzl=jkzl from T_jkzht
where (bm=@zhtbm and ybm is null) or (bm!=@zhtbm and ybm=@zhtbm)
select * from T_jkzht
where ((bm=@zhtbm and ybm is null) or (bm!=@zhtbm and ybm=@zhtbm)) and mqhkr<@mqhkr
if (@@error!=0 or @@rowcount>1)
begin
rollback tran tr_dkzq
return 9
end
select count(*) from T_jkzht
where ((bm=@zhtbm and ybm is null) or (bm!=@zhtbm and ybm=@zhtbm)) and mqhkr<@mqhkr
if (@@error=0 and @@rowcount=1)
begin
insert T_Tjkzht select * from T_jkzht
where (bm=@zhtbm and ybm is null) or (bm!=@zhtbm and ybm=@zhtbm)
if (@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 10
end
select @xh=xygbm from T_bmxd where bm="T_jkzht" and xm=@jgh
if (@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 11
end
update T_bmxd set xygbm=stuff("0000",5-len(ltrim(rtrim(convert(char(4),convert(int,@xh)+1)))),len(ltrim(rtrim(convert(char(4),convert(int,@xh)+1)))),ltrim(rtrim(convert(char(4),convert(int,@xh)+1))))
where bm="T_jkzht" and xm=@jgh
if(@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 12
end
select @chtbm=chtbm from T_jkzht
where (bm=@zhtbm and ybm is null) or (bm!=@zhtbm and ybm=@zhtbm)
if(@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 13
end
update T_Tjkzht set
bm=convert(char(4),datepart(yy,getdate()))+substring(@zhtbm,5,9)+stuff("0000",5-len(ltrim(rtrim(@xh))),len(ltrim(rtrim(@xh))),ltrim(rtrim(@xh)))+"00",
ybm=@zhtbm,
jkqx=@S_dkqx,
jkll=@jzyll*(1+@fdl),
mqhkr=@mqhkr
where bm=@zhtbm
if (@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 14
end
/*补充从合同*/
select @khh=jkrbm from T_jkcht
where ((bm=@chtbm and ybm is null) or (bm!=@chtbm and ybm=@chtbm)) and htzzr<@mqhkr
if (@@error!=0 or @@rowcount>1)
begin
rollback tran tr_dkzq
return 15
end
select @khh=jkrbm from T_jkcht
where ((bm=@chtbm and ybm is null) or (bm!=@chtbm and ybm=@chtbm)) and htzzr<@mqhkr
if (@@error=0 and @@rowcount=1)
begin
insert T_Tjkcht select * from T_jkcht
where (bm=@chtbm and ybm is null) or (bm!=@chtbm and ybm=@chtbm)
if (@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 16
end
select @xh=xygbm from T_bmxd where bm="T_jkcht" and xm=@jgh
if (@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 17
end
update T_bmxd set xygbm=stuff("000000",7-len(ltrim(rtrim(convert(char(6),convert(int,@xh)+1)))),len(ltrim(rtrim(convert(char(6),convert(int,@xh)+1)))),ltrim(rtrim(convert(char(6),convert(int,@xh)+1))))
where bm="T_jkcht" and xm=@jgh
if(@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 18
end
update T_Tjkcht set
bm=convert(char(4),datepart(yy,getdate()))+substring(@chtbm,5,7)+stuff("000000",7-len(ltrim(rtrim(@xh))),len(ltrim(rtrim(@xh))),ltrim(rtrim(@xh)))+"00",
ybm=@chtbm,
htzzr=@mqhkr
where bm=@chtbm
if (@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 19
end
end
end
/*
insert T_jytmp values(
jyrq int, 交易日期(YYYYMMDD),jyzl char(2), 交易种类,jgh int,机构号,khh int,客户号,hth char(20) NULL,合同号,
zh char(20) NULL,贷款帐号,dkzl int,贷款种类,kph int NULL,卡片号,hm char(30),户名,
qsrq int,起始日期(YYYYMMDD),dqrq int,到期日期(YYYYMMDD),qx int,期限(以月为单位),
je decimal(16,2), 金额(以元为单位,整数14位,小数2位),ll int,年利率(以%为单位,整数2位,小数4位),
yqll int,逾期利率(以%为单位,整数2位,小数4位),hkfs char(3),还款方式,bz int,标志,mm char(6),密码,
dkxt char(1),代扣系统,dkzh char(20),代扣帐号,ffxt char(1),发放系统,ffzh char(20),发放帐号,
clbz int,处理标志,czy int,操作员,bz1 char(20),备注1,bz2 int,备注2,bz3 decimal(16,2)),备注3
*/
insert T_jytmp values(convert(int,(datepart(yy,getdate())*100+datepart(mm,getdate()))*100+datepart(dd,getdate())),"13",
convert(int,@jgh),convert(int,@khh),@xjj,
@dkzh,convert(int,@dkzl),NULL,@hm,convert(int,@qsrq),convert(int,@mqhkr),convert(int,@S_dkqx),
@je,convert(int,@jzyll*@fdl*1200),convert(int,@yqll*10000),@hkfs,0,@mm,NULL,@kkzh,NULL,
@ffzh,1,convert(int,@czyh),NULL,NULL,NULL)
if(@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 20
end
commit tran tr_dkzq
return 0
go
多谢!
为什么受伤的总是我?
这是我的代码:
StoredProc1.ParamByName('@S_jj').Value := '2000000001402001000';
StoredProc1.ParamByName('@S_dkqx').Value := '120';
StoredProc1.ParamByName('@czyh').Value := '01010101';
StoredProc1.ExecProc; (StoreProc11.Open我也试过了)
Caption := StoredProc1.ParamByName('Result').AsString;
//这就是我那可恨的Proc
create proc p_dkzq (@S_jj char(20),@S_dkqx char(3),@czyh char(8))
as
declare @xh char(10),@jgh char(5),@yqx char(3),@d_hkr char(10),@mqhkr char(8)
declare @zhtbm char(20)
declare @chtbm char(20)
declare @khh char(10)
declare @dkzl char(2)
declare @xjj char(20)
declare @hm char(30)
declare @qsrq char(8)
declare @je decimal(16,2)
declare @jkzl char(2)
declare @yjzyll decimal(6,4),@jzyll decimal(6,4),@jkll decimal(6,4)
declare @fdl decimal(4,2)
declare @jkqx char(3)
declare @yqll decimal(6,4)
declare @hkfs char(3),@hkfs1 char(1),@hkfs2 char(3),@hkfs3 char(1),@hkfs4 char(1)
declare @mm char(6)
declare @ffzh char(18),@dkzh char(18),@kkzh char(18)
select * from T_gw
select @kkzh=T_jkcht.kkzh,@khh=T_jkcht.jkrbm,@ffzh=T_jkzht.skrzh,@dkzh=T_jkzht.dkzh,@mm=T_jkcht.dkmm,@hkfs1=T_jkzht.hkfsbm,@hkfs2=T_jkzht.ydsj,
@hkfs3=T_jkzht.hkr,@jkll=T_jj.jkll,@jkqx=T_jj.jkqx,@jkzl=T_jkzht.jkzl,@je=T_jj.jkje,@qsrq=T_jj.jkr,@hm=T_grzl.mc
from T_grzl,T_jkcht,T_jkzht,T_jj where T_jj.bm=@S_jj and T_jj.zhtbm=T_jkzht.bm and T_jkzht.chtbm=T_jkcht.bm
and T_jkcht.jkrbm=T_grzl.bm
select @hkfs4=""
if convert(int,@hkfs2)=1
select @hkfs4="y"
if convert(int,@hkfs2)=3
select @hkfs4="J"
if convert(int,@hkfs2)=6
select @hkfs4="B"
if convert(int,@hkfs2)=12
select @hkfs4="N"
select @hkfs=@hkfs1+@hkfs4+@hkfs3
select @jzyll=min(jzyll) from T_dkll where dkzlbm=@jkzl and convert(int,dkqx)>=convert(int,@S_dkqx)
if (@jzyll is null)
begin
select @jzyll=max(jzyll) from T_dkll where dkzlbm=@jkzl
end
select @yjzyll=min(jzyll) from T_dkll where dkzlbm=@jkzl and convert(int,dkqx)>=convert(int,@jkqx)
if (@yjzyll is null)
begin
select @yjzyll=max(jzyll) from T_dkll where dkzlbm=@jkzl
end
select @fdl=convert(decimal(4,2),((@jkll/@yjzyll)-1)/100.0)
select @yqll=convert(decimal(6,4),sj) from T_xtsz where lx="Rate" and xm="Over"
begin tran tr_dkzq
/*补充借据*/
select @jgh=ssjgh from T_xdry where bm=@czyh
if (@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 1
end
select @xh=xygbm from T_bmxd where bm="T_jj" and xm=@jgh
if (@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 2
end
select @zhtbm=zhtbm,@yqx=jkqx,@mqhkr=mqhkr from T_jj
where (bm=@S_jj and ybm is null) or (bm!=@S_jj and ybm=@S_jj)
if(@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 3
end
select * from T_jj where ybm=@S_jj
if (@@error!=0 or @@rowcount>0)
begin
rollback tran tr_dkzq
return 4
end
insert T_Tjj select * from T_jj
where (bm=@S_jj and ybm is null) or (bm!=@S_jj and ybm=@S_jj)
if (@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 5
end
update T_bmxd set xygbm=stuff("0000",5-len(ltrim(rtrim(convert(char(4),convert(int,@xh)+1)))),len(ltrim(rtrim(convert(char(4),convert(int,@xh)+1)))),ltrim(rtrim(convert(char(4),convert(int,@xh)+1))))
where bm="T_jj" and xm=@jgh
if(@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 6
end
select @zhtbm=zhtbm,@yqx=jkqx,@mqhkr=mqhkr from T_jj
where (bm=@S_jj and ybm is null) or (bm!=@S_jj and ybm=@S_jj)
if(@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 7
end
select @d_hkr=convert(char(10),dateadd(mm,convert(int,@S_dkqx)-convert(int,@yqx),convert(datetime,substring(@mqhkr,1,4)+"."+substring(@mqhkr,5,2)+"."+substring(@mqhkr,7,2))),102)
select @mqhkr=substring(@d_hkr,1,4)+substring(@d_hkr,6,2)+substring(@d_hkr,9,2)
select @xjj=convert(char(4),datepart(yy,getdate()))+substring(@S_jj,5,9)+stuff("0000",5-len(ltrim(rtrim(@xh))),len(ltrim(rtrim(@xh))),ltrim(rtrim(@xh)))+"00"
update T_Tjj set
bm=@xjj,
ybm=@S_jj,
jkqx=@S_dkqx,
jkll=@jzyll*(1+@fdl),
mqhkr=@mqhkr
where bm=@S_jj
if (@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 8
end
/*补充主合同*/
select @dkzl=jkzl from T_jkzht
where (bm=@zhtbm and ybm is null) or (bm!=@zhtbm and ybm=@zhtbm)
select * from T_jkzht
where ((bm=@zhtbm and ybm is null) or (bm!=@zhtbm and ybm=@zhtbm)) and mqhkr<@mqhkr
if (@@error!=0 or @@rowcount>1)
begin
rollback tran tr_dkzq
return 9
end
select count(*) from T_jkzht
where ((bm=@zhtbm and ybm is null) or (bm!=@zhtbm and ybm=@zhtbm)) and mqhkr<@mqhkr
if (@@error=0 and @@rowcount=1)
begin
insert T_Tjkzht select * from T_jkzht
where (bm=@zhtbm and ybm is null) or (bm!=@zhtbm and ybm=@zhtbm)
if (@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 10
end
select @xh=xygbm from T_bmxd where bm="T_jkzht" and xm=@jgh
if (@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 11
end
update T_bmxd set xygbm=stuff("0000",5-len(ltrim(rtrim(convert(char(4),convert(int,@xh)+1)))),len(ltrim(rtrim(convert(char(4),convert(int,@xh)+1)))),ltrim(rtrim(convert(char(4),convert(int,@xh)+1))))
where bm="T_jkzht" and xm=@jgh
if(@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 12
end
select @chtbm=chtbm from T_jkzht
where (bm=@zhtbm and ybm is null) or (bm!=@zhtbm and ybm=@zhtbm)
if(@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 13
end
update T_Tjkzht set
bm=convert(char(4),datepart(yy,getdate()))+substring(@zhtbm,5,9)+stuff("0000",5-len(ltrim(rtrim(@xh))),len(ltrim(rtrim(@xh))),ltrim(rtrim(@xh)))+"00",
ybm=@zhtbm,
jkqx=@S_dkqx,
jkll=@jzyll*(1+@fdl),
mqhkr=@mqhkr
where bm=@zhtbm
if (@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 14
end
/*补充从合同*/
select @khh=jkrbm from T_jkcht
where ((bm=@chtbm and ybm is null) or (bm!=@chtbm and ybm=@chtbm)) and htzzr<@mqhkr
if (@@error!=0 or @@rowcount>1)
begin
rollback tran tr_dkzq
return 15
end
select @khh=jkrbm from T_jkcht
where ((bm=@chtbm and ybm is null) or (bm!=@chtbm and ybm=@chtbm)) and htzzr<@mqhkr
if (@@error=0 and @@rowcount=1)
begin
insert T_Tjkcht select * from T_jkcht
where (bm=@chtbm and ybm is null) or (bm!=@chtbm and ybm=@chtbm)
if (@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 16
end
select @xh=xygbm from T_bmxd where bm="T_jkcht" and xm=@jgh
if (@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 17
end
update T_bmxd set xygbm=stuff("000000",7-len(ltrim(rtrim(convert(char(6),convert(int,@xh)+1)))),len(ltrim(rtrim(convert(char(6),convert(int,@xh)+1)))),ltrim(rtrim(convert(char(6),convert(int,@xh)+1))))
where bm="T_jkcht" and xm=@jgh
if(@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 18
end
update T_Tjkcht set
bm=convert(char(4),datepart(yy,getdate()))+substring(@chtbm,5,7)+stuff("000000",7-len(ltrim(rtrim(@xh))),len(ltrim(rtrim(@xh))),ltrim(rtrim(@xh)))+"00",
ybm=@chtbm,
htzzr=@mqhkr
where bm=@chtbm
if (@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 19
end
end
end
/*
insert T_jytmp values(
jyrq int, 交易日期(YYYYMMDD),jyzl char(2), 交易种类,jgh int,机构号,khh int,客户号,hth char(20) NULL,合同号,
zh char(20) NULL,贷款帐号,dkzl int,贷款种类,kph int NULL,卡片号,hm char(30),户名,
qsrq int,起始日期(YYYYMMDD),dqrq int,到期日期(YYYYMMDD),qx int,期限(以月为单位),
je decimal(16,2), 金额(以元为单位,整数14位,小数2位),ll int,年利率(以%为单位,整数2位,小数4位),
yqll int,逾期利率(以%为单位,整数2位,小数4位),hkfs char(3),还款方式,bz int,标志,mm char(6),密码,
dkxt char(1),代扣系统,dkzh char(20),代扣帐号,ffxt char(1),发放系统,ffzh char(20),发放帐号,
clbz int,处理标志,czy int,操作员,bz1 char(20),备注1,bz2 int,备注2,bz3 decimal(16,2)),备注3
*/
insert T_jytmp values(convert(int,(datepart(yy,getdate())*100+datepart(mm,getdate()))*100+datepart(dd,getdate())),"13",
convert(int,@jgh),convert(int,@khh),@xjj,
@dkzh,convert(int,@dkzl),NULL,@hm,convert(int,@qsrq),convert(int,@mqhkr),convert(int,@S_dkqx),
@je,convert(int,@jzyll*@fdl*1200),convert(int,@yqll*10000),@hkfs,0,@mm,NULL,@kkzh,NULL,
@ffzh,1,convert(int,@czyh),NULL,NULL,NULL)
if(@@error!=0 or @@rowcount!=1)
begin
rollback tran tr_dkzq
return 20
end
commit tran tr_dkzq
return 0
go
多谢!