buggy dbExpress for MSSQL

dbExpress 2002-12-16 04:54:22
我这样用dbExpress调用我的MsSql2000的存储过程:

SQLConnection1.ConnectionName = 'MSSQL';
SQLDataSet1.SQLConnection := SQLConnection1;
SQLDataSet1.SchemaName = 'dbo';
...

SQLDataSet1.SQLConnection = SQLConnection1;
SQLDataSet1.CommandType := ctStoredProc;
SQLDataSet1.CommandText := 'p1';
SQLDataSet1.ExecSQL;
Result := SQLDataSet1.ParamByName('@p1').AsInteger;

数据库里原本有存储过程
create table t1(
id integer not null primary key,
name varchar(10)
)
go

insert into t1 values ( 1 )
go

create procedure p
@p integer output
as
begin
select @p = id from t1 where id = 1
if (not exists(select * from t1 where id = 2)
insert into t1 values ( 2, '10' )
end
go

create procedure p1
@p1 integer output
as
begin
execute p @p1 output
end
go


这个存储过程在isqlw, dbGo(ADOExpress)中能够正确返回1,但是dbExpress却返回0
但是下面的能够正确返回1
SQLDataSet1.SQLConnection = SQLConnection1;
SQLDataSet1.CommandType := ctStoredProc;
SQLDataSet1.CommandText := 'p'; //p, not p1
SQLDataSet1.ExecSQL;
Result := SQLDataSet1.ParamByName('@p').AsInteger;


下面的存储过程p2也不能被dbExpress正确返回参数:
设有:

create procedure p2
@p2 integer output
as
begin
declare cursor_id cursor for
select id from t1 where id = 1

open cursor_id
fetch next from cursor_id into @p2
update t1 set
name = 'abc'
where current of cursor_id
close cursor_id
deallocate cursor_id
end
go

调用时,
SQLDataSet1.SQLConnection = SQLConnection1;
SQLDataSet1.CommandType := ctStoredProc;
SQLDataSet1.CommandText := 'p2';
SQLDataSet1.ExecSQL;
Result := SQLDataSet1.ParamByName('@p2').AsInteger;
这个存储过程同样返回0,而dbGo正确返回了1


为什么呢???是bug吗?
...全文
42 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
tommy_linux 2002-12-20
  • 打赏
  • 举报
回复

呵呵~~~~~

学习!

dbExpress 2002-12-16
  • 打赏
  • 举报
回复
对不起,写漏了,重写:


为什么我的存储过程不能正确返回参数?是bug吗?

我这样用dbExpress调用我的MsSql2000的存储过程:

SQLConnection1.ConnectionName = 'MSSQL';
SQLDataSet1.SQLConnection := SQLConnection1;
SQLDataSet1.SchemaName = 'dbo';
...

SQLDataSet1.SQLConnection = SQLConnection1;
SQLDataSet1.CommandType := ctStoredProc;
SQLDataSet1.CommandText := 'p1';
SQLDataSet1.ExecSQL;
Result := SQLDataSet1.ParamByName('@p1').AsInteger;

数据库里原本有存储过程
create table t1(
id integer not null primary key,
name varchar(10)
)
go

insert into t1 values ( 1 )
go

create procedure p
@p integer output
as
begin
select @p = id from t1 where id = 1
if (not exists(select * from t1 where id = 2))
insert into t1 values ( 2, '10' )
end
go

create procedure p1
@p1 integer output
as
begin
execute p @p1 output
end
go


这个存储过程在isqlw, dbGo(ADOExpress)中能够正确返回1,但是dbExpress却返回0
但是下面的能够正确返回1
alter procedure p
@p integer output
as
begin
select @p = id from t1 where id = 1
end
go

SQLDataSet1.SQLConnection = SQLConnection1;
SQLDataSet1.CommandType := ctStoredProc;
SQLDataSet1.CommandText := 'p'; //p, not p1
SQLDataSet1.ExecSQL;
Result := SQLDataSet1.ParamByName('@p').AsInteger;


下面的存储过程p2也不能被dbExpress正确返回参数:
设有:

create procedure p2
@p2 integer output
as
begin
declare cursor_id cursor for
select id from t1 where id = 1

open cursor_id
fetch next from cursor_id into @p2
update t1 set
name = 'abc'
where current of cursor_id
close cursor_id
deallocate cursor_id
end
go

调用时,
SQLDataSet1.SQLConnection = SQLConnection1;
SQLDataSet1.CommandType := ctStoredProc;
SQLDataSet1.CommandText := 'p2';
SQLDataSet1.ExecSQL;
Result := SQLDataSet1.ParamByName('@p2').AsInteger;
这个存储过程同样返回0,而dbGo正确返回了1


为什么呢???是bug吗?

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧