A method and mechanism are provided for accessing data. Values are stored
for a set of context attributes associated with a session between a
database user and a database server. The database system includes an
attribute setting mechanism that selectively restricts access to the set
of context attributes based on a policy. During the session, the database
server executes a query that contains a reference to one or more of the
context attributes. For example, the query may contain a predicate that
requires a comparison between a context attribute value and a constant.
The database server processes the query based on current values of the
one or more of the context attributes referenced in the query. A
mechanism is also provided for dynamically attaching predicates to
queries, where the predicates are attached based on a policy. For
example, the database system detects that a query is issued against a
database object. Prior to executing the query, a policy function
associated with the database object is invoked. The policy function
creates a modified query by selectively adding zero or more predicates to
the query based on a policy associated with the database object. The
modified query is then executed.