Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: DBMS_SESSION.set_context

Re: DBMS_SESSION.set_context

From: Richard Kuhler <noone_at_nowhere.com>
Date: Fri, 08 Mar 2002 19:52:48 GMT
Message-ID: <kE8i8.13094$Gu6.5912918@typhoon.san.rr.com>


I suspect you're not being completely accurate here. The only line that should return ORA-01031 is the 'set_context'. However, if that line was giving the error then you shouldn't be getting the 'datamanagerID:' line at all (unless you've changed the code). My only guess is that the context is not properly associated with package. Are you creating the context in he same schema that you compile the package? Did you really have the 'xxx.' on the line:

CREATE CONTEXT xxxContext USING xxx.dmContextPack;

I had assumed from the beginning that the 'xxx.' was the name of the actual schema that you compiled the package under. If that's not right then that's your problem. Drop the context and recreate it properly.

If you still can't get this working, please send the exact input and output from the sql*plus session of you creating the context, compiling the code and testing it.

Richard

Eva Haiden wrote:
>
> Yes, the 'datamanID:' line has a value on it but the 'datamanagerID:'
> line does not. When I run the setDatamanagerID procedure, the
> WHEN_OTHERS clause is reached. When I print the error number and
> message it returns the ORA-01031.
>
> Thank you very much for helping!
> Eva
>
> Richard Kuhler <noone_at_nowhere.com> wrote in message news:<6oTh8.11731$Gu6.5281039_at_typhoon.san.rr.com>...
> > Please clarify something for me. Are you saying that the 'datamanID:'
> > line has a value on it but the 'datamanagerID:' line does not? Also,
> > what is the exact call you are making when you get ORA-01031? I don't
> > see any reason that you should get that from calling sys_context unless
> > the standard package is screwed up.
> >
> > Richard
> >
> > Eva Haiden wrote:
> > >
> > > Hello,
> > >
> > > You are right, the context does get set. I just printed the context
> > > with the DBMS_SESSION.LIST_CONTEXT function and it printed the value
> > > of my context. But, I don't understand why the sys_context funtion
> > > will not print it. Also, the sys_context functiong gives me the Oracle
> > > error message: ORA-01031. Unfortunately, I can't make any sense out of
> > > it? Do you have any suggestions?
> > >
> > > Thank you,
> > > Eva
> > >
> > > Richard Kuhler <noone_at_nowhere.com> wrote in message news:<
> > > LJsh8.8209$Gu6.4435281_at_typhoon.san.rr.com>...
> > > > That couldn't possibly be the output of the procedure you included. The
> > > > 'datamanID:' line appears above the 'Attribute is set now:' line in the
> > > > code. The 'datamanagerID:' line appears below that. The only way that
> > > > the 'datamanID:' line could appear without a value would be if the ID
> > > > value from the xxx_datamanager table was null for the row being
> > > > selected. In that case, the 'datamangerID:' line should appear with no
> > > > value as well.
> > > >
> > > > Richard
> > > >
> > > > Eva Haiden wrote:
> > > > >
> > > > > Richard,
> > > > > Thank you for trying out my code. Did you use the my showContext
> > > > > procedure to show the values of the context? Because it does not print
> > > > > any values. Also, when I use the setDatamanagerID procedure, the
> > > > > context value is not printed. It just prints:
> > > > >
> > > > > Attribute is set now:
> > > > > datamanID:
> > > > >
> > > > > and no value. Do I miss any settings?
> > > > >
> > > > > Please help! Thank you!
> > > > > Eva
> > > > >
> > > > > Richard Kuhler <noone_at_nowhere.com> wrote in message news:<%OOg8.6146$Gu6.3125743_at_typhoon.san.rr.com>...
> > > > > > Obviously, you can't do the set_context as an 'exec' that would defeat
> > > > > > the purpose of a context. Only the dmContextPack should be able to do
> > > > > > that. I compiled this code on an 8.1.7 database and it ran without any
> > > > > > problems. The context was set properly. Are you sure that you don't
> > > > > > get an error that's being trapped by that 'when others' clause?
> > > > > >
> > > > > > Richard
> > > > > >
> > > > > > Eva Haiden wrote:
> > > > > > >
> > > > > > > Dear oracle users,
> > > > > > >
> > > > > > > I try to create an application context to be used with an security
> > > > > > > policy. The select in the below database package works, but the
> > > > > > > context does not get set. Any idea why this could be?
> > > > > > >
> > > > > > > Also, when I run
> > > > > > > exec dbms_session.set_context('carambaContext', 'datamangerID', 2) by
> > > > > > > itself, I get the following error message:
> > > > > > >
> > > > > > > *
> > > > > > > FEHLER in Zeile 1:
> > > > > > > ORA-01031: Unzureichende Berechtigungen
> > > > > > > ORA-06512: in "SYS.DBMS_SESSION", Zeile 78
> > > > > > > ORA-06512: in Zeile 1
> > > > > > >
> > > > > > > The context creation is as following:
> > > > > > >
> > > > > > > CREATE CONTEXT xxxContext USING xxx.dmContextPack;
> > > > > > >
> > > > > > > CREATE OR REPLACE PACKAGE dmContextPack as
> > > > > > >
> > > > > > > PROCEDURE setDatamanagerID;
> > > > > > > PROCEDURE showContext (context_name VARCHAR2, context_attribute
> > > > > > > VARCHAR2);
> > > > > > >
> > > > > > > END dmContextPack;
> > > > > > >
> > > > > > > CREATE OR REPLACE PACKAGE BODY dmContextPack IS
> > > > > > >
> > > > > > > PROCEDURE setDatamanagerID IS
> > > > > > >
> > > > > > > datamanID NUMBER;
> > > > > > >
> > > > > > > BEGIN
> > > > > > >
> > > > > > > select id
> > > > > > > into datamanID
> > > > > > > from xxx_datamanager
> > > > > > > where upper(dm_user) = SYS_CONTEXT('USERENV', 'session_user');
> > > > > > >
> > > > > > > dbms_session.set_context('xxxContext', 'datamangerID',
> > > > > > > datamanID);
> > > > > > > DBMS_OUTPUT.PUT_LINE ('datamanID: ' || datamanID);
> > > > > > > DBMS_OUTPUT.PUT_LINE ('Attribute is set now:');
> > > > > > > DBMS_OUTPUT.PUT_LINE ('datamanagerID: ' ||
> > > > > > > SYS_CONTEXT('xxxContext',
> > > > > > > 'datamanagerID'));
> > > > > > >
> > > > > > > EXCEPTION
> > > > > > > WHEN NO_DATA_FOUND
> > > > > > > THEN
> > > > > > > DBMS_OUTPUT.PUT_LINE ('No data found');
> > > > > > > WHEN OTHERS THEN
> > > > > > > DBMS_OUTPUT.PUT_LINE ('When others clause reached:');
> > > > > > > DBMS_OUTPUT.PUT_LINE ('datamanID: ' || datamanID);
> > > > > > >
> > > > > > >
> > > > > > > END setDatamanagerID;
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > PROCEDURE showContext (context_name VARCHAR2, context_attribute
> > > > > > > VARCHAR2) IS
> > > > > > > BEGIN
> > > > > > >
> > > > > > > DBMS_OUTPUT.PUT_LINE (context_name || ' = ' ||
> > > > > > > SYS_CONTEXT(context_name,
> > > > > > > context_attribute));
> > > > > > >
> > > > > > > END showContext;
> > > > > > >
> > > > > > > END dmContextPack;
Received on Fri Mar 08 2002 - 13:52:48 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US