Setting and retrieving session using pl/sql

How to set and retrieve session using pl/sql?Can anyone help me?

mrs wrote:
create or replace
function get_login_details(in_user in VARCHAR2,in_pwd in VARCHAR2,in_cname in VARCHAR2)
..snipped..The code should look as follows:
create or replace function AuthenticateUser( userName varchar2, userPassw varchar2, userGroup varchar2 )
return integer is
  i integer;
begin
  --// purpose of the SQL is simply to check if such a row exist -
--// no data from the row needs to be fetched
  select 1 into i from acl_users_gv
  where user_name = userName
  and password = userPassw
  and entity_group_name = userGroup;
  --// if the SQL succeeded, then the row exists and matches
  --// the authentication details
  return( 0 );
exception when NO_DATA_FOUND then
  --// SQL failed to find a row - authentication details do
  --// not exist
  return( 1 );
end;No need to fetch data unnecessarily. No need too check the fetched data when the column values are already checked via the SQL filter condition (predicate).
No need to return a flag variable as a freely formatted text string containing Successful Login and login failed. That is not a robust design to use a string variable like that. Use boolean for true/false. Or use integer values 0/1.
This is my function get_login_details.And I need to get this 'o_mesg' in other java file also.Standard PL/SQL call from Java. The SQL string to execute contains an anonymous PL/SQL and needs to use bind variables. E.g.
begin
  :result := AuthenticateUse( :userName, :userPassw, :userGroup );
end;
Can you suggest the right way, how I can get this variable in other pages?That depends on whether there is database session state. If there is, authentication can be done once only via a trusted context, that specifies whether the session is authenticated.
If this is done from an app server that uses a db session pool and stateless db sessions, the state needs to be kept in the app server.
Do you understand what stateful versus stateless db sessions are, and what the differences are?

Similar Messages

  • Setting session using pl/sql

    How to set and retrieve session using pl/sql?Can anyone help me?

    This is the wrong forum for SQL or PL/SQL questions.
    1. Post your question in the SQL and PL/SQL forum
    https://forums.oracle.com/forums/forum.jspa;jsessionid=8d92100c30d7960321c250bf4adeaa5dcac037eb147c.e34SbxmSbNyKai0Lc3mPbhmSbNaLe0?forumID=75&start=0
    2. Edit this thread and post the link to your new question.
    3. Mark this thread ANSWERED so people will follow up in the other forum.
    When you post your new question provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION). You will also need to explain what you mean by 'set and retrieve' session. A session is created when a logon is successful so 'set' and 'retrieve' only have meaning in terms of trying to set or retrieve session parameters that may be in effect.

  • Code to set and destroy session variables in Java Server Pages(JSP)

    code to set and destroy session variables in Java Server Pages(JSP)
    we have use following statement to set session variable
    session.setAttribute("userClient",id);
    we have use following statement to destroy session variable
    session.setAttribute("userClient","");
    and
    the session.invalidate() is not working
    Plz. solve this probem

    code to set and destroy session variables in Java
    Server Pages(JSP)
    we have use following statement to set session
    variable
    session.setAttribute("userClient",id);
    we have use following statement to destroy session
    variable
    session.setAttribute("userClient","");Perhaps if you tried using
    session.setAttribute("userClient", null);
    or
    session.removeAttribute("userClient");
    and
    the session.invalidate() is not workingNot working how?
    >
    Plz. solve this probem

  • "Setting and Retrieving Cookies" DreamWeaver 8

    I am training from the book, "MacroMedia DreamWeaver 8,
    Training from the Source." I am unable to get retrieve the cookies
    set on my hard drive by the code I used in Chapter 4, Setting and
    Retrieving Cookies. I have checked my code against the completed
    code in the book and they appear to me to be identical. The cookies
    are being transferred to my hard drive by by the variables set in
    the code, but the code fails to retrieve the cookies from the hard
    drive as expected on the linked page. Since I eventually want to
    develop an interactive commerical web site, I need to solve this
    problem now. Any help is certainly appreciated. Below, I am listing
    the code that I am using for each of the three dynamic pages.
    Test Form:
    Information is entered on this form and passed to test form
    processor (This works well.)
    Code]
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Transitional//EN" "
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="
    http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html;
    charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>
    <body>
    <form id="frm_name" name="frm_name" method="get"
    action="test_form_processor.php">
    <label>First Name
    <input name="firstName" type="text" id="firstName" />
    </label>
    <p>
    <label>Last Name
    <input name="lastName" type="text" id="lastName" />
    </label>
    </p>
    <p>
    <p>
    <input type="submit" name="Submit" value="Submit" />
    </p>
    </form>
    </body>
    </html>
    [/Code]
    Test Form Processor:
    The first name and last name from page one transfer to the
    variables on this page, no problem.
    [Code]
    <?php
    setcookie('firstName', $_Get['firstName'], time() +
    (60*60*24));
    setcookie('lastName', $_Get['lastName'], time() +
    (60*60*24));
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Transitional//EN" "
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="
    http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html;
    charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>
    <body>
    <p>Thank you, <?php echo $_GET['firstName']; ?>
    <?php echo $_GET['lastName']; ?> , for filling out my
    form.</p>
    <p>Check <a
    href="test_form_processor_cookies.php">cookie</a>.
    </p>
    </body>
    </html>
    ]/Code]
    Test form processor cookies:
    The cookies sre transferred to my hard drive, I checked by
    looking in the browser cache. the problem is that the cookies are
    not retrieved by this page. When I click on the link to this page,
    "I get Hi, !." Why won't the code echo the variables that the
    cookies are holding? The code is below.
    [Code]
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Transitional//EN" "
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="
    http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html;
    charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>
    <body>
    Hi, <?php echo $_COOKIE['firstName']; ?> <?php echo
    $_COOKIE['lastName']; ?> !</body>
    </html>
    [/Code]
    All the bindings are set, the cookies are placed on the hard
    drive, but for some reason the link page does not retrieve the
    cookies and print them to the screen as expected. I use Firefox and
    IE7. I set both to accept totally cookies, still I cannot retrieve
    the cookie set by this small application from my hard drive, when I
    run the pages. Any help and are ideas are appreciatted.

    The problem is in the Set Cookie header on page two. It
    should be $_GET and not $_get. Dreamweaver uses lower case with the
    get method. The correct $_GET is displayed in blue letters in upper
    case, instead of black letters and lower case. This is a very
    subtle difference, as PHP uses the get method in lower case.

  • What are the advanteges and disadvanteges of using pl/sql over hibernate

    i knwo that pl/sql are well structure and provide a lot of functionalities with oracle databse , but my question is the hibernate might give some advnateges of scalability over pl/sql.
    so what are the advanteges and disadvanteges of using pl/sql over hibernate?
    and does oracle recommend using hibernate for connecting JSP with oracle 11i , or it is better to connect the JSP pages with oracle databse using pl/sql ?

    812643 wrote:
    but if i search for the diferencess then there are a lot of opinions about this ..., specially when they say that with hibernate you can integrate with any DB , and it provides object printed architecture, etc.All databases are not equal. This is a basic and fundamental fact. SQL-Server is not Oracle. Oracle is not SQL-Server. As it is the case with Sybase, Ingres, DB2 and other database products. They are all different. And there are some very core differences between them.
    So how would a product like Hibernate treat these database products with their differences? By using the lowest common denominator. Which means your expensive database product is dumbed down - and even MS Access will likely have better and more features.
    You also need to decide what is the "permanent" part in your architecture. What is going to the core? What is the expensive part? The app server (with Hibernate)? Or the database server?
    What are you likely to change next year? The app server server? Or the database server?
    In the vast majority of cases, the core is the database server. That is your biggest expense and investment. As it should be - as it holds that which is most precious to business, data. You want to ensure the integrity of that data. The accuracy of that data. Make sure that it can be easily backed up and recovered. Is flexible to use. Etc. Etc.
    The database server is the core - and that is where you need to realise your return on investment. By using the database server to its full extent.
    Hibernate does not do that. And in that respect, it is junk.
    Why does it not do that? Because many Java developers are totally and fully clueless about what database servers are and how to use them. And want to use them as little plug-in black boxes - bit buckets that are only there to provide a data persistence layer. Instead of using the database server to its full extent, they instead use Hibernate, and try to do their own "+database thing+" in the app layer - and do it poorly and with utter lack of any scalability. (and no, only ignorant Java heads think that scalability means throwing more money and h/w at it)
    My largest database processes billions of rows per day, every day, 356 days a year (between 350 to 450 million new inserts into a single table per day). And have been for several years now. It does so using PL/SQL. Using Oracle to its full extent. Then there are Java heads that cannot even design and code an app that effectively process 1% of this volume... and grasp at straws like Hibernate and other Java cr@p to "fix" this - when the actual problem is their total lack of ignorance in how to use and scale the database server.
    Hibernate is trash - and a symptom of Java developers's ignorance of database technology.

  • Store and retrieve datetime using mysql

    Hi
    Am first timer in JSP and having a problem with datetime field. My requirement is that I have to store the date and time a message is posted in mysql database.
    After the message is posted I have to retrieve the data and display it in a new page including the datetime field.
    Trying this for a long time but not able to get. Any suggestions.
    Thanks,
    Sridhar

    I am using the preparedStatement to insert into the database and retrieve from the database.
    My problem is when i am retreiving from the database datetime are not coming.
    my preparedSTatement looks like this.,
    PreparedStatement insert1ps=con.prepareStatement("insert into topic_category values(?,?,?,?,?,?,?,?,?)");
    insert1ps.setInt(1,topic_id);
    insert1ps.setInt(2,article_id);
    insert1ps.setInt(3,author_id);
    insert1ps.setString(4,heading);
    insert1ps.setString(5,article);
    insert1ps.setDate(6,sqldate);
    insert1ps.setInt(7,archives);
    insert1ps.setInt(8,verify);
    insert1ps.setInt(9,no_views);
    I am using the above statements for inserting into the database.
    PreparedStatement selectaa = con.prepareStatement("select tc.topic_description,tc.datetime,aa.fname,tc.topic_head,aa.lname,tc.no_views from topic_category tc,article_author aa where tc.author_id=aa.author_id and tc.topic_id="+topic_id);
    ResultSet rss=selectaa.executeQuery();
    <td style="{font-family:verdana;font-size:12;color:#03065f}">
    Posted on :<%=rss.getTimestamp(2)%></td>
    And using this statement for retrieving.
    Is there any error in the above

  • Whats is the easiest way to store and retrieve files using a DB?

    Hello,
    I have a web application where my users need to upload and retrieve files(.doc, .ppt. excel). I want to store them in the database instead of on the server. Anyone have any ideas on the easiest way to do this?
    Thanks,
    Danny

    Well, there's a BFILE data type-- that allows you to store essentially a pointer to a file in the database, though the file itself would be stored externally.
    A better option would be to store the data either as interMedia Text or as a B/CLOB, so all the data from the file would be stored in the file. interMedia Text gives a number of benefits if you're going to be working with the data-- i.e. searching the data, etc, but the additional work & restrictions may not be worth it if you just want to get the data in and out of the database whole.
    Justin

  • Setting and retrieving a browser cookie using  a pl/sql procedure

    I want to set a cookie on the client browser and then later retrieve its value. I want to do both the operations using a pl/sql procedure. All this is going top be done from within the Portal 9.0.2 context. could you please give me any pointers

    Take a look at 'owa_cookie' Package
    Cheers

  • I am using the database connectivity toolkit to retrieve data using a SQL query. The database has 1 million records, I am retrieving 4000 records from the database and the results are taking too long to get, is there any way of speeding it up?

    I am using the "fetch all" vi to do this, but it is retrieving one record at a time, (if you examine the block diagram) How can i retrieve all records in a faster more efficient manner?

    If this isn't faster than your previous method, then I think you found the wrong example. If you have the Database Connectivity Toolkit installed, then go to the LabVIEW Help menu and select "Find Examples". It defaults to searching for tasks, so open the "Communicating with External Applications" and "Databases" and open the Read All Data. The List Column names just gives the correct header to the resulting table and is a fast operation. That's not what you are supposed to be looking at ... it's the DBTools Select All Data subVI that is the important one. If you open it and look at its diagram, you'll see that it uses a completely different set of ADO methods and properties to retrieve all the data.

  • Can i store and retrieve image using sql command?

    hi
    the following is what i enter to store image in table using sql*plus
    however i encounter some errors as shown below.
    i wondered if i actually can use sql to store image and retreive image
    or i need other developer beside sql to do.
    create table img_storage
    (id     number primary key,
    image     ORDSYS.ORDImage);
    CREATE or REPLACE procedure ADD_image (tmp_id number, file_name varchar2)
    as
         obj ORDSYS.ORDImage;
         ctx raw(4000) := null;
    begin
         INSERT INTO img_classifier (id, image) VALUES (tmp_id,
         ORDSYS.ORDImage (ORDSYS.ORDSOURCE(EMPTY_BLOB(),
         NULL,NULL,NULL,SYSDATE,NULL),
         NULL,NULL,NULL,NULL,NULL,NULL,NULL));
         COMMIT;
         SELECT image into obj FROM img_storage
         where id = tmp_id FOR UPDATE;
         obj.importFrom(ctx,'FILE','IMGDIR',file_name);
         obj.setproperties();
         UPDATE img_storage
         SET image = obj where id = tmp_id;
         COMMIT;
    end;
    show errors;
    create or replace directory imgdir as 'c:\image\';
    exec add_image(1,'argvseng.jpg');
    BEGIN add_image(1,'argvseng.jpg'); END;
    ERROR at line 1:
    ORA-00001: unique constraint (SYS.SYS_C002717) violated
    ORA-06512: at "SYS.ADD_IMAGE", line 7
    ORA-06512: at line 1
    how to reslove the error as shown above.
    or sql does not support ordsys.ordimage such command.
    hmm very confused ....
    what is the difference bet using blob for image and ordsys.ordimage?

    This has nothing to do with intereMedia.
    This is a basic SQL issue.
    A primary key cannot have duplicate entries in a table as the error message suggests.
    Before you call your peocedure you can delete the row with 1 as the primary key, or call the insert peocedure using a primary key that is not being used.

  • Kill the session Using Pl/sql Script

    Hi,
    I wrote a PL/SQL Script which kills the Specified Schema name..... the Script Run Successfully i got this output message "PL/SQL procedure successfully completed." But the Problem is in session status the status is in KILLED" state for more than 30 minutes.
    Please Advice Why the Session in Killed State for more than 30 minutes and please tell me how to kill the session immediate;
    I am Using Oracle DB 11g R1 and OS is Windows 2003 Server R2
    My Pl/sql Script
    SET SERVEROUTPUT ON;
    DECLARE
    KILLER1 V$SESSION.SID%TYPE;
    KILLER2 V$SESSION.SERIAL#%TYPE;
    CURSOR KILL_SESSION IS SELECT SID,SERIAL# FROM V$SESSION WHERE SCHEMANAME='NAME';
    BEGIN
    OPEN KILL_SESSION;
    LOOP
    FETCH KILL_SESSION INTO KILLER1,KILLER2;
    EXIT WHEN KILL_SESSION%NOTFOUND;
    DBMS_OUTPUT.put_line ('ALTER SYSTEM KILL SESSION '''||KILLER1||','||KILLER2||''' IMMEDAITE');
    EXECUTE IMMEDIATE 'ALTER SYSTEM KILL SESSION'||chr(39)||KILLER1||','||KILLER2||chr(39);
    END LOOP;
    IF (KILLER1 > 0)
    THEN
    EXECUTE IMMEDIATE 'ALTER SYSTEM KILL SESSION'||chr(39)||KILLER1||','||KILLER2||chr(39);
    END IF;
    CLOSE KILL_SESSION;
    END;
    Thank You
    Shan

    Hello,
    In fact you may use orakill it's an Oracle utility for Windows so as to Kill the thread corresponding
    to the session.
    It's equivalent to a kill -9 on Unix.
    Please find here a link about the use of orakill:
    http://articles.techrepublic.com.com/5100-10878_11-5224960.html
    Hope this help.
    Best regards,
    Jean-Valentin
    Edited by: Lubiez Jean-Valentin on Mar 27, 2010 5:17 PM

  • Set and Get parameters using SAP memory.

    I have an ALV grid list that I want to transfer to a detail report when the user doubleclicks.  I have set up a parameter transaction associated with the detail report.  My problem is the transfer does not take place.  After the "CALL TRANSACTION" the ALV grid list refreshes with none of the previous select-options being used.  Is there further setup I need to do, or is my coding incorrect?  All of the parameter fields have valid values.  I am new to ABAP, so please be fairly specific with you answer.
    ALV Grid code:
    form user_command using r_ucomm     like sy-ucomm
                            rs_selfield type slis_selfield.
      case r_ucomm.
        when '&IC1'.
          read table gt_data index rs_selfield-tabindex into gt_data_drilldown.
          set parameter id 'LIF' field gt_data_drilldown-lifnr.
          set parameter id 'BLN' field gt_data_drilldown-belnr.
          set parameter id 'CHK' field gt_data_drilldown-chect.
          set parameter id 'BES' field gt_data_drilldown-ebeln.
          set parameter id 'BSP' field gt_data_drilldown-ebelp.
          set parameter id 'MAT' field gt_data_drilldown-matnr.
          set parameter id 'WRK' field gt_data_drilldown-werks.
          call transaction 'ZRVRAD' and skip first screen.
      endcase.
    endform.   
    Detail report code:
    start-of-selection.
    all fields are in DATA stmts.
      get parameter id 'LIF' field lifnr.
      get parameter id 'BLN' field belnr.
      get parameter id 'CHK' field chect.
      get parameter id 'BES' field ebeln.
      get parameter id 'BSP' field ebelp.
      get parameter id 'MAT' field matnr.
      get parameter id 'WRK' field werks.
    end-of-selection.
      write:/1 sy-vline,
            lifnr under 'Vendor #',
            35 sy-vline,
            belnr under 'Invoice #',
            50 sy-vline,
            chect under 'Cheque #',
            65 sy-vline,
            belnr under 'PO #'.
      uline.
      uline.
      write:/1 sy-vline,
            chect under 'Item #',
            90 sy-vline,
            matnr under 'Material #',
            105 sy-vline,
            werks under 'Plant'
    Thanks in advance for your help - Jim

    Thanks for the replies.
    Problem was resolved with submit report.  Code is below:
    <u>Calling ALV List program:</u>
    FORM user_command USING r_ucomm     LIKE sy-ucomm
                            rs_selfield TYPE slis_selfield.
      CASE r_ucomm.
        WHEN '&IC1'.
          READ TABLE gt_data INDEX rs_selfield-tabindex INTO gt_data_drilldown.
          SET PARAMETER ID 'LIF' FIELD gt_data_drilldown-lifnr.
          SET PARAMETER ID 'BLN' FIELD gt_data_drilldown-belnr.
          SET PARAMETER ID 'CHK' FIELD gt_data_drilldown-chect.
          SET PARAMETER ID 'BES' FIELD gt_data_drilldown-ebeln.
          SET PARAMETER ID 'BSP' FIELD gt_data_drilldown-ebelp.
          SET PARAMETER ID 'MAT' FIELD gt_data_drilldown-matnr.
          SET PARAMETER ID 'WRK' FIELD gt_data_drilldown-werks.
          SUBMIT zco_rpt_vra_detail AND RETURN.
          IF sy-subrc <> 0.
          ENDIF.
      ENDCASE.
    ENDFORM.                    "user_command
    <u>Called program zco_rpt_vra_detail:</u>
    START-OF-SELECTION.
      GET PARAMETER ID 'LIF' FIELD lifnr.
      GET PARAMETER ID 'BLN' FIELD belnr.
      GET PARAMETER ID 'CHK' FIELD chect.
      GET PARAMETER ID 'BES' FIELD ebeln.
      GET PARAMETER ID 'BSP' FIELD ebelp.
      GET PARAMETER ID 'MAT' FIELD matnr.
      GET PARAMETER ID 'WRK' FIELD werks.
    END-OF-SELECTION. 
      WRITE:/1 sy-vline, 'Vendor', 20 sy-vline, 'Vendor #', 35 sy-vline, 'Invoice #',50 sy-vline,
            'Cheque #', 65 sy-vline, 'PO #', 80 sy-vline, 'Item #', 90 sy-vline,
            'Material #', 105 sy-vline, 'Plant'.
      ULINE.
      WRITE: 'MyVendor' UNDER 'Vendor', lifnr UNDER 'Vendor #', belnr UNDER 'Invoice #',
            chect UNDER 'Cheque #', ebeln UNDER 'PO #', ebelp UNDER 'Item #', matnr UNDER 'Material #',
            werks UNDER 'Plant'.

  • CF8 and connection pooling using MS SQL 2005 JDBC Driver

    After upgrading one of our production servers to CF8 we're
    getting errors under load while connecting to MS SQL 2000 data
    bases using the MS SQL 2005 JDBC 1.1 driver instead of the driver
    cf8 ships with. The following error is recorded in the logs:
    Error Executing Database Query. The TCP/IP connection to the
    host has failed. java.net.BindException: Address already in use:
    connect
    Confirmed by the database statistics, Coldfusion is no longer
    pooling the database connections. After changing the data source to
    use the build in driver everything works fine. We've been using
    this driver and CF7 for some time without this error.
    Is this a compatibility issue between the driver and Java 6?
    Or is there a conflict between this driver and the build in driver?
    Has anyone seen similar issues? We’d like to use this driver
    rather then the build in one.
    Thanks,
    Remy Becher

    thanks for the answer...I have been waiting for one..I do agree that connection ppooling is same ..but I would appreciate it if someone could point me to some example implemenations using MS JDBC type 4 driver..
    Thanks again..
    PS: I did search the forum before posting this..

  • Web container session setting and AM session setting

    We have access manager deployed on a sun appserver 9.1. Just wondering if Access Manager making use of the session properties setting on the instance/domain web container configuration? How is the session timeout at the web container level going to impact the Access Manager in performance?
    Thanks,
    Mo

    Brenden,
    what about the prepare session method on the AM. If you override this then after the call to super class you should be in an after connect. In my VPD examples I use this method to set the VPD application context getting the username from getUserPrincipal on teh Am
    Frank

  • Open telnet session using PL/SQL

    Dear all
    I have made a function that returns a value when a remote server runs a specific process. In order to find this, I would like to run a telnet command along with some grep parameters. This can be done using a Java class, but it is not very functional! Is this a way to do using only PL/SQL?
    Thanx in advance

    I know there are a couple of Java telnet clients out there, I'm not sure whether they support the JDK in your database. What version of Oracle are you using? The other option would be to write a script that does whatever you want to do and just call the batch file.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

Maybe you are looking for