如何借助out参数或局部变量从db2存储过程中获取结果集

时间:2015-01-29 11:34:39

标签: stored-procedures db2 cognos

我编写了一个存储过程如下:

create procedure return_dates
(in date_range_string char(50),
in report_id integer
)
language sql
dynamic result sets 2

begin
DECLARE paid_strt_dt varchar(250);
DECLARE paid_end_dt varchar(250);
DECLARE c1 CURSOR WITH RETURN FOR s1;
DECLARE c2 CURSOR WITH RETURN FOR s2;

if date_range_string='prior month' then
    set paid_strt_dt = 'select (current date - 1 month) + 1 days - day(current date - 1 month) days from sysibm.sysdummy1';
    set paid_end_dt = 'select current date - day(current date) days from sysibm.sysdummy1';
end if;

PREPARE s1 FROM paid_strt_dt;
OPEN c1;

PREPARE s2 FROM paid_end_dt;
OPEN c2;
end

我收到错误,说我的prepare语句包含空字符串。我试图将此存储过程作为查询主题导入到cognos框架管理器中,当我验证查询时,此错误即将发生。从db2存储过程使用cognos框架管理器获取结果集的最佳方法是什么,它可以从上面的代码返回paid_strt_dt和paid_end_dt。

0 个答案:

没有答案