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: Parameterized Views

Re: Parameterized Views

From: Connor McDonald <connor_mcdonald_at_yahoo.com>
Date: Wed, 13 Aug 2003 23:07:32 +0800
Message-ID: <3F3A5434.518@yahoo.com>


Brian Kramer wrote:
>
> Does oracle support parameterized views? Basically we'd like to be
> able to pass a userid to a view and based on the userid filter the
> data.
> We can get the userid into a table but the problem is that we don't
> know which user id goes with which request (we are using a common
> application login, rather than separate user logins). Is there such a
> thing as a temporary table for a given session? Or some other way to
> guarantee we are pulling the correct userid?
>
> In a nutshell we have the userid in a web application and we need a
> way to get it to the database so a view can be created that filters
> based on the userid.

check out the use of contexts and the SYS_CONTEXT function to do this.

create view view_on_emp
as select * from emp
where empno = sys_context('MYCTX','EMPNO);

dbms_session.set_context('MYCTX','EMPNO',12); select * from view_on_emp;

hth
connor

-- 
=========================
Connor McDonald
http://www.oracledba.co.uk

"Some days you're the pigeon, some days you're the statue"
Received on Wed Aug 13 2003 - 10:07:32 CDT

Original text of this message

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