cuba-platform / yarg

Yet Another Report Generator - CUBA Platform reporting engine
https://www.cuba-platform.com
Apache License 2.0
239 stars 75 forks source link

SQL refcursor type data #164

Open iavasiljeva opened 2 years ago

iavasiljeva commented 2 years ago

Hi,

Is there any ability to work with SQL refcursor type?

e.g. we have function returning refcursor with data we need to insert into the template: select Report0302.cCardStaff(idp, dpdate)

CREATE OR REPLACE FUNCTION Report0302.cCardStaff(idp numeric, dpdate timestamp without time zone)
 RETURNS refcursor
 LANGUAGE plpgsql
AS $function$
declare
  p_cursor  refcursor;

begin
 open p_cursor for 
  select AllRep.*
    from AllRep
        where id = idp and dpdate between dbegin and dend
        order by sLevel, nLevelOrder;
   return p_cursor;      

end;
$function$
;

now it results into the error ОШИБКА: курсор "<unnamed portal 1>" не существует Query: select Report0302.cCardStaff(?::numeric,sysdate()) Parameters: [1.0]

It is a simple example, in reality we have difficult logic with dynamically changing querys, so just taking select-part to insert into the reporting tool is not an option.