ORACLENERD twitter/oraclenerd view chet justice's profile on LinkedIn feed oraclenerd t-shirts Unemployment Clock:

  DBMS_SESSION.IS_ROLE_ENABLED
Interesting (to me anyway) thing I learned recently.

DBMS_SESSION.IS_ROLE_ENABLED

The call looks like this:
DBMS_SESSION.IS_ROLE_ENABLED (
rolename VARCHAR2)
RETURN BOOLEAN;
A few times in the pass I've had need to check the role of the logged in user. I would do that with something like this:
CREATE OR REPLACE
FUNCTION role_enabled( p_role_name IN VARCHAR2 ) RETURN BOOLEAN
IS
l_dummy VARCHAR2(1);
BEGIN
SELECT 'Y'
INTO l_dummy
FROM dba_role_privs
WHERE grantee = USER
AND role = p_role_name;

RETURN TRUE;
EXCEPTION
WHEN no_data_found THEN
RETURN FALSE;
END role_enabled;
/
I did something similar here (and I can't believe no one told me about this function!).

Lesson? Before building something on your own (even something this simple), search through the documentation to see if Oracle has already done it.

Update This was shown to me by my colleage, @serge_a_storms

Labels: , ,

 
Comments:
The hyperlink to the Oracle documentation points to your local hard drive!
 
My internal docs...sorry about that.

I've updated the link.
 
just popping in ;-)
 
Post a Comment

Subscribe to Post Comments [Atom]



Links to this post:

Create a Link



<<Home


Guest Authors

How To

Popular

Previous Posts

Code Projects

Archives
August 2007 / September 2007 / October 2007 / November 2007 / December 2007 / January 2008 / February 2008 / March 2008 / April 2008 / May 2008 / June 2008 / July 2008 / August 2008 / September 2008 / October 2008 / November 2008 / December 2008 / January 2009 / February 2009 / March 2009 / April 2009 / May 2009 / June 2009 / July 2009 / August 2009 / September 2009 / October 2009 / November 2009 / December 2009 / January 2010 / February 2010 / March 2010 / April 2010 / May 2010 / June 2010 / July 2010 /


Aggregated by OraNA