Skip to main content

Oracle VPD setup

This will be a quick guide on how to use the VPD feature in an Oracle database.

Start with creating a package that will fill your context.

create or replace package
user.mypackage
is
procedure set_user_id_context;
end;

Here comes the package body:

create or replace package body
user.mypackage
is
procedure set_user_id_context
is
sec_user_id number;
begin
--
-- in this case we have a table that holds my users and each user has a code
--
select
code
into
sec_user_id
from
usr
where
upper(id) =
upper(
sys_context(
'USERENV'
,'SESSION_USER'
)
);
--
-- set the context
--

dbms_session.set_context(
'MYCONTEXT_NAME'
, 'USER_ID'
, sec_user_id
);

exception

--
-- This is necessary in order to allow users that are
-- not in the usr table to login, as this procedure is
-- used in a logon trigger
--

when no_data_found then
dbms_session.set_context(
'MY_CONTEXT_NAME'
, 'USER_ID'
, NULL
);
end set_user_id_context;
end;



Then create a context:

connect user/password@sid


create or replace context my_context_name using user.mypackage;
/

Comments

Popular posts from this blog

Oracle Fusion Middleware Forum in Valencia

Last week the 22nd Fusion Middleware and PaaS Partner Community Forum took place in Valencia, Spain. For me this was a very valuable experience - again as I have visited a number of #ofmForum before. Let me recap here the highlights of this meeting. After a great Welcome-Reception the evening before, where everybody had the chance to catch up with a large number of old (and soon-to-be new) friends, the conference started with a kind of the state of the union by Jürgen Kress. The community already has more than 8000 people. This - in a fact - is a tremendous achievement. Everybody agrees that this is only possible by the relentless work of Jürgen who puts a big effort into this. It shows that other areas inside the Oracle technology stack do not benefit by equivalent communities. Even other communities, when they exist at all, do not compete in the same league. So a VERY BIG THANK YOU for Jürgen is at its place here. After the opening a keynote from Alistair Hopkins showed ver...

Oracle Streams Explorer

At the recent Oracle SOA Suite community forum in Budapest I had a hands-on experience with the Oracle Streams Explorer. Having worked with the Oracle Complex Event Processing and also some hands-on exercises with the new Oracle Event Processing, the Oracle Streams Explorer is a very easy to handle and useful addition to the area of near-real-time data insight and analysis. The user interface comes along in the new Oracle look-and-feel. You can select a number of areas like IOT, Risk and Fraud Management, Transportation and Logistics, Customer Experience and Analysis and Telecommunications. Within that you get a number of predefined patterns and resources. Defining your own solution can therefore be based on an existing solution in your catalog or simply by combining input streams and defining filters on them. Now plenty of examples can (and will) be named. The essence for me - and this is a message that I will convey to customers - is the fact that by using Oracle Streams Expl...

Paas Summercamp 2017 in Lisbon

So – another summer camp is over. What was the outcome of this? Was there more to it than meeting some old friends, dive into some slides, get your hands dirty on new versions and finally talk about it over a glass of Portuguese wine or beer? So let’s start at the beginning – where are we right now? In the Process Cloud Service track the global PM Nathan Angstadt kicked of the session by asking how many projects we are on that use PCS and how we get along selling the product. The outcome was somewhat predictable: about one or two participants were on PCS projects, and selling is still a big issue. We discussed the various reasons for that. The main essence was that the PCS is often positioned at previous BPM customers who still have to deal with large BPM implementations and are somewhat afraid of the new PCS-style. BPM and PCS are two different things. They target different customer issues. BPM is still useful when it comes to large scale implementation...