oracle - How to get return value from stored procedure with output parameter in Grails? -


i have stored procedure has output parameter cursor

here's code stored procedure use, don't know how return value

def kf_fpy sql.call("{call calfpy(?,?,?,?,?)}",[workcenter,product,stattime,endtime,sql.resultset(oracletypes.cursor)])  {                 cursorresults ->                    cursorresults.eachrow() {                         x ->                           kf_fpy = x.getat('kf_fpy')//error occured                    } } 

and got error "method threw 'java.lang.nullpointerexception' exception. cannot evaluate $proxy11.tostring()"

stored procedure:

procedure calfpy(workcenter in varchar2,produ in varchar2,stdt in varchar2,etdt in varchar2,p_out out pkg_package.type_cursor) 

pkg_package:

create or replace package pkg_package   type type_cursor ref cursor;  type type_record record  (  kf_ws varchar2(20),  kf_fpy number, kf_tfpy number, kf_pro varchar2(200)  );  end; 

enter image description here

check out this solution:

procedure:

create or replace procedure grails_example (   v_name in varchar2,   ref_cur1 in out sys_refcursor ) begin    open ref_cur1   select upper(v_name) upper_name   dual;  end grails_example; 

controller calls procedure:

    string uppername;     sql.call("begin grails_example(?,?); end;",             [params.name, sql.resultset(oracletypes.cursor)]) {cursorresults ->              if (cursorresults.next()) {                  uppername = cursorresults.getat('upper_name');             }      } 

if need @ field isn't aliased in proc can still access index. example follow work in above controller:

uppername = cursorresults.getat(0) 

if need more values procedure check out this answer.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -