Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Setting Application Context in Oracle for RLS

Posted on 2011-09-15
3
Medium Priority
?
350 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
  • 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses

885 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