火鸟定义带返回的存储过程是这样,先定义返回结果字段列表,然后为返回字段一一赋值,当你需要返回一行时,就suspend。
当需要返回多行时,就再次为返回字段变量赋值,suspend。
示例:
1 create or alter procedure GET_BATCH 2 returns ( 3 ADDR varchar(10), 4 BATCH varchar(10)) 5 as 6 declare variable MTH varchar(10); 7 begin 8 /* Procedure Text */ 9 :addr = 'Shang Hai'; 10 11 select extract(month from current_date) from rdb$database into :mth; 12 if(char_length(:mth) = 1) then 13 :mth = '0' || :mth; 14 15 select extract(year from current_date) || :mth || extract(day from current_date) 16 from rdb$database into :batch; 17 suspend; 18 19 end
调用方式: select * from get_batch;
结果: