zoukankan      html  css  js  c++  java
  • 如何编写管道函数

    管道函数:用于返回一个集合,通常函数只返回一个值.

    create or replace package PKG_USER_ORG_EXTEND_HELPER is
      type tp_map is record(
                    objId varchar2(50),
                    val   varchar2(200)

                 );
      type tp_maps is table of tp_map;
      type cur is ref cursor;
      function getUserExtendAttr(attrCode varchar2) return tp_maps pipelined;
      function getOrgExtendAttr(attrCode varchar2) return tp_maps pipelined;
    end;
    /

    create or replace package body PKG_USER_ORG_EXTEND_HELPER is
    -- TODO
    function getUserExtendAttr(attrCode varchar2) return tp_maps pipelined is
    begin
    return;
    end;

    function getOrgExtendAttr(attrCode varchar2) return tp_maps pipelined is
    p_mark number(4) := 2; p_attri_field varchar2(30); p_map tp_map; p_sql varchar2(4000); p_list cur;
    begin
    select d.attri_field
      into p_attri_field
      from top_expand_attri_define d
     where d.mark = p_mark
       and d.attri_code = attrCode;
    p_sql := 'select o.org_id,a.' || p_attri_field || '
    from top_expand_attribute a,top_organization o
    where a.attri_object_id=o.org_id
    and o.state = 1 and a.mark = :mark';

    open p_list for p_sql using p_mark;

    loop fetch p_list into p_map.objId, p_map.val;

    exit when p_list % notfound;

    pipe row(p_map);
    end loop; return;
    end;
    end;
    /

  • 相关阅读:
    你知道RAID的初始化过程吗?
    Dynamic Disk Pool技术解析
    Ubuntu-16.04.6 安装 oracle 11.2.0.4 数据库database软件
    Ubuntu-16.04.6 安装 oracle 12.2.0.1 数据库database软件
    IDEA 快捷键
    Redis 常用操作命令
    甘特图
    PERT图
    现金贷
    线上信贷提供解决方案
  • 原文地址:https://www.cnblogs.com/HondaHsu/p/4227922.html
Copyright © 2011-2022 走看看