Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Setting Application Context in Oracle for RLS

Posted on 2011-09-15
3
Medium Priority
?
347 Views
Last Modified: 2012-05-12
Dear All,
I have a requirement.
I have web Based Oracle Application (Oracle Forms 10gAs and Oracle 10g DB).
There are approx. 800 application userid but only one DB User .
All application userid is maintained in a table (say T_USER_MASTER).
Each application Userids is associated with one user role or more (stored in T_USER_ROLE).
I want to restrict one column(Col1) of a table (say T1) for all application userid other than one who is doctor (Role).

I want to do this through RLS but I do not know where ,when & how to set system context for this.
Pls.let me know the steps to be followed.
0
Comment
Question by:surendra_oracle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 74

Accepted Solution

by:
sdstuber earned 2000 total points
ID: 36548963
contexts are set using a procedure or package.  you define that object when you create the context

for instance...


CREATE OR REPLACE CONTEXT my_context USING context_test_pkg;  

CREATE OR REPLACE PACKAGE context_test_pkg
AS
    PROCEDURE set_context;
END;

CREATE OR REPLACE PACKAGE BODY context_test_pkg
AS
    PROCEDURE set_context
    IS
    BEGIN
            DBMS_SESSION.set_context('my_context',
                                    'some_name',
                                    'some_value'
                                    );

             DBMS_SESSION.set_context('my_context',
                                    'some_other_name',
                                    'some_other_value'
                                    );
    END;
END;
0
 

Author Comment

by:surendra_oracle
ID: 36552765
Thanks.
I do not understand "you define that object when you create the context for instance...".
When and where to set context in D2K Application.
Pls. give me some real example (as I have mentioned in my question)
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 36552833
usually you set a context at the beginning of a session.

in a web application where you might have a connection pool, you might want to set the context per page.
I can't be more specific than that because the answer depends on your specific application operation
basic rule:  before you access an object you want context controlled- set the context, if you set it more than once, it's inefficient, but not dangerous


>> I do not understand "you define that object when you create the context for instance...".

CREATE OR REPLACE CONTEXT my_context USING context_test_pkg;  

the object "context_test_pkg"  is defined for the context "my_context"

this means you can only set "my_context" by using "context_test_pkg"
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question