We're taking a break this week as Connor and Chris will both be at CloudWorld, the premier Oracle conference of 2024. If you're in Vegas, please come say Hi or pop into our sessions
Thanks for the question, Sunny.
Asked: July 06, 2019 - 5:31 pm UTC
Last updated: July 11, 2019 - 3:03 pm UTC
Version: 12c
Viewed 10K+ times! This question is
John Keymer, July 08, 2019 - 10:57 am UTC
Rajeshwaran Jeyabal, July 16, 2019 - 6:44 am UTC
demo@PDB1> create table t as select * from emp; Table created. demo@PDB1> begin 2 dbms_fga.add_policy(object_schema=>user, 3 object_name=>'T', 4 policy_name=>'T_ACCESS_POLICY' ); 5 end; 6 / PL/SQL procedure successfully completed. demo@PDB1> variable x1 number demo@PDB1> variable x2 varchar2(20) demo@PDB1> variable x3 varchar2(20) demo@PDB1> exec :x1 := 10; :x2 := 'KING'; :x3 := '15-Aug-2019'; PL/SQL procedure successfully completed. demo@PDB1> select count(*) from t where deptno = :x1; COUNT(*) ---------- 3 demo@PDB1> col db_user format a5 demo@PDB1> col sql_text format a30 demo@PDB1> col sql_bind format a15 demo@PDB1> col policy_name format a15 demo@PDB1> select db_user,sql_text,sql_bind,policy_name 2 from dba_fga_audit_trail 3 where policy_name ='T_ACCESS_POLICY' ; DB_US SQL_TEXT SQL_BIND POLICY_NAME ----- ------------------------------ --------------- --------------- DEMO select count(*) from t where d #1(2):10 T_ACCESS_POLICY eptno = :x1 demo@PDB1> select count(*) from t where ename = :x2; COUNT(*) ---------- 1 demo@PDB1> select db_user,sql_text,sql_bind,policy_name 2 from dba_fga_audit_trail 3 where policy_name ='T_ACCESS_POLICY' ; DB_US SQL_TEXT SQL_BIND POLICY_NAME ----- ------------------------------ --------------- --------------- DEMO select count(*) from t where d #1(2):10 T_ACCESS_POLICY eptno = :x1 DEMO select count(*) from t where e #1(4):KING T_ACCESS_POLICY name = :x2 demo@PDB1> select count(*) from t where hiredate < to_date(:x3,'dd-mon-yyyy'); COUNT(*) ---------- 14 demo@PDB1> select db_user,sql_text,sql_bind,policy_name 2 from dba_fga_audit_trail 3 where policy_name ='T_ACCESS_POLICY' ; DB_US SQL_TEXT SQL_BIND POLICY_NAME ----- ------------------------------ --------------- --------------- DEMO select count(*) from t where d #1(2):10 T_ACCESS_POLICY eptno = :x1 DEMO select count(*) from t where e #1(4):KING T_ACCESS_POLICY name = :x2 DEMO select count(*) from t where h #1(11):15-Aug- T_ACCESS_POLICY iredate < to_date(:x3,'dd-mon- 2019 yyyy') demo@PDB1> demo@PDB1> demo@PDB1> exec :x1 := 20; PL/SQL procedure successfully completed. demo@PDB1> select count(*) from t where deptno = :x1; COUNT(*) ---------- 5 demo@PDB1> select db_user,sql_text,sql_bind,policy_name 2 from dba_fga_audit_trail 3 where policy_name ='T_ACCESS_POLICY'; DB_US SQL_TEXT SQL_BIND POLICY_NAME ----- ------------------------------ --------------- --------------- DEMO select count(*) from t where d #1(2):10 T_ACCESS_POLICY eptno = :x1 DEMO select count(*) from t where e #1(4):KING T_ACCESS_POLICY name = :x2 DEMO select count(*) from t where h #1(11):15-Aug- T_ACCESS_POLICY iredate < to_date(:x3,'dd-mon- 2019 yyyy') DEMO select count(*) from t where d #1(2):20 T_ACCESS_POLICY eptno = :x1 demo@PDB1>
The Oracle documentation contains a complete SQL reference.