Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select from execute block?

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!

like image 959
Steve88 Avatar asked Sep 14 '25 22:09

Steve88


1 Answers

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
like image 195
JPB31 Avatar answered Sep 17 '25 20:09

JPB31