如何獲取MSSQL中StoredProc中變量的值(50分)

  • 主题发起人 dfeng_shen
  • 开始时间
D

dfeng_shen

Unregistered / Unconfirmed
GUEST, unregistred user!
請教各位,
在delphi程序中,如何獲取storedproc中變量的值,存儲過程如下:在
程序中,我如何得到@DayMk,@Save,@Rep的值.
CREATE Proc Store1(@FLNO int,@Date datetime,@Depa varchar(3)) as
declare @DayMk int, @Save int, @Rep int
IF exists (select * from table1 where pqty_flno=@flno and
pqty_date=@date and pqty_depa=@depa)
begin
select @DayMk =Pqty_DayMk from table1
select @Save=Pqty_YesSa+Pqty_ToSav-Pqty_SavTo from table1
select @Rep =Pqty_YesRe+Pqty_ToRep-Pqty_RepTo from table1
End
 
TStoredProc.ParamByName(...).AsInteger
 
pipi,這樣得到的是參數的值,而不是變量的值
 
给你一个实例,我是这样做的:storedproc控件放在应用层上,远程模块上放有
storedproc控件:StdstionSearchProc(控件名),DataSetProvider1控件:
StdstionSearchPrd(控件名),在StdstionSearchPrd的ondatarequire事件里写
入:
with StdstionSearchProcdo
begin
parambyname('@number').asinteger:=input[0];
parambyname('@parameter').asstring:=input[1];
end;
(准备接受参数)
在客户端写入:
with SetDoctorFrm(form名)do
begin
StdstionSearch.close;//StdstionSearch是ClientDataSet1的控件名
StdstionSearch.DataRequest(VarArrayof
([searchfrm.ComboBox1.ItemIndex,searchfrm.val1.Text]));
//发送参数
StdstionSearch.Open;
end;
 
wuzhenzhen,這樣操作的對象也是參數,不是存儲過程中的變量
 
CREATE Proc Store1(
@FLNO int,
@Date datetime,
@Depa varchar(3)
@DayMk int OUTPUT,
@Save int OUTPUT,
@Rep int OUTPUT
) as
IF exists (select * from table1 where pqty_flno=@flno and
pqty_date=@date and pqty_depa=@depa)
begin
select @DayMk =Pqty_DayMk from table1
select @Save=Pqty_YesSa+Pqty_ToSav-Pqty_SavTo from table1
select @Rep =Pqty_YesRe+Pqty_ToRep-Pqty_RepTo from table1
End
在ExecProc后就可以得到三个参数的值.
 
非常感謝wgzhang,問題解決.
 
多人接受答案了。
 
顶部