zoukankan      html  css  js  c++  java
  • oracle 自定义类型

    ex1:

    RIGHTOBJECT是UserID,RightTypeId,UserDutyId,RightId,RightFlag集合类型

    CREATE OR REPLACE TYPE "RIGHTOBJECT"                                                                                                                                                                                                                            as object
    (
    UserID number,
    RightTypeID number,
    UserDutyID number,
    RightID number,
    RightFlag number
    )

    RIGHTOBJECTCOLLECTION 是RIGHTOBJECT的集合类型

    CREATE OR REPLACE TYPE "RIGHTOBJECTCOLLECTION"  as table of rightobject

    用法:

    function getuserrightlist(userid      sys_userinfo.userid%type,
                                righttypeid rgt_righttype.righttypeid%type)
        return rightobjectcollection as
        result rightobjectcollection;
      begin
        result := rightobjectcollection();
     
        for mycs in (
                     --个人自定义权限
                     select *
                       from rgt_userright
                      where userid = getuserrightlist.userid
                        and righttypeid = getuserrightlist.righttypeid) loop
          result.extend;
          result(result.count) := rightobject(0, 0, 0, 0, 0);
          result(result.count).userid := mycs.userid;
          result(result.count).righttypeid := mycs.righttypeid;
          result(result.count).rightid := mycs.rightid;
          result(result.count).userdutyid := mycs.userdutyid;
          result(result.count).rightflag := mycs.rightflag;
       
        end loop;
      
     
        --插入个人用户组的权限  
        for mycs in (select rightid,
                            righttypeid,
                            max(rightflag) rightflag,
                            getuserrightlist.userid
                       from rgt_rightgroupcontent
                      where rightgroupid in
                            (select rightgroupid
                               from rgt_usergroupright
                              where usergroupid in
                                    (select distinct usergroupid
                                       from sys_groupuser
                                      where userid = getuserrightlist.userid))
                        and righttypeid = getuserrightlist.righttypeid
                        and rightid not in (select rightid from table(result))
                      group by rightid, righttypeid /*,rightgroupid*/) loop
          result.extend;
          result(result.count) := rightobject(0, 0, 0, 0, 0);
          result(result.count).userid := mycs.userid;
          result(result.count).righttypeid := mycs.righttypeid;
          result(result.count).rightid := mycs.rightid;
          result(result.count).rightflag := mycs.rightflag;
        end loop;
       return result;
      end;

  • 相关阅读:
    Linux KVM
    linux 下添加,修改,删除路由
    爬虫之requests urllib urllib2 BeautifulSoup
    MyBatis-Plus+mysql5.7 动态拼接sql语句 分页查询 自定义sql 查询条件 分组 排序
    springboot2.x+neo4j创建图形数据库
    linux(centos7)下springboot项目jar包使用shell脚本运行
    java网络爬虫-利用phantomjs和jsoup爬取动态ajax加载页面
    springboot开发qq第三方授权登录
    linux(centos7)下nginx访问静态文件403错误解决过程
    idea2019.2+springboot2.2.1版本配置热部署
  • 原文地址:https://www.cnblogs.com/kelly/p/1280189.html
Copyright © 2011-2022 走看看