0

是否可以根据用户权限在视图中有多个选择语句?或者什么应该是好的做法?我想要一个仅根据用户权限显示数据的视图。该视图将具有代码 USER_ID = (SELECT SYSTEM_USER)我计划使用 Windows 身份验证。

我希望用户 abc@company.com 可以看到 TRANS 表中的所有数据,用户 def@company.com 只能看到基于 SUPERVISOR'S QUERY 的数据,用户 ghi@company.com 可以看到基于 USER'S QUERY 的所有数据。

经理的询问

    SELECT OrderNum, total, CustomerNum, Invoice, Order_Date, Region   FROM TRANS

主管的询问

    SELECT OrderNum, total, Invoice, Order_Date, Region   FROM TRANS

用户查询

    SELECT OrderNum, total, Order_Date, Region   FROM TRANS
    WHERE only allow user to see the region assigned to them, example user with Region_N in 
    PERM_GROUP from Table: EMPLOYEE should only see data in Region "N"

表:员工

         USER_ID        |     PERM_GROUP     
    --------------------------------------
    abc@company.com     |  Manager   
    def@company.com     |  Supervisor
    ghi@company.com     |  User; Region_N

表:反式

    OrderNum  |  Total  | CustomerNum | Invoice |  Order_Date  |  Region  
    -----------------------------------------------------------------
    25986     |  100    |  Yahoo123   | ad589   |  10-28-12    |  N
    87456     |  700    |  Google856  | cb124   |  05-17-12    |  E
    30123     |  450    |  MSN907     | ab456   |  01-22-10    |  S
4

0 回答 0