How to lock session in pl/sql

i have application where user logs and perform manipulation operation such as insert and update on database table.
some time its possible that same user login twice, i just want to hold one session  until and unless dml operation perform by another session gets complete.
how to accomplish this in database level
plz suggest

i also read below statement on net
Dynasets created with FOR UPDATE are handled correctly in most cases by scanning the SQL statement for the FOR UPDATE construct (This is necessary because the Oracle database functions do not distinguish between SELECT and SELECT FOR UPDATE SQL statements.) It is possible that some exotic FOR UPDATE SQL statement will be treated as "not FOR UPDATE"—meaning that rows are not locked during the lifetime of the dynaset. If the FOR UPDATE is not recognized, rows are locked only during an Edit/Update sequence. However, during the Edit/Update sequence, the row is verified as unchanged before the Edit is permitted.
i think in my case FOR UPDATE is not working

Similar Messages

  • How to find session information in sql plus

    Can someone please tell me how to find session information in sql plus? I specifically want to know my privileges for the current session. Thanks in advance.

    SELECT * FROM session_privs;
    SELECT * FROM session_roles;

  • How can a session have an ACTIVE status with a WAITING state

    Hi all,
    I would like to know the difference between status and state of a session ?
    The documentation says :
    for status ACTIVE : Session currently executing SQL
    for state WAITING : The session is currently waiting...
    How can a session execute a SQL statement and be waiting at the same time ?
    Regards,
    fcjunic.

    Hi fcjunic,
    It's really not paradoxical, once you understand the definition of the terms.
    First, we have V$SESSION.STATUS, which can be ACTIVE or INACTIVE. A session is ACTIVE if it's in a database call. So, think of this from the client side point of view. A session does a parse call, or an execute call, or a fetch call, etc. For the duration of that call, till control returns back to the client, that session is said to be ACTIVE.
    From the time the calls returns, till the time of the next call, the session is INACTIVE.
    Next, we have V$SESSION.STATE. This is probably more useful to think of from the server process point of view. This refers to whether the server process is currently running, i.e. on the CPU, or WAITING, i.e., waiting on a resource. Possible values for this column are WAITING, WAITED KNOWN TIME, WAITED SHORT TIME, and WAITED UNKNOWN TIME. Of those possibilities, a session is only actually waiting if STATE is WAITING. All the other values mean that it's no longer waiting, but is running on CPU.
    A session w/ STATUS of INACTIVE, will always be in STATE of WAITING, waiting on the 'SQL*NET message from client' wait. So, in that case, it means the server process is waiting around for work to do. It's in between calls, so, STATUS is INACTIVE, and it's waiting on that network port, to receive the next call from the client.
    An example of a session that's ACTIVE and has STATE of WAITING, would be a session that's, for example, doing a full table scan. So, it's got lots of data to read from disk. While the session waits for the read from disk to complete, the session waits on 'db file scattered read'.
    Finally, for completeness, the difference between the different possible values of the STATE column. I already covered WAITING. If a session is not waiting, it's now on CPU, and it previously waited. If so, it either waited more than 10 ms, in which case it will report WAITED KNOWN TIME, or less than 10 ms, in which case it reports WAITED SHORT TIME, or timed_statistics is false, in which case this column will always be WAITED UNKNOWN TIME. Also, it's important to pay attention to this column, when trying to interpret the WAIT_TIME and SECONDS_IN_WAIT columns.
    See here:
    http://download.oracle.com/docs/cd/E11882_01/server.112/e10820/dynviews_3016.htm#REFRN30223
    for more information.
    Hope that helps,
    -Mark

  • How can I stop Crystal reports from locking tables in our SQL db?  PLEASE HELP!!!

    Post Author: kevans
    CA Forum: Data Connectivity and SQL
    I really need help with this and so far I've had no luck finding a solution on Crystal's knowledge base, forums our even outside of this site.
    I recently upgraded from crw8 to crw10 and of course after converting reports and placing them into production I now discovered that crw10 will place locks (blocking) on the SQL tables it is using.
    Is there a setting in crystal so I can turn this off?  Someone said I can use a statement like ... "with (nolock)"  but I can't seem to figure out the correct syntax to use, I'm not even sure if this works since I can't find info on it.  I desperately need help!!!
    Example - if this is my select statement how would I add the "nolock" to it?
    (DateTimeToDate (PDMTimeToDateTime ({call_req.open_date})) >= {?Starting Date}) AND   (DateTimeToDate (PDMTimeToDateTime ({call_req.open_date})) <= {?End Date}) AND    (if {?Select_Group} <> "ALL" then {ca_contact.last_name} = {?Select_Group}         else if {?Select_Group} = "ALL" then true) AND            {call_req.type} = {?Type}

    Post Author: sharonmtowler
    CA Forum: Data Connectivity and SQL
    no lock is used in the sql stored procedure. i believe you can look at your sql statement in the report and place the nolock(prior to the table name)
    the only problem with this is you may get dirty data. most sql developers dont recommend it especially with real time data.

  • How to check Locking sessions in oracle 10g

    Hi,
    I have tried to get locking sessions. i got the blocking session by using v$lock view.
    Pls help how to get locking sessions.
    Regards,
    Venkat

    Hi Venkat
    Or just run this independent of database version
    select a.sid blocker, 'is blocking the session ', b.sid blockee from v$lock a, v$lock b
    where a.block =1 and b.request > 0  and a.id1=b.id1 and a.id2=b.id2;You can extend this query to find the username and machine (plus all other details) from v$session using the a.sid and b.sid from above
    To find the blocking session_
    SELECT S.SID, S.SQL_ID, S.USERNAME, S.MACHINE from
    V$SESSION S WHERE S.SID  = (SELECT blocker from
    (select a.sid blocker, 'is blocking the session ', b.sid blockee from v$lock a, v$lock b
    where a.block =1 and b.request > 0  and a.id1=b.id1 and a.id2=b.id2
    *_To find the blocked session_*SELECT S.SID, S.SQL_ID, S.USERNAME, S.MACHINE from
    V$SESSION S WHERE S.SID = (SELECT blockee from
    (select a.sid blocker, 'is blocking the session ', b.sid blockee from v$lock a, v$lock b
    where a.block =1 and b.request > 0 and a.id1=b.id1 and a.id2=b.id2
    Edited : Added blocker and blockee code                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to check locked session?

    Hi all,
    How do I check locked session,or which tables has been locked.and how to kill the lock session. i would need to do it in sqlplus. we'r not allowed to use toad.

    SELECT sess.osuser AS OsUser, NVL (sess.program, sess.module) AS
    Program, sess.terminal AS Terminal,
    obj.Object_Name AS TABLE_NAME,
    DBMS_ROWID.rowid_create (1, ROW_WAIT_OBJ#, ROW_WAIT_FILE#,
    ROW_WAIT_BLOCK#, ROW_WAIT_ROW#) AS ROW_ID
    FROM dba_objects obj, v$session sess
    WHERE sess.SID IN (SELECT a.SID
    FROM v$lock a, v$session b
    WHERE (id1, id2) IN (SELECT b.id1, b.id2
    FROM v$lock b
    WHERE b.id1 = a.id1 AND
    b.id2 = a.id2 AND b.request > 0)
    AND a.SID = b.SID
    AND a.lmode = 0)
    AND obj.object_id = sess.ROW_WAIT_OBJ#)

  • How to join v$session to v$sql?

    Oracle 9.2.0.8 on Windows 2000 Server
    I am using the query below to identify memory intensive sessions coming from a particular machine. I want to find out what queries they are running. What the best way of doing this? Can I join v$session to v$sql?
    set feedback off
    set verify off
    SET LINESIZE 145
    SET PAGESIZE 9999
    COLUMN sid                     FORMAT 999            HEADING 'SID'
    COLUMN oracle_username         FORMAT a12            HEADING 'Oracle User'     JUSTIFY right
    COLUMN os_username             FORMAT a9             HEADING 'O/S User'        JUSTIFY right
    COLUMN session_program         FORMAT a18            HEADING 'Session Program' TRUNC
    COLUMN session_machine         FORMAT a8             HEADING 'Machine'         JUSTIFY right TRUNC
    COLUMN session_pga_memory      FORMAT 9,999,999,999  HEADING 'PGA Memory'
    COLUMN session_pga_memory_max  FORMAT 9,999,999,999  HEADING 'PGA Memory Max'
    COLUMN session_uga_memory      FORMAT 9,999,999,999  HEADING 'UGA Memory'
    COLUMN session_uga_memory_max  FORMAT 9,999,999,999  HEADING 'UGA Memory MAX'
    COLUMN server                                                            FORMAT a10
    SELECT
        s.sid                sid
      , lpad(s.username,12)  oracle_username
      , lpad(s.osuser,9)     os_username
      , s.program            session_program
      , lpad(s.machine,8)    session_machine
      , lpad(s.server,8)     server
      , (select ss.value from v$sesstat ss, v$statname sn
         where ss.sid = s.sid and
               sn.statistic# = ss.statistic# and
               sn.name = 'session pga memory')        session_pga_memory
      , (select ss.value from v$sesstat ss, v$statname sn
         where ss.sid = s.sid and
               sn.statistic# = ss.statistic# and
               sn.name = 'session pga memory max')    session_pga_memory_max
      , (select ss.value from v$sesstat ss, v$statname sn
         where ss.sid = s.sid and
               sn.statistic# = ss.statistic# and
               sn.name = 'session uga memory')        session_uga_memory
      , (select ss.value from v$sesstat ss, v$statname sn
         where ss.sid = s.sid and
               sn.statistic# = ss.statistic# and
               sn.name = 'session uga memory max')    session_uga_memory_max
    FROM
        v$session  s
    WHERE s.machine LIKE 'land%'
    ORDER BY session_pga_memory DESC
    /

    John,
    The hash_value (and in 10g the sql_id) is the better option for this join - it's an "indexed" access path, whereas the sql_address join leaves you thrashing though the library cache hammering the library cache latches as you go.
    (See http://www.jlcomp.demon.co.uk/guilty.html and associated notes for various comments on messing with v$ )
    Unfortunately, even that doesn't give you an exact answer until 10g, as Oracle does not expose the child number for the specific child cursor that this session is using. It's a piece of information that's hidden underneath v$open_cursor in x$kgllk.
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk

  • Lock session

    hi guys.
    please how can i know the lock session if i have lock how to know the session information anf how to kill it .

    Hi you can check the information using either v$LOCK or v$LOCKED_OBJECT views. after getting SID from any of these views, issue
    sql> alter system kill session'SID,SERIAL#';
    where sid and serial# can be get from v$session view. you need to get serial# by mapping SID from v$lock to SID in v$session.

  • How to pass session variable value with GO URL to override session value

    Hi Gurus,
    We have below requirement.Please help us at the earliest.
    How to pass session variable value with GO URL to override session value. ( It is not working after making changes to authentication xml file session init block creation as explained by oracle (Bug No14372679 : which they claim it is fixed in 1.7 version  Ref No :Bug 14372679 : REQUEST VARIABLE NOT OVERRIDING SESSION VARIABLE RUNNING THRU A GO URL )
    Please provide step by step solution.No vague answers.
    I followed below steps mentioned.
    RPD:
    ****-> Created a session variable called STATUS
    -> Create Session Init block called Init_Status with SQL
        select 'ACTIVE' from dual;
    -> Assigned the session variable STATUS to Init block Init_Status
    authenticationschemas.xml:
    Added
    <RequestVariable source="url" type="informational"
    nameInSource="RE_CODE" biVariableName="NQ_SESSION.STATUS"/>
    Report
    Edit column "Contract Status" and added session variable as
    VALUEOF(NQ_SESSION.STATUS)
    URL:
    http://localhost:9704/analytics/saw.dll?PortalGo&Action=prompt&path=%2Fshared%2FQAV%2FTest_Report_By%20Contract%20Status&RE_CODE='EXPIRED'
    Issue:
    When  I run the URL above with parameter EXPIRED, the report still shows for  ACTIVE only. The URL is not making any difference with report.
    Report is picking the default value from RPD session variable init query.
    could you please let me know if I am missing something.

    Hi,
    Check those links might help you.
    Integrating Oracle OBIEE Content using GO URL
    How to set session variables using url variables | OBIEE Blog
    OBIEE 10G - How to set a request/session variable using the Saw Url (Go/Dashboard) | GerardNico.com (BI, OBIEE, O…
    Thanks,
    Satya

  • How to get Arabic dates in SQL*Plus?

    I want to do a very simple thing.
    I want to type in Arabic and Display dates in Arabic.
    Instead i get ????? ??????? ????? ??????? ? ? ???????, ????? for this?
    Why is this?
    I then changed my Windows XP "Regional and Language Options" all to Arabic. Now, I get AR (Arabic) in my language selection bar at the bottom of the Desktop. When I choose AR I can type Arabic in Notepad. ُ
    Even HERE I can type in Arabic: فغحث غخعق ةثسسشلث اثقث
    But in Sql*PLus I get ????? ??????? ????? ??????? ? ? ???????, ?????
    If I choose AR in SQL Plus and type in Arabic I get garbage characters?
    How to get Arabic in Sql*Plus?
    SQL> SHOW USER
    USER is "ARABDTEST"
    SQL> SELECT * FROM v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    PL/SQL Release 11.1.0.6.0 - Production
    CORE    11.1.0.6.0      Production
    TNS for 32-bit Windows: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - Production
    SQL> SELECT * FROM nls_session_parameters;
    PARAMETER                      VALUE
    NLS_LANGUAGE                   AMERICAN
    NLS_TERRITORY                  AMERICA
    NLS_CURRENCY                   $
    NLS_ISO_CURRENCY               AMERICA
    NLS_NUMERIC_CHARACTERS         .,
    NLS_CALENDAR                   GREGORIAN
    NLS_DATE_FORMAT                DD-MON-RR
    NLS_DATE_LANGUAGE              AMERICAN
    NLS_SORT                       BINARY
    NLS_TIME_FORMAT                HH.MI.SSXFF AM
    NLS_TIMESTAMP_FORMAT           DD-MON-RR HH.MI.SSXFF AM
    NLS_TIME_TZ_FORMAT             HH.MI.SSXFF AM TZR
    NLS_TIMESTAMP_TZ_FORMAT        DD-MON-RR HH.MI.SSXFF AM TZR
    NLS_DUAL_CURRENCY              $
    NLS_COMP                       BINARY
    NLS_LENGTH_SEMANTICS           BYTE
    NLS_NCHAR_CONV_EXCP            FALSE
    17 rows selected.
    SQL> ALTER SESSION set NLS_DATE_LANGUAGE = 'ARABIC';
    Session altered.
    SQL> SELECT TO_CHAR(SYSDATE, 'RRRR/MM/DD YEAR MONTH DAY MON DY AM PM DL') FROM dual;
    TO_CHAR(SYSDATE,'RRRR/MM/DDYEARMONTHDAYMONDYAMPMDL')
    2013/04/08 TWENTY THIRTEEN ?????  ???????  ?????  ???????  ? ? ???????, ????? 08, 2013
    SQL> ALTER SESSION set NLS_DATE_LANGUAGE = 'AMERICAN';
    Session altered.
    SQL>  SELECT TO_CHAR(SYSDATE, 'RRRR/MM/DD YEAR MONTH DAY MON DY AM PM DL') FROM dual;
    TO_CHAR(SYSDATE,'RRRR/MM/DDYEARMONTHDAYMONDYAMPMDL')
    2013/04/08 TWENTY THIRTEEN APRIL     MONDAY    APR MON PM PM Monday, April 08, 2013
    SQL> SELECT * FROM nls_database_parameters;
    PARAMETER                      VALUE
    NLS_LANGUAGE                   AMERICAN
    NLS_TERRITORY                  AMERICA
    NLS_CURRENCY                   $
    NLS_ISO_CURRENCY               AMERICA
    NLS_NUMERIC_CHARACTERS         .,
    NLS_CHARACTERSET               WE8MSWIN1252
    NLS_CALENDAR                   GREGORIAN
    NLS_DATE_FORMAT                DD-MON-RR
    NLS_DATE_LANGUAGE              AMERICAN
    NLS_SORT                       BINARY
    NLS_TIME_FORMAT                HH.MI.SSXFF AM
    NLS_TIMESTAMP_FORMAT           DD-MON-RR HH.MI.SSXFF AM
    NLS_TIME_TZ_FORMAT             HH.MI.SSXFF AM TZR
    NLS_TIMESTAMP_TZ_FORMAT        DD-MON-RR HH.MI.SSXFF AM TZR
    NLS_DUAL_CURRENCY              $
    NLS_COMP                       BINARY
    NLS_LENGTH_SEMANTICS           BYTE
    NLS_NCHAR_CONV_EXCP            FALSE
    NLS_NCHAR_CHARACTERSET         AL16UTF16
    NLS_RDBMS_VERSION              11.1.0.6.0
    20 rows selected.

    I am not sure SQL*Plus in character mode can display Arabic characters on Windows. OTN NLS_LANG FAQ http://www.oracle.com/technetwork/products/globalization/nls-lang-099431.html#_Toc105389288 says:
    >
    if you are testing with "special" characters please DO use the GUI and not the "DOS box" sqlplus.exe !
    >
    SQL*Plus GUI is not available with 11G: you should use SQL Developer.

  • How to bind DATE variables in SQL*Plus

    I have a stored procedure in a package that has a DATE OUT parameter
    myPackage.myProcedure( outDate OUT DATE )
    I am trying to test this from SQL*Plus
    How do I specify a Bind variable for the outDate? The VARIABLE command does not allow DATE types?
    If this was a CHAR type I could have done
    VARIABLE myChar CHAR
    BEGIN
    myPackage.myProcedure( :myChar )
    END;
    PRINT myChar
    How do I do this with DATE data types instead? I am using Oracle 8.1.7.

    you should use VARCHR2 type with the minimum length that can store a value defined by your NLS_DATE_FORMAT
    string. The returned date will be converted to a VARCAHR2 type and the size and format will depend on
    your NLS_DATE_FORMAT setting.
    =============================================================================
    SQL> variable dt VARCHAR2(20)
    SQL> create or replace procedure ret_date(dt OUT DATE) is
    2 begin
    3 dt := SYSDATE ;
    4 end ;
    5 /
    Procedure created.
    SQL> exec ret_date(:dt) ;
    PL/SQL procedure successfully completed.
    SQL> print dt
    DT
    13-OCT-02
    SQL> select sysdate from dual ;
    SYSDATE
    13-OCT-02
    SQL> alter session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS' ;
    Session altered.
    SQL> exec ret_date(:dt) ;
    PL/SQL procedure successfully completed.
    SQL> print dt
    DT
    13-OCT-2002 10:43:23
    SQL>
    ================================================================

  • 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?

  • 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.

  • How can I extract the native SQL generated by TopLink?

    How can I extract the native SQL generated by TopLink?
    This is useful for example to use pagination, or pass the SQL to a stored procedure that may do many things, like using a cursor, or apply security.
    Pagination example where the SQL inside the inner parentheses are generated from Toplink, and the outer SQL is generic:
    select *
    from
    (select xx.*, rownum as rn
    from
    (select o.order_id, r.name, ...
    from placed_order o, restaurant r
    where o.restaurant_id = r.restaurant_id
    order by o.order_ext_id
    ) xx
    where rownum < 21)
    where rn > 10

    Alternatively, you can open your sessions.xml in the Mapping Workbench and for a specific session, you can Click the Login Tab and then the Options tab. Then select "Native SQL" and it will be outputted to the console (assuming that is where you outputing it).
    zb

  • How to Generate Trace Files in SQL*Plus

    Hi Friends ,
    How to Generate Trace Files in SQL*Plus ?
    i have no idea
    thanks
    raj

    What trace files would you like to generate?
    Are we talking SQL trace files?
    ALTER SESSION SET sql_trace = TRUE;This will be generated in the user_dump_dest on the server.
    show parameter dump

Maybe you are looking for

  • Error in Jdeveloper while running a project on weblogic server.

    Hi , I am receiving below error while running a project in Weblogic. I am using Jeveloper 11.1.1.2.0 *** Using port 7101 *** "C:\Documents and Settings\nlatif\Application Data\JDeveloper\system11.1.1.2.36.55.36\DefaultDomain\bin\startWebLogic.cmd" [w

  • Album artwork turns solid black (for one album only)

    I recently decided to get serious about adding missing artwork to my collection (most of it was ripped long ago, before such things were quite as turnkey). By now, I've added artwork to dozens of albums with no problem, then I got to one where I add

  • Wh7at version of itunes works with windows 7 32bit

    Can anyone help me with this I just cant get the itunes store thanks Seumas

  • IF ELSEIF ELSE  error

    Good Morning This code compiles fine: IF v_status_code = '3' THEN INSERT INTO CRAM_STG (ID, ITEM_NO, CHGNBR, UI, SUPPLYACTIONCODE, QTY, ACCT, RECEIPTDATE, REQUISITIONDATE, PROCESSDATE) VALUES ( to_char(sysdate,'YYMMDDHH24MISS') || test_seq.nextval, n

  • Album artwork not displaying correctly

    I recently updated to 1.1.4 and the album artwork associated with my music does not match up anymore. It is very strange. When I flip through coverflow everything works fine, but once I play a song from a particular album, it shows the album art for