如果要在 foreach 循环中执行某些处理,则必须SELECT INTO变量。所以你的代码会变成:
drop procedure if exists _this_is_it ;
drop table if exists this_table ;
create temp table this_table(column1 CHAR(3), column2 CHAR(4), column3 CHAR(3))
with no log ;
insert into this_table values("A","B","C") ;
create procedure _this_is_it(this CHAR(3), that CHAR(4), other CHAR(3))
returns CHAR(10) AS something
define f_this CHAR(3) ;
define f_that CHAR(4) ;
define f_other CHAR(3) ;
foreach
select * into f_this, f_that, f_other
from this_table
where column1 = this and
column2 = that and
column3 = other
return f_this||f_that||f_other WITH RESUME ;
end foreach
end procedure;
grant execute on _this_is_it to public;
execute procedure _this_is_it("A","B","C") ;
drop procedure if exists _this_is_it ;
drop table if exists this_table ;
FOREACH 语句的语法可从 IBM 的Infocenter获得。