Execute anonymous pl/sql block and get resultset in java

前端 未结 3 1021
-上瘾入骨i
-上瘾入骨i 2020-11-28 09:15

I would like to execute the anonymous PL/SQL and need to get the resultset object. I got the code which can be done by using cursors inside the PL/SQL block.

But the

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-28 09:48

    Try something like this (pseudo-code):

    [create or replace] function get_dataset (p_query in varchar2) return sys_refcursor
    as
      l_returnvalue sys_refcursor;
    begin
      open l_returnvalue for p_query;
      return l_returnvalue;
    end get_dataset;
    

    The REF CURSOR which is returned can be processed like a normal dataset.

    And beware of SQL injection when you use an approach like this...

提交回复
热议问题