Use the CREATE CONTEXT statement to:
Create a namespace for a context (a set of application-defined attributes that validates and secures an application)
Associate the namespace with the externally created package that sets the context
You can use the DBMS_SESSION.SET_CONTEXT procedure in your designated package to set or reset the attributes of the context.
CREATE OR REPLACE CONTEXT ORDER_CTX USING orders_app_pkg;
CREATE OR REPLACE PACKAGE orders_app_pkg IS
PROCEDURE set_app_context;
END;
/
CREATE OR REPLACE PACKAGE BODY orders_app_pkg IS
c_context CONSTANT VARCHAR2(30) := 'ORDER_CTX';
PROCEDURE set_app_context IS
v_user VARCHAR2(30);
BEGIN
SELECT user INTO v_user FROM dual;
DBMS_SESSION.SET_CONTEXT(c_context, 'ACCOUNT_MGR', v_user);
DBMS_OUTPUT.PUT_LINE(v_user);
END;
END;
/
declare
var varchar2(2000);
begin
orders_app_pkg.set_app_context;
SELECT SYS_CONTEXT('ORDER_CTX', 'ACCOUNT_MGR') into var FROM dual;
DBMS_OUTPUT.PUT_LINE(var);
end;
/
the answer is C because SYS_CONTEXT(CONTEXT_NAME, PARAM1) returns the value of the parameter associated to the context namespace.
upvoted 1 times
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
orakell
Highly Voted 5 years, 2 months agoRakeshpro
Most Recent 2 years, 4 months agoRakeshpro
2 years, 4 months agoRakeshpro
2 years, 4 months agoRakeshpro
2 years, 4 months agochrishillinger
2 years, 5 months agoCosminCof
4 years, 2 months agopeguynya
4 years, 7 months ago