在delphi中,用storeproc調用一個還游檔的存儲過程.我是先寫那個存儲過程的.好像在sql server 中,游標只能訂義成外部參數,但是在delphi中怎么樣把這個游標傳進去呀.我是這樣子寫的.
create procedure DBO.proc_1
@cloumns1 char(8),
@C_Cur Cursor vaying output
as
set nocount on
begin
set @C_Cur = Cursor for
select * from table1
open @C_Cur
declare @row int
Set @Row = @@Cursor_Rows
while @Row > 0
begin ....
....
Set @Row = @Row -1
end
close @C_Cur
end
create procedure DBO.proc_1
@cloumns1 char(8),
@C_Cur Cursor vaying output
as
set nocount on
begin
set @C_Cur = Cursor for
select * from table1
open @C_Cur
declare @row int
Set @Row = @@Cursor_Rows
while @Row > 0
begin ....
....
Set @Row = @Row -1
end
close @C_Cur
end
函数名称:MaxVal()
函功能功:取得数据字典表中某表的最大编号
参数1:TableName:指定要取最大值的表名
参数2:FieldName:字段名
返回值:取得的最大编号
////////////////////////////////////////////////////////////////}
function MaxVal(TableName: string) : integer;
var
ADOQMax:TADOQuery;
begin
ADOQMax := TADOQuery.Create(nil);
ADOQMax.ConnectionString:=connstr;
with ADOQMax do
begin
//取编号的最大值
Close;
SQL.Clear;
SQL.Add('declare @GetMax int' + #13);
SQL.Add('exec @GetMax = SET_MAX '+''''+TableName+''''+','+'1'+#13);
SQL.Add('select @GetMax as fname');
Open;
MaxVal := FieldByName('fname').AsInteger; end;
end;
这是我写的一个在Delphi中调用存储过程的例子