1、无需调整存储过程,直接提交后台执行
Query1.Close;
Query1.CommandText := P_INYEAR_CWYS 参数1, 参数2, 参数N';
Query1.Execute;
2、create PROCEDURE P_INYEAR_CWYS (@AS_YEAR CHAR(4),@AS_YEAR1 CHAR(4),@AS_LCID VARCHAR(32)) AS
declare @as_return varchar(20)
INSERT TABLE_JH_ND_CWYSJH (ND,XH,XM,LCID) SELECT @AS_YEAR1,XH,XM,@AS_LCID FROM TABLE_JH_ND_CWYSJH WHERE ND=@AS_YEAR
select @as_return
或者 create PROCEDURE P_INYEAR_CWYS (@AS_YEAR CHAR(4),@AS_YEAR1 CHAR(4),@AS_LCID VARCHAR(32)) AS
declare @as_return varchar(20)
INSERT TABLE_JH_ND_CWYSJH (ND,XH,XM,LCID) SELECT @AS_YEAR1,XH,XM,@AS_LCID FROM TABLE_JH_ND_CWYSJH WHERE ND=@AS_YEAR
select ''
然后:
var
p1: TDataParam;
begin
DataSetsp3.StoredProcName := 'dbo.Business3_5';
DataSetsp3.Params.Clear;
p1 := TDataParam.Create(DataSetsp3.Params, TParamType.ptInput);
p1.Name := '@p1';
p1.AsString := '4';
try
DataSetsp3.Open;
finally
p1.Free;
end;
end;
注意此时因为有返回结果集,要用Open而不是Exceute了。 |