Single permission with a dependent table
Example 3: Using a single permission with the users defined in a dependent table.
CREATE SCHEMA MY_LIB
CREATE SCHEMA RCAC_DEPENDENT
CREATE TABLE MY_LIB.PERMISSION_TABLE (COLUMN1 INT)
CREATE TABLE RCAC_DEPENDENT.USERS (USERNAME CHAR (10))
INSERT INTO RCAC_DEPENDENT.USERS
VALUES('USER1 '),('USER2 '),('USER3 ')
CREATE TABLE MY_LIB.PERMISSION_TABLE (FIELD1 INT)
CREATE PERMISSION MY_LIB.PERM1 ON MY_LIB.PERMISSION_TABLE
FOR ROWS WHERE
CURRENT_USER IN (SELECT USERNAME FROM RCAC_DEPENDENT.USERS)
ENFORCED FOR ALL ACCESS ENABLE
ALTER TABLE MY_LIB.PERMISSION_TABLE ACTIVATE ROW ACCESS CONTROL
/***********************************************************************/
/* Sign on as USER1 */
/***********************************************************************/
INSERT INTO MY_LIB.PERMISSION_TABLE VALUES(1) /* Allowed. */
The advantage of a single permission checking a dependent table is that when adding another user, the permission does not have to change. The disadvantage is the performance consideration of querying the dependent table.