CREATE procedure InputMingxi
@sGongling varchar(20),
@sTuhao varchar(30),
@iReturnValues int OUTPUTas
declare @iCount int
set @iCount=0
set @iReturnValues =0
begin transaction
select @iCount=count(*) from gongling where gongling=@sGongling
if @@error<>0
begin
rollback transaction
set @iReturnValues=1
end
if @iCount<1 --插入数据
begin
insert into gongling
values(@sGongling,@sTuhao)
if @@error<>0
begin
rollback transaction
set @iReturnValues=1
end
else
commit transaction
end
else --更新数据
begin
update gongling set tuhao=@sTuhao where gongling=@sGongling
if @@error<>0
begin
rollback transaction
set @iReturnValues=1
end
else
commit transaction
end
GO
================================================
我在delphi中执行存储过程 要通过返回值 @iReturnValues 来决定下一步做什么,应该怎样使用啊。
with adostoredproc1 do
begin
Close;
Parameters.ParamByName('@sGongling').Value := Edit1.text;
Parameters.ParamByName('@AccountNo').Value := Edit2.text;
//第三个参数怎样使用
ExecProc;
//怎样使用返回值????
end==================================
@sGongling varchar(20),
@sTuhao varchar(30),
@iReturnValues int OUTPUTas
declare @iCount int
set @iCount=0
set @iReturnValues =0
begin transaction
select @iCount=count(*) from gongling where gongling=@sGongling
if @@error<>0
begin
rollback transaction
set @iReturnValues=1
end
if @iCount<1 --插入数据
begin
insert into gongling
values(@sGongling,@sTuhao)
if @@error<>0
begin
rollback transaction
set @iReturnValues=1
end
else
commit transaction
end
else --更新数据
begin
update gongling set tuhao=@sTuhao where gongling=@sGongling
if @@error<>0
begin
rollback transaction
set @iReturnValues=1
end
else
commit transaction
end
GO
================================================
我在delphi中执行存储过程 要通过返回值 @iReturnValues 来决定下一步做什么,应该怎样使用啊。
with adostoredproc1 do
begin
Close;
Parameters.ParamByName('@sGongling').Value := Edit1.text;
Parameters.ParamByName('@AccountNo').Value := Edit2.text;
//第三个参数怎样使用
ExecProc;
//怎样使用返回值????
end==================================
给你个adoquery的调用方法
/*
declare @return varchar(8)
exec testout @return output
print @Return
*/alter procedure testout
@returnstr varchar(8) output
asselect @returnStr = convert(varchar(8),getdate(),108)procedure TForm1.Button1Click(Sender: TObject);
begin
with adoquery1 do
begin
close;
sql.clear;
sql.Text := ' exec testout :Return output ';
execsql;
showmessage(Parameters.ParamByName('Return').Value);
end;
end;