Sybase IQ 动态执行SQL

在Sybase IQ的环境下,我编写了一个返回结果集的sql:
begin
declare @id1 integer;
declare @s varchar(2000);
set @id1=3 ;
set @s='select *  from unit where id='+cast(@id1 as varchar);
execute(@s);
end
报错:result set not permitted in ' batch statement '
我修改成:
begin
declare @id1 integer;
declare @s varchar(2000);
set @id1=3 ;
set @s='select * into #tmp  from unit where id='+cast(@id1 as varchar);
execute(@s);
select * from #tmp;
drop table #tmp
end
把结果集返回到一个临时表中,然后在获取临时表,请问能不能把结果集返回到一个游标中,此外我想返回这个表的记录条数到当前的一个变量中:
BEGIN
  declare  @a  int
declare  @cmd  varchar(200)  
select  @cmd= 'select  count(*)  into #temp from  unit'
execute(@cmd)
select  expression into @a from #temp  -- expression是临时表的唯一字段名称
truncate table #temp
select @a
END
试问下还有其他办法不通过临时表来实现吗?像SQL Server那样定义参数就可以实现

作者: plfire   发布时间: 2010-08-19

临时表可以吗?至少ASE是不行的。

IQ不懂,ASE从动态SQL中返回结果集只能通过真实表的方式。

作者: jarjar   发布时间: 2010-08-21