Access rule examples

The following examples show how access rules return specific rows containing information limited by access rules.

Example 1

This example returns information from two rows.

/* return rows when empno = 1 and deptno = 2
and ( name = "smith" or phone = "9999" )
*/select * from testtab1 empno       deptno      name       phone------------ ----------- ---------- -----           1           2 smith      8282           1           2 jones      9999(2 rows affected)
/* unbind access rule from specific column */sp_unbindrule "testtab1.empno",NULL,"accessrule"/*Rule unbound from table column.*/

(return status = 0)

Example 2

This example returns information from four rows.

/* return rows when deptno = 2 and ( name = "smith"
or phone = "9999" )*/select * from testtab1 empno       deptno      name       phone ----------- ----------- ---------- -----           1           2 smith      8282                      2           2 smith      9999           3           2 smith      8888           1           2 jones      9999(4 rows affected)/* unbind all deptno rules from specific column */sp_unbindrule "testtab1.deptno",NULL,"all"
/*Rule unbound from table column.*/(return status = 0)

Example 3

This example returns information from six rows.

/* return the rows when name = "smith" or phone = "9999" */select * from testtab1 empno       deptno      name       phone ----------- ----------- ---------- -----           1           1 smith      3245           1           2 smith      8282           2           2 smith      9999           3           2 smith      8888           1           2 jones      9999           2           3 jones      9999