Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6597727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:14:44+00:00 2026-05-25T18:14:44+00:00

We have table in database, using Oracle 9i(9.2), we must made policy for SELECT

  • 0

We have table in database, using Oracle 9i(9.2), we must made policy for SELECT query, some group of users can access for exact row and some cannot, standardly it solved by VIEWs:

  • making some VIEW table
  • changing table name of origin

But there is a problem, we can’t change table name, it bureaucracy problems.

Finally, is it some mechanism or triggers(there are no triggers for SELECT but just example) to control row access?

Sorry, if question is dummy,I don’t have much experience with DBs.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:14:44+00:00Added an answer on May 25, 2026 at 6:14 pm

    One option would be to create a Virtual Private Database policy for the table in question.

    From a presentation I did a couple years ago

    Set up the environment

    -- The SEMOP user has been granted the following privileges
    --   CREATE SESSION
    --   CREATE PROCEDURE
    --   CREATE ANY CONTEXT
    --   UNLIMITED TABLESPACE
    --   CREATE TABLE
    --   CREATE SEQUENCE
    --   EXECUTE ON DBMS_RLS
    --   EXECUTE ON DBMS_FGA
    --   SELECT ON DBA_FGA_AUDIT_TRAIL
    
    conn oow2009/oow2009;
    
    create table patient (
      patient_id         number primary key,
      patient_first_name varchar2(30),
      patient_last_name  varchar2(30),
      vip_flag           char(1)
    );
    
    create table service (
      service_id         number primary key,
      service_name       varchar2(30)
    );
    
    create table doctor (
      doctor_id          number primary key,
      doctor_first_name  varchar2(30),
      doctor_last_name   varchar2(30),
      service_id         number references service( service_id )
    );
    
    create table admission (
      admission_id       number primary key,
      patient_id         number references patient( patient_id ),
      service_id         number references service( service_id ),
      primary_doctor_id  number references doctor( doctor_id ),
      admission_date     date,
      discharge_date     date
    );
    
    begin
      insert into patient( patient_id, patient_first_name, patient_last_name, vip_flag )
        values( 1, 'Barack', 'Obama', 'Y' );
      insert into patient( patient_id, patient_first_name, patient_last_name, vip_flag )
        values( 2, 'Larry', 'Ellison', 'Y' );
      insert into patient( patient_id, patient_first_name, patient_last_name, vip_flag )
        values( 3, 'Justin', 'Cave', 'N' );
      insert into patient( patient_id, patient_first_name, patient_last_name, vip_flag )
        values( 4, 'Jane', 'Doe', 'N' );
    
      insert into service( service_id, service_name )
        values( 11, 'Obstetrics' );
      insert into service( service_id, service_name )
        values( 12, 'Cardiac' );
      insert into service( service_id, service_name )
        values( 13, 'Opthamology' );
      insert into service( service_id, service_name )
        values( 14, 'Emergency' );
    
      insert into doctor( doctor_id, doctor_first_name, doctor_last_name, service_id )
        values( 21, 'William', 'Mayo', 14 );  
      insert into doctor( doctor_id, doctor_first_name, doctor_last_name, service_id )
        values( 22, 'George', 'Minot', 13 );  
      insert into doctor( doctor_id, doctor_first_name, doctor_last_name, service_id )
        values( 23, 'Richard', 'Morton', 12 );  
      insert into doctor( doctor_id, doctor_first_name, doctor_last_name, service_id )
        values( 24, 'Carl', 'Jung', 11 );  
      insert into doctor( doctor_id, doctor_first_name, doctor_last_name, service_id )
        values( 25, 'Joseph', 'Lister', 12 );  
    
      -- Obama has been admitted 3 times, twice for heart tests and once for an eye test  
      insert into admission( admission_id, patient_id, service_id, primary_doctor_id, admission_date, discharge_date )
        values( 31, 1, 12, 23, date '2009-04-01', date '2009-04-01' );  
      insert into admission( admission_id, patient_id, service_id, primary_doctor_id, admission_date, discharge_date )
        values( 32, 1, 12, 25, date '2009-05-03', date '2009-05-03' );  
      insert into admission( admission_id, patient_id, service_id, primary_doctor_id, admission_date, discharge_date )
        values( 33, 1, 13, 22, date '2009-05-03', date '2009-05-03' );  
    
      -- Ellison was admitted to the emergency department following a yachting accident  
      insert into admission( admission_id, patient_id, service_id, primary_doctor_id, admission_date, discharge_date )
        values( 34, 2, 14, 21, date '2009-07-01', date '2009-07-03' );  
    
      -- Justin was admitted earlier today for an eye exam and hasn't been discharged
      insert into admission( admission_id, patient_id, service_id, primary_doctor_id, admission_date, discharge_date )
        values( 35, 3, 13, 22, date '2009-09-24', null );  
    
      -- Jane was admitted to obstatrics
      insert into admission( admission_id, patient_id, service_id, primary_doctor_id, admission_date, discharge_date )
        values( 36, 4, 11, 24, date '2009-08-01', date '2009-08-10' );  
    end;
    /
    

    Create a secure context

    create or replace context oow2009_ctx
     using pkg_secure_context;    
    
    create or replace package pkg_secure_context 
    as 
      procedure login( p_doctor_first_name IN doctor.doctor_first_name%TYPE,
                       p_doctor_last_name  IN doctor.doctor_last_name%TYPE );
    
      procedure logout;                   
    end;
    /
    
    create or replace package body pkg_secure_context
    as
      procedure login( p_doctor_first_name IN doctor.doctor_first_name%TYPE,
                       p_doctor_last_name  IN doctor.doctor_last_name%TYPE )
      as
        l_doctor_id doctor.doctor_id%TYPE;
      begin
        SELECT doctor_id
          INTO l_doctor_id
          FROM doctor
         WHERE doctor_first_name = p_doctor_first_name
           AND doctor_last_name  = p_doctor_last_name;
    
        dbms_session.set_context( 'oow2009_CTX', 
                                  'DOCTOR_ID', 
                                  to_char(l_doctor_id) );   
      end login;             
    
      procedure logout
      as
      begin
        dbms_session.clear_context( 'oow2009_CTX' );
      end logout;     
    end;
    /     
    

    Create a policy function

    create or replace function policy_view_own_patients( schema_p IN VARCHAR2,
                                                         table_p IN VARCHAR2 )  
      return VARCHAR2
    is
    begin
      return 'patient_id IN 
                (SELECT patient_id    
                   FROM admission
                  WHERE primary_doctor_id = 
                            SYS_CONTEXT( ''oow2009_CTX'', ''DOCTOR_ID'' ))';
    end;
    /
    

    Create the row-level security policy

    begin
      dbms_rls.add_policy (
        object_schema => 'oow2009',
        object_name   => 'PATIENT',
        policy_name   => 'VIEW_OWN_PATIENTS',
        policy_function => 'POLICY_VIEW_OWN_PATIENTS'
      );
    end;
    / 
    

    This query returns 0 rows now

    select patient_first_name || ' ' || patient_last_name patient_name, 
           service_name, 
           doctor_last_name, 
           admission_date, 
           discharge_date
      from patient   p,
           doctor    d,
           service   s,
           admission a
     where p.patient_id = a.patient_id
       and a.service_id = s.service_id
       and a.primary_doctor_id = d.doctor_id
     order by patient_last_name;
    

    If you log in as William Mayo, however

    exec pkg_secure_context.login( 'William', 'Mayo' );
    

    the same query now returns rows but only those that rows for Mayo’s patients. The other rows continue to be filtered out

    select patient_first_name || ' ' || patient_last_name patient_name, 
           service_name, 
           doctor_last_name, 
           admission_date, 
           discharge_date
      from patient   p,
           doctor    d,
           service   s,
           admission a
     where p.patient_id = a.patient_id
       and a.service_id = s.service_id
       and a.primary_doctor_id = d.doctor_id
     order by patient_last_name;
    

    Your policy function could drive off the currently logged in user or any other piece of information if you didn’t want or need the secure context.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: SELECT INTO using Oracle I have one table in my oracle database.
I have a database table using an enum. This is already working with hibernate
I have a table in the database that I'm retrieving using LINQ to SQL,
Using MS Access 2007, I am creating a student management database. I have tables
I have an access database with 3 tables. People Gifts PeopleGifts Using VS 2008,
I have a table in database that is having some fields one of which
We are using Java and Oracle for development. I have table in a oracle
I am developing an application using oracle 11g, Java(struts2) and Hibernate. I have table
I am using Oracle 10g Enterprise edition. A table in our Oracle database stores
I have a table in an Oracle Database like this ID | LABEL ------------

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.