我想创建一个行级安全策略。
我的输入是通过中间层应用程序连接到数据库的用户的 user_id。
我想:
- 查询一张配置表(姑且称之为
conf_table
)获取部门名称user_id
- 根据值
department
,我想在另一个表customers
上进行过滤type_of_customers
。
例子:
conf_table
:
用户身份 | 部 |
---|---|
多多 | 悉尼 |
顾客:
客户编号 | typ_customer |
---|---|
0001 | 一个 |
0002 | 乙 |
功能:
IF conf_table.user_id = 'toto' AND conf_table.department = 'sidney'`
SELECT *
FROM customers
WHERE typ_customer = A`
ELSE
SELECT *
FROM customers
WHERE typ_customer = B`
非常感谢您的帮助!