Alternate of sys_refcursor

心不动则不痛 提交于 2019-12-12 06:56:11

问题


What is the alternate of sys_refcursor.

After 12c upgrade, the resultset of sys_refcursor is unrecognizable by mulesoft/tibco. Reading it as null


回答1:


Use

TYPE cursor_type IS REF CURSOR;

or a strongly typed cursor:

CREATE PACKAGE SCHEMA_NAME.PACKAGE_NAME
AS
  TYPE Table_Name_Cursor IS REF CURSOR RETURN SCHEMA_NAME.TABLE_NAME%ROWTYPE;

  -- You said this does not work.
  -- PROCEDURE get_Weakly_Typed_Cursor (
  --   out_cursor OUT SYS_REFCURSOR
  -- );

  PROCEDURE get_Strongly_Typed_Cursor (
    out_cursor OUT Table_Name_Cursor
  );
END;
/

CREATE PACKAGE BODY SCHEMA_NAME.PACKAGE_NAME
AS
  PROCEDURE get_Strongly_Typed_Cursor (
    out_cursor OUT Table_Name_Cursor
  )
  AS
  BEGIN
    OPEN out_cursor FOR
    SELECT * FROM SCHEMA_NAME.TABLE_NAME;
  END;
END;
/



回答2:


You can define your own ref cursor type:

TYPE my_ref_cursor_type is REF CURSOR;
v_cursor my_ref_cursor_type;

But it would only make sense to do that if using a very old version of Oracle that didn't have SYS_REFCURSOR!



来源:https://stackoverflow.com/questions/35503839/alternate-of-sys-refcursor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!