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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Session variable wanted

Re: Session variable wanted

From: Pavel Vetesnik <Pavel.Vet_at_volny.cz>
Date: Thu, 6 Mar 2003 14:48:06 +0100
Message-ID: <b47jin$1pdu$1@ns.felk.cvut.cz>


And another question:
Is there a way how to handle exceptions with cookies? If I try to get a cookie that does not exists, I always get a runtime error and my exception code is not fired.

This is an example:


    PROCEDURE showpage2 IS
    MyCookie owa_cookie.cookie;
    cValue VARCHAR2(100);
    BEGIN

        MyCookie:=owa_cookie.get('pavel1_test1');
        cValue:=MyCookie.vals(1);
    EXCEPTION
        WHEN OTHERS THEN
            htp.p('Error!');
        RAISE;

    END;

Instead of my "Error!" message I always get "ORA-01403: No data found" runtime error. What can I do to handle it?

TIA,
Pavel

"Pavel Vetesnik" <Pavel.Vet_at_volny.cz> píše v diskusním příspěvku news:b475uj$1i5t$1_at_ns.felk.cvut.cz...
> Greeting Vladimir,
>
> thank you very much for your comprehensive answer and for pointing me to
> "OWA_COOKIE" package (I didn't know about it before). I took a look
at -send
> and -get functions and they works exactly as I need.
>
> If you take a look at the "demo" application at
> http://newalex.stk.cz:7777/pls/portal30/el_cas.testovaci.showpage1 then
you
> see that now it works as needed.
>
> The only problem can be if client has cookies disabled and then my pages
> won't work for him, I guess.
>
> Thank you again,
> Pavel
>
>
> "Vladimir M. Zakharychev" <bob_at_dpsp-yes.com> pise v diskusnim prispevku
> news:b457u9$5tf$1_at_babylon.agtel.net...
> > HTTP is discrete by design (if we do not delve deep into Keep-Alive.)
> > Thus, it is up to the developer to preserve application state between
> > HTTP calls. HTTP cookies were introduced to help developers with that.
> > The idea is simple: the application saves its state in some permanent
> > storage (a table, for example) on the server and assigns this state a
> > unique identifier (session id), and sends this identifier to the HTTP
> > client in a cookie. On subsequent requests, the client presents this
> > identifier to the server as part of the request. The application starts
> > clean, retrieves stored session state associated with the session id it
> > got from the client, and reinitializes the application to that saved
> state.
> > From now on, it can proceed as there was no interruption in its flow.
> > If you do not like cookies, you can implement similar mechanism
> > manually: just include the data you want to be preserved between calls
> > in HTML forms (as hidden parameters, for example.) On the next
> > request, the client will send this data as part of the request.
> >
> > Having said that, it's not possible to use package variables as
permanent
> > storage for session data - packages are reset between HTTP calls
> > (some versions of mod_plsql supported "stateful" applications, where
> > packages were not reset between calls, but this approach was abandoned
> > because it forced to maintain separate Oracle session for each HTTP
> > session, which was not particularly good idea since the HTTP client may
> > terminate without notifying the server it did, leaving associated Oracle
> > session stranded.) Stateless mode requires the application to preserve
> > state between calls if needed.
> >
> > OWA supports setting and retrieving cookies through OWA_COOKIE
> > package. How you will preserve the application state is up to you
anyway.
> >
> > hth.
> >
> > --
> > Vladimir Zakharychev (bob_at_dpsp-yes.com)
> http://www.dpsp-yes.com
> > Dynamic PSP(tm) - the first true RAD toolkit for Oracle-based internet
> applications.
> > All opinions are mine and do not necessarily go in line with those of my
> employer.
> >
> >
> > "Pavel Vetesnik" <Pavel.Vet_at_volny.cz> wrote in message
> news:b44jfr$kju$1_at_ns.felk.cvut.cz...
> > > Hello,
> > >
> > > I want to write an application using PL/SQL (with Oracle 8 installed),
> where
> > > user will access data using HTML interface.
> > >
> > > What I am looking for is an variable, that will be kept during whole
> users
> > > session. I thought, that variables defined for whole package will do
the
> > > task, but they probably do not.
> > >
> > > I created a little testing application, which you may find at
> > > c . There
> > > are 2 procedures (1st page and 2nd page) and I want to keep is a
> variable
> > > set in the 1st page.
> > >
> > > The source code follows. Any help is appreciated.
> > >
> > > Thank you in advance,
> > > Pavel
> >
>
> --------------------------------------------------------------------------
> > > CREATE OR REPLACE PACKAGE testovaci IS
> > > cTitle VARCHAR2(100);
> > >
> > > PROCEDURE showpage1;
> > > PROCEDURE showpage2;
> > > END;
> > > /
> > >
> > > CREATE OR REPLACE PACKAGE BODY testovaci IS
> > >
> > > PROCEDURE showpage1 IS
> > > BEGIN
> > > cTitle:='This is the text I want to keep...';
> > > htp.htmlopen;
> > > htp.bodyopen;
> > > htp.header(1, ctitle);
> > > htp.p('<a
> > >
>

HREF="http://newalex.stk.cz:7777/pls/portal30/el_cas.testovaci.showpage2">Cl
> > > ick for page2</a>');
> > > htp.bodyclose;
> > > htp.htmlclose;
> > > END;
> > >
> > > PROCEDURE showpage2 IS
> > > BEGIN
> > > htp.htmlopen;
> > > htp.bodyopen;
> > > htp.header(1, cTitle);
> > > htp.p('If you can see "This is the text I want to keep..."
above
> > > this line, then everything works fine. If this is the only line on the
> page,
> > > then it doesn''t work.');
> > > htp.bodyclose;
> > > htp.htmlclose;
> > > END;
> > > END testovaci;
> > > /
> > >
> > > GRANT EXECUTE ON testovaci TO PUBLIC;
> >
>
> --------------------------------------------------------------------------
> > >
> > >
>
>
Received on Thu Mar 06 2003 - 07:48:06 CST

Original text of this message

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