-->

Select from execute block?

2019-07-10 04:26发布

问题:

Is is possible to select from execute block result? I want to perform some operation (sum etc..) from it.

 select t1.* 
 from 
   ( execute block 
     returns ( 
       OUT_VALUE integer ) 
    as 
    begin 
    ... 
    suspend; 
  end ) t1

or

 with   
 t1 as ( execute block ... ) 
   select * 
   from t1 
   order by 
     t1.sort_column 

Neither does not work. Anyone has an advice? Thanks!

回答1:

You should create an independent stored procedure like

create procedure proc1
returns (
  OUT_VALUE integer 
) as
begin
   ... 
  suspend; 
end

and then select on this proc

select sum(OUT_VALUE)
from proc1