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

  • Home
  • SEARCH
  • 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 6630037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:20:46+00:00 2026-05-25T22:20:46+00:00

There is this post that describes setting up a trigger to change the schema

  • 0

There is this post that describes setting up a trigger to change the schema on login. Is there a way to check the role of the user to see if it matches a specific role instead of the username itself?

I tried to do a subquery to user_role_privs in the when clause, but it doesn’t allow that. Ideas?

UPDATE

This is what I’m using per Yahia’s suggested solution. It does not seem to be working though. When I login with a user with the role, it still does not recognize the table without the schema name before it.

CREATE OR REPLACE TRIGGER db_logon
AFTER logon ON DATABASE
DECLARE
    v_count NUMBER;
BEGIN
    SELECT COUNT(*) INTO v_count FROM user_role_privs WHERE granted_role = 'USER_ROLE' and username <> 'DEFAULT_SCHEMA';
    IF v_count > 0 THEN
        execute immediate 'ALTER SESSION SET CURRENT_SCHEMA = DEFAULT_SCHEMA';
    END IF;
END;
  • 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-25T22:20:47+00:00Added an answer on May 25, 2026 at 10:20 pm

    Yes – ditch the WHEN part and build the SQL string inside the trigger dynamically:

    CREATE OR REPLACE TRIGGER db_logon
    AFTER logon ON DATABASE 
    

    Use the SELECT on USER_ROLE_PRIVS and map whatever you want from the ROLE to a SCHEMA.

    Then build an SQL string for EXECUTE IMMEDIATE including the mapped SCHEMA.

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

Sidebar

Related Questions

I was looking at this post that describes a simple way to do databinding
Paul Silver had this post 7 years ago to check various browsers. Has there
This blog post (slightly annoying page there) (and that's not my blog by the
I know there is this post , but I still want to know more
Before I start, I know there is this post and it doesn't answer my
There are several scripting environments available for .NET applications (e.g. this post ). My
There was a post this morning asking about how many people disable JavaScript. Then
There is an interesting post over here about this, in relation to cross-application flow
This question is related to a previous post . Is there something comparable to
This question is related with one of my earlier questions.. Previous Post In there

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.