VERIFY_ROLE_FOR_USER scalar function
The VERIFY_ROLE_FOR_USER function returns a value that indicates whether any of the roles associated with the authorization ID identified by the SESSION_USER special register are in (or contain any of) the role names specified by the list of role-name-expression arguments.
The schema is SYSIBM. The function name cannot be specified as a qualified name.
- An expression that specifies a role name (SQLSTATE 42815). The existence of the role name at the current server is not verified. role-name-expression must return a built-in character string data type or graphic string data type that is not a LOB (SQLSTATE 42815). The content of the string is not folded to uppercase and is not left-aligned.
The result of the function is an integer. The result cannot be null. The result is 1 if any of the roles associated with the authorization ID identified by the SESSION_USER special register are in (or contain any of) the role names specified by the list of role-name-expression arguments. Otherwise, the result is 0.
CREATE PERMISSION TELLER_ROW_ACCESS ON CUSTOMER FOR ROWS WHERE VERIFY_ROLE_FOR_USER(SESSION_USER,'TELLER') = 1 AND BRANCH = (SELECT HOME_BRANCH FROM INTERNAL_INFO WHERE EMP_ID = USER) ENFORCED FOR ALL ACCESS ENABLE
CREATE PERMISSION ROLEACCESS ON CUSTOMER FOR ROWS WHERE (VERIFY_ROLE_FOR_USER(SESSION_USER, ACCESS_ROLE) = 1) ENFORCED FOR ALL ACCESS ENABLE