SQL SERVER 2000中的存储过程为:
create proc aa
@X int output
AS
begin
begin tran
set XACT_ABORT on
set ANSI_NULL_DFLT_ON on
set ANSI_WARNINGS on
....
if @@ERROR<>0 goto Error
commit tran
set @X=0
Error:
rollback tran
set @X=1
end
DELPHI中程序代码如下:
ADOStoredProc1.Close;
ADOStoredProc1.Parameters[0].Value:=3;
ADOStoredProc1.ExecProc;
case ADOStoredProc1.Parameters.ParamByName('X').Value of
0: showmessage('return 0');
1: showmessage('return 1');
else
showmessage('return other');
end;
程序运行后出错:‘list index out of bound(0)'
请专家帮忙!
create proc aa
@X int output
AS
begin
begin tran
set XACT_ABORT on
set ANSI_NULL_DFLT_ON on
set ANSI_WARNINGS on
....
if @@ERROR<>0 goto Error
commit tran
set @X=0
Error:
rollback tran
set @X=1
end
DELPHI中程序代码如下:
ADOStoredProc1.Close;
ADOStoredProc1.Parameters[0].Value:=3;
ADOStoredProc1.ExecProc;
case ADOStoredProc1.Parameters.ParamByName('X').Value of
0: showmessage('return 0');
1: showmessage('return 1');
else
showmessage('return other');
end;
程序运行后出错:‘list index out of bound(0)'
请专家帮忙!
解决方案 »
- 关于界面上Tab Order 的问题
- 为什么下载的源码可以正常调试,但不能修改,修改后保存就提示出错!!!
- 数据模块怎样让他运行程序的时候最先运行,然后再运行主窗体
- Midas中 (server)远程函数 为什么不能返回值??
- 编程序完成数据库的倒入倒出,在本地局域网上已经完成,但通过internet 就不行了
- 这句SQL应怎么写?
- sql高手请进,sql出现怪事
- 如何得出一个字符在一个字符串从后往前的位置?
- 用TTreeView如何创建一棵树 ?
- 请问:如何通过*.dfm、*.dcu文件得到*.pas文件?
- 关于edit控件
- 求救啊!!!关于打开dataset的问题。——好急呵!!!!!!!!!
2、用存储过程的Result表示返回值!注意:Goto语句在SQL2000中已经不建议使用了!
ADOStoredProc1.ExecProc;
case ADOStoredProc1.Parameters.ParamByName('X').Value of
0: showmessage('return 0');
1: showmessage('return 1');
else
showmessage('return other');
end;
你的方法一样出错。
DOStoredProc1.Parameters.CreateParameter('x',ftstring,ptoutput,10,null);ADOStoredProc1.ExecProc;
case ADOStoredProc1.Parameters.ParamByName('X').Value of
0: showmessage('return 0');
1: showmessage('return 1');
else
showmessage('return other');
end;你试试希望你看看帮助!!
X的类型为什么设为ftstring?
这句运行通不过.
2、我以前的代码,参考一下:(有点长,大致看一下就知道什么意思了)
Delphi Code:
if SysDM.GetSysParam(pkOut_IsUniteRecipe)=1 then//山东省
begin
with spRecipeSettl1 do
begin
Close;
ParamByName('@XingMing').AsString:=pnlXm.Caption;
ParamByName('@ShouKuanBM').AsString:=SysDM.GetUserID;
ExecProc;
Case ParamByName('Result').AsInteger of
0:
begin
vErrstr:='更新处方主表失败';
Result:=vErrstr;
Exit;
end;
1:
begin
vErrstr:='更新处方明细表失败';
Result:=vErrstr;
Exit;
end;
2:
begin
vErrstr:='生成发票明细表失败';
Result:=vErrstr;
Exit;
end;
3:
begin
vErrstr:='生成发票主表失败';
Result:=vErrstr;
Exit;
end;
4:
begin
vErrstr:='生成发药状态表失败';
Result:=vErrstr;
Exit;
end;
5:
begin
vErrstr:='更新药房库存失败';
Result:=vErrstr;
Exit;
end;
-1:
begin
vErrstr:='生成单据号失败';
Result:=vErrstr;
Exit;
end;
-2:
begin
vErrstr:='发票已用完';
Result:=vErrstr;
Exit;
end;
end;
end;
end;
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[pOut_Chg_RecipeSettl1]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[pOut_Chg_RecipeSettl1]
GOSET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO/***********************/
/* 山东省门诊结帐 */
/***********************/
CREATE PROCEDURE pOut_Chg_RecipeSettl1(@XingMing varchar(8),@ShouKuanBM varchar(10))
AS
--Assay:
Set Nocount ondeclare @SerialNo varchar(23),@RiQi varchar(10),@DanJuID varchar(10),@Count int
declare @YingShouJE Numeric(10,2),@ShiShouJE Numeric(10,2),@RetRound Numeric(10,2),@RetRound2 Numeric(10,2),@YingShouZLJE Numeric(10,2),@ShiShouZLJE Numeric(10,2)
set @SerialNo=convert(varchar(23),getdate(),121)
set @RiQi=convert(varchar(10),getdate(),120)
Begin Tran
--删除发票临时打印表
delete Out_TempPrintInvoice where ShouKuanYBM=@ShouKuanBM
if @@Error<>0
begin
RollBack Tran
Return 12
end
--Assay:
-- Update Out_Recipe Set JieSuanBZ=1 where (convert(varchar(10),JiuZhenID)+convert(varchar(10),ChuFangLH)) in
-- (select convert(varchar(10),JiuZhenID)+convert(varchar(10),ChuFangBM) from Out_TempRecipeNo where RenYuanBM=@ShouKuanBM)
update Out_Recipe
set JieSuanBZ=1
from Out_Recipe a,Out_TempRecipeNo b
where a.JiuZhenID=b.JiuZhenID and a.ChuFangLH=b.ChuFangBM and b.RenYuanBM=@ShouKuanBM if @@Error<>0
begin
RollBack Tran
Return 0--更新处方主表
end
for
select JiuZhenID,ChuFangBM from Out_TempRecipeNo where RenYuanBM=@ShouKuanBM
Open Out_Assay
Declare @JiuZhenID2 int,@ChuFangHao2 int
Fetch Next from Out_Assay into @JiuZhenID2,@ChuFangHao2
while (@@Fetch_Status=0)
begin
exec pDoc_UpDateAssayOrExamineZT @JiuZhenID2,@ChuFangHao2,2
if @@Error<>0
begin
Close Out_Assay
Deallocate Out_Assay
RollBack Tran
Return 0 --更新检验表错误
end
Fetch Next from Out_Assay into @JiuZhenID2,@ChuFangHao2
end
Close Out_Assay
Deallocate Out_Assay
declare Out_Inv Cursor
for
select distinct JiuZhenID from Out_TempRecipeNo where RenYuanBM=@ShouKuanBM
open Out_Inv
declare @JiuZhenID int
Fetch Next from Out_Inv into @JiuZhenID
while (@@Fetch_Status=0)
begin
set @Count=0
set @YingShouJE=0.00
set @ShiShouJE=0.00
set @YingShouZLJE=0.00
set @ShiShouZLJE=0.00
declare Out_Invo Cursor
for
select HeSuanBM,Sum(JinE),Sum(ZiLiJE) from Out_RecipeDetail where JiuZhenID=@JiuZhenID and ChuFangLH
in (select ChuFangBM from Out_TempRecipeNo where JiuZhenID=@JiuZhenID and RenYuanBM=@ShouKuanBM)
Group By HeSuanBM
order by convert(int,HeSuanBM)
open Out_Invo
declare @HeSuanBM varchar(5),@JinE Numeric(10,2),@ZiLiJE Numeric(10,2)
Fetch Next from Out_Invo into @HeSuanBM,@JinE,@ZiLiJE
while (@@Fetch_Status=0)
begin
exec @DanJuID=pSys_PreGetBill @ShouKuanBM,1
if @@Error<>0
begin
Close Out_Invo
Deallocate Out_Invo
Close Out_Inv
Deallocate Out_Inv
RollBack Tran
Return -1--生成单据号错误
end
if @DanJuID=-1
begin
Close Out_Invo
Deallocate Out_Invo
Close Out_Inv
Deallocate Out_Inv
RollBack Tran
Return -2--单据已用完
end
set @Count=@Count+1
update Out_RecipeDetail Set DanJuID=@DanJuID where JiuZhenID=@JiuZhenID and ChuFangLH
in (select ChuFangBM from Out_TempRecipeNo where JiuZhenID=@JiuZhenID and RenYuanBM=@ShouKuanBM)
and HeSuanBM=@HeSuanBM
if @@Error<>0
begin
Close Out_Invo
Deallocate Out_Invo
Close Out_Inv
Deallocate Out_Inv
RollBack Tran
Return 1--更新处方明细表
end