请问如何才得到存储过程执行结果?存储过程:
CREATE PROCEDURE hj01
AS
begin tran
delete temphj01
insert into temphj01 select a from temp group by aif @@error<>0 goto procommit transactionreturn 0
pro:
rollback transaction
return 1
GO调用方法1a:
with ADOQuery2 do
begin
Close;
SQL.Clear;
SQL.Add('exec hj01');
Open;
end;调用方法1b:
with ADOQuery2 do
begin
Close;
SQL.Clear;
SQL.Add('exec hj01');
Open;
s:= ADOQuery2.Fields[0].AsString;
end;结果:存储过程有执行,但有错信息:CommandText does not return a result set.调用方法2:
with ADOQuery2 do
begin
Close;
SQL.Clear;
SQL.Add('exec hj02');
ExecSQL;
s:= ADOQuery2.Fields[0].AsString;
end;结果:存储过程有执行,但有错信息:List index out of bounds(0)调用方法3:
with ADOQuery2 do
begin
Close;
SQL.Clear;
SQL.Add('exec hj01');
ExecSQL;
end;
结果:没有出错信息,存储过程正常执行,没有出错信息,但不知什么时候完成
CREATE PROCEDURE hj01
AS
begin tran
delete temphj01
insert into temphj01 select a from temp group by aif @@error<>0 goto procommit transactionreturn 0
pro:
rollback transaction
return 1
GO调用方法1a:
with ADOQuery2 do
begin
Close;
SQL.Clear;
SQL.Add('exec hj01');
Open;
end;调用方法1b:
with ADOQuery2 do
begin
Close;
SQL.Clear;
SQL.Add('exec hj01');
Open;
s:= ADOQuery2.Fields[0].AsString;
end;结果:存储过程有执行,但有错信息:CommandText does not return a result set.调用方法2:
with ADOQuery2 do
begin
Close;
SQL.Clear;
SQL.Add('exec hj02');
ExecSQL;
s:= ADOQuery2.Fields[0].AsString;
end;结果:存储过程有执行,但有错信息:List index out of bounds(0)调用方法3:
with ADOQuery2 do
begin
Close;
SQL.Clear;
SQL.Add('exec hj01');
ExecSQL;
end;
结果:没有出错信息,存储过程正常执行,没有出错信息,但不知什么时候完成
解决方案 »
- 如何实现对mms网址的有效性验证?
- SimpleDataSet中如何使用 SQL 2000 SERVER 的存储过程!
- 十万火急:请教如何把jpg图片文件插入到Excel的一个表格中?
- 请教一个关于事务的问题,困扰了很久
- 谁有delphi控制javascript 的详细资料
- 如何在Integer类型中使用/(除)啊 ??
- (小问题)改form中的image的大小
- 想问如何使dbgrid中的部分列的数据内容是可改写的,其它列是只读的
- 我的老婆看过来!
- error Undeclared identifier:'Tguessform'
- 如何返回ShellListView选中的文件名?
- delphi中有最大化事件和最小化事件么?
1a,1b就都可以了;
2要在execsql后面加上active:=True; 加上后也是可以的,这里的 SQL.Add('exec hj02');不知道是不是笔误。
如果要用 QUERY 调用,把:
CREATE PROCEDURE hj01
AS
begin tran
delete temphj01
insert into temphj01 select a from temp group by a
if @@error<>0 goto pro
commit transaction
return 0
pro:
rollback transaction
return 1
GO改成:
CREATE PROCEDURE hj01
AS
begin tran
delete temphj01
insert into temphj01 select a from temp group by a
if @@error<>0 goto pro
commit transaction
select 0
pro:
rollback transaction
select 1
GO
?
3:execsql;这句代码执行完。存储过程也就执行完成了.
你是意思是要存储过程执行完,程序才会运行后面的代码吗?