调用SQL语句的函数

CREATE OR REPLACE FUNCTION GetSplitName(v_value IN VARCHAR2)
  RETURN VARCHAR2 IS
  strSql     VARCHAR2(2000) := ' select listagg(username,'|| '''' || ',' || ''''||
                               ') within group (order by rownum) from sec_userinfo where loginname in (select * from table(split_STR(';
  strName    VARCHAR2(2000) := '';
  get_matou_ sys_refcursor;
BEGIN
  strSql := strSql || v_value || ',' || '''' || ',' || '''' || ')))';
  Dbms_Output.put_line(strSql);
  begin
    Open get_matou_ FOR strSql;
    Fetch get_matou_
      Into strName;
    Close get_matou_;
  end;
  RETURN strName;
END GetSplitName;

posted @ 2013-06-09 17:25  UnDefault  阅读(601)  评论(0编辑  收藏  举报