Locking in a Table

Hello
i am using oracle 9i.i have twq queries
1)Is there any way to lock an entire table in the database.
2)Is there any way to lock a particular row in a table.
Regards Sourav

1)Is there any way to lock an entire table in the database.--> there are 5 or 6 level of locks with regard to table.
There is a command of locking a table.
lock table ...
2)Is there any way to lock a particular row in a table.
--> select .. for update
--> update a row and no commit

Similar Messages

  • Function module to hold and release lock on MARD table entry

    Hi Gurus,
    Can you please tell me Function module to HOLD lock on MARD table and the Function Module to release lock on MARD table entry.
    Thanks and Regards,
    Sudipto

    Look via SE11 lock objects, use F4 for tables MAR*, the best for your request is on MARC table with object EMMARCS, so use FM ENQUEUE_EMMARCS and DEQUEUE_EMMARCS.
    Regards,
    Raymond

  • How to find out the locks in the table

    Any query anybody have to find out locks in any table.

    Here is a version with SID and serial# data:
    set linesize 150;
    set head on;
    col sid_serial form a13
    col ora_user for a15;
    col object_name for a35;
    col object_type for a10;
    col lock_mode for a15;
    col last_ddl for a8;
    col status for a10;
    break on sid_serial;
    SELECT l.session_id||','||v.serial# sid_serial,
           l.ORACLE_USERNAME ora_user,
           o.object_name,
           o.object_type,
           DECODE(l.locked_mode,
              0, 'None',
              1, 'Null',
              2, 'Row-S (SS)',
              3, 'Row-X (SX)',
              4, 'Share',
              5, 'S/Row-X (SSX)',
              6, 'Exclusive',
              TO_CHAR(l.locked_mode)
           ) lock_mode,
           o.status,
           to_char(o.last_ddl_time,'dd.mm.yy') last_ddl
    FROM dba_objects o, gv$locked_object l, v$session v
    WHERE o.object_id = l.object_id
          and l.SESSION_ID=v.sid
    order by 2,3;

  • How to implement the shared lock in a  table view

    Hi,
    How to implement the shared lock in a  table view.for multiple users to edit on this same table.
    Thanks in advance
    Swathi

    Hi,
    Please refer this link to find solution to your querry.
    Hope it helps.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/c322c690-0201-0010-fb86-811c52b0acc2.
    Regards,
    Rahul

  • Table overflowed  when trying to sap locks in the table..

    Dear ALL,
      when trying to sap locks in the table then its showing table overflowed. can telle the actual reason.
    Reagards.
    ASHUTOSH

    Hi, ALL
    suddenly sap PP persons execute the report, " errors comes as last msg  table overflow" whats the main reasons. i konw my self it automatically resize the table.
    Regards,
    ASHUTOSH

  • Lock object for table KNVP and KNVK

    Hello Friends,
    Can you please tell me the standard lock object for the table KNVP and KNVK.
    Thank and regards,
    Kuldeep

    Hi
    see this and do accordingly
    Lock objects are use in SAP to avoid the inconsistancy at the time of data is being insert/change into database.
    SAP Provide three type of Lock objects.
    - Read Lock(Shared Locked)
    protects read access to an object. The read lock allows other transactions read access but not write access to
    the locked area of the table
    - Write Lock(exclusive lock)
    protects write access to an object. The write lock allows other transactions neither read nor write access to
    the locked area of the table.
    - Enhanced write lock (exclusive lock without cumulating)
    works like a write lock except that the enhanced write lock also protects from further accesses from the
    same transaction.
    You can create a lock on a object of SAP thorugh transaction SE11 and enter any meaningful name start with EZ Example EZTEST_LOCK.
    Use: you can see in almost all transaction when you are open an object in Change mode SAP could not allow to any other user to open the same object in change mode.
    Example: in HR when we are enter a personal number in master data maintainance screen SAP can't allow to any other user to use same personal number for changes.
    Technicaly:
    When you create a lock object System automatically creat two function module.
    1. ENQUEUE_<Lockobject name>. to insert the object in a queue.
    2. DEQUEUE_<Lockobject name>. To remove the object is being queued through above FM.
    You have to use these function module in your program.
    check this link for example.
    http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
    tables:vbak.
    call function 'ENQUEUE_EZLOCK3'
    exporting
    mode_vbak = 'E'
    mandt = sy-mandt
    vbeln = vbak-vbeln
    X_VBELN = ' '
    _SCOPE = '2'
    _WAIT = ' '
    _COLLECT = ' '
    EXCEPTIONS
    FOREIGN_LOCK = 1
    SYSTEM_FAILURE = 2
    OTHERS = 3
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    Normally ABAPers will create the Lock objects, because we know when to lock and how to lock and where to lock the Object then after completing our updations we unlock the Objects in the Tables
    http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
    purpose: If multiple user try to access a database object, inconsistency may occer. To avoid that inconsistency and to let multiple user give the accessibility of the database objects the locking mechanism is used.
    Steps: first we create a loc object in se11 . Suppose for a table mara. It will create two functional module.:
    1. enque_lockobject
    1. deque_lockobject
    before updating any table first we lock the table by calling enque_lockobject fm and then after updating we release the lock by deque_lockobject.
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
    GO TO SE11
    Select the radio button "Lock object"..
    Give the name starts with EZ or EY..
    Example: EYTEST
    Press Create button..
    Give the short description..
    Example: Lock object for table ZTABLE..
    In the tables tab..Give the table name..
    Example: ZTABLE
    Save and generate..
    Your lock object is now created..You can see the LOCK MODULES..
    In the menu ..GOTO -> LOCK MODULES..There you can see the ENQUEUE and DEQUEUE function
    Lock objects:
    http://www.sap-img.com/abap/type-and-uses-of-lock-objects-in-sap.htm
    http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
    Match Code Objects:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/41/f6b237fec48c67e10000009b38f8cf/content.htm
    http://searchsap.techtarget.com/tip/0,289483,sid21_gci553386,00.html
    See this link:
    http://www.sap-img.com/abap/type-and-uses-of-lock-objects-in-sap.htm
    Check these links -
    lock objects
    Lock Objects
    Lock Objects
    Regards
    Anji

  • Lock for PRPS table(CJ20N) project.

    Hi
    I am trying to LOCK the project(table PRPS) using OPEN FI Func module.
    But its not possible.
    Below is my observation.
    using Below FM to lock
    L_V_PSPID = PRPS-PSPHI
       CALL FUNCTION 'ENQUEUE_EC_PROJS'
        EXPORTING
          MODE_PROJ_ENQ  = L_V_ENQMODE "E
          TYP            = L_V_ENQTYPE "P
          PSPID          = L_V_PSPID   " XXX-1234457  "project
        EXCEPTIONS
          FOREIGN_LOCK   = 1
          SYSTEM_FAILURE = 2
          OTHERS         = 3.
    When i execute in OPENFI, Lock record is created for XXX-1234457
    But when i update using transaction CJ20N, new lock record is created
    as XXX1234457(without hyphen) and lock is not done.
    Which parameter should be used in PSPID?
    Should i have to use PROJ-PSPID? or PRPS-PSPHI?
    Regards
    prince

    Hi Prince,
        CALL FUNCTION 'ENQUEUE_EC_PROJS'
             EXPORTING
                  TYP   = 'P'
                  PSPID = PROJ-PSPID
             EXCEPTIONS
                  FOREIGN_LOCK   = 01
                  SYSTEM_FAILURE = 02.
    The above functional module works fine and in your code remove the mode you r passing and you need to pass PSPID values not psphi.
    Regards,
    S.C.K
    Edited by: Chandrakumar S on Jan 12, 2012 2:49 PM
    Edited by: Chandrakumar S on Jan 12, 2012 2:50 PM

  • How to set DDL lock for a table

    OCI,how to set DDL lock for a table?

    Oracle acquires a dictionary lock automatically on behalf of any DDL transaction requiring it. Users cannot explicitly request DDL locks. Only individual schema objects that are modified or referenced are locked during DDL operations. The whole data dictionary is never locked
    DDL locks fall into three categories: exclusive DDL locks, share DDL locks, and breakable parse locks.
    see this link
    http://www.sc.ehu.es/siwebso/KZCC/Oracle_10g_Documentacion/server.101/b10743/consist.htm#i5281

  • How to check the locks in a table

    Hi
    Can any one tell me the commands to check the locks and get rid of the locks in a table.
    Thanks and Reg
    Debashis

    v$lock
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/manproc.htm#sthref764

  • Lock's the table

    hi,
    I have update statement like
    Update table_name a
    set sal =
         (select sal
         from sal_table b
         where a.empno = b.emp_no);
    when, i run this statement, it takes near by 20 minutes.
    and upto that time it lock's the table.
    Is it possible, i run same statement and at that i use dml statement on that?
    Please, help...

    Do you really need to update every row of TABLE_NAME? My guess is that you want a WHERE clause, i.e.
    Update table_name a
       set sal =
        (select sal
          from sal_table b
         where a.empno = b.emp_no)
    where exists
        (select 1
           from sal_table b
          where a.empno = b.emp_no
            and nvl(a.sal,-1) != nvl(b.sal,-1))If you actually want to update every row of the table, this won't change anything. But if it's likely that most of the salaries in TABLE_NAME are already correct, it is likely to be far more efficient.
    Justin

  • Archive data of using DART : Job lock problem in table TSP01

    Hi ,
    I'm facing problem while archiving from Production system to UNIX using DART.
    Using TC: FTW1A to data extract, once data has extracted, we need to do verifaction progess through TC. FTWE1(run a BG jobRTXWCHK4) and FTWD(BG Job RTXWCHK2).
    When I am running TC: FTWD(BG Job RTXWCHK2)to verify, it was holding an extensive lock on the TSP01 table for long period of time which blocking others processing with this table, So We need to terminate this job. For the time being solution is to run this job during weekends.But I want solution for this.
    Is any boby can help me in this problem?
    Regards,
    Nupur S Jaipuriyar

    Locking a row that does not exist can be difficult.
    On most database you can lock an entire table through "LOCK TABLE <table>", however this may be extreme. Potentially you could also insert an empty row into the table with the id that you want to lock, then you would have a write lock on the row until you commit the transaction.

  • About Dead Lock on apps tables in 11.5.10.2

    Hi All,
    How to find and Kill dead lock on apps table (11.5.10) ?
    Reg
    Chirag Patel

    Chirag,
    Please refer to the following notes, it should be helpful.
    Note: 109061.1 - How to Check Whether an AOL Table is Locked
    https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=109061.1
    Note: 223559.1 - Oracle Application Object Library Table Lock Data Collection Test
    https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=223559.1
    Note: 732271.1 - R12 Oracle Application Object Library (FND): Table Lock Data Collection Test
    https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=732271.1

  • Lock sql server table through DG4ODBC?

    Hi
    I'm using DG4ODBC to connect to SQL server 2008, querying data and insert to Oracle. Is it possible to lock the remote table in sql server, prohibit it from inserting any new record?
    My Oracle version is 11.1.0.7.0, OS version : Red Hat Enterprise Linux Server release 5.3.
    Thanks
    Edited by: user1152556 on 21:20 06-05-2013

    by default the gateway starts its own transaction on the SQL Server side and as soon as you even execute a select it locks the data until you execute a commit (even when only selecting data). Unfortunately the amount of data being locked now depends on the SQL Server version and on the lock mode chosen by the SQl Server (row/page/table).
    Another option would be to explicit set a transaction isolation level for your gateway session using the passthrough command:
    DECLARE
    ret integer;
    c integer;
    BEGIN
    c := DBMS_HS_PASSTHROUGH.OPEN_CURSOR@MSODBCSQLSERVER_DG4ODBC_EMGTW_1123_DB;
    DBMS_HS_PASSTHROUGH.PARSE@MSODBCSQLSERVER_DG4ODBC_EMGTW_1123_DB(c, 'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE');
    ret := DBMS_HS_PASSTHROUGH.EXECUTE_NON_QUERY@MSODBCSQLSERVER_DG4ODBC_EMGTW_1123_DB(c);
    dbms_output.put_line(ret ||' passthrough output');
    DBMS_HS_PASSTHROUGH.CLOSE_CURSOR@MSODBCSQLSERVER_DG4ODBC_EMGTW_1123_DB(c);
    END;
    Please check out your SQL Server documentation which isolation level will fit for your needs.
    - Klaus

  • UL type lock on a table blocking all other users

    Hi,
    We have a referential integrity constraint on a version enabled table, that refers to a non-version enabled table (highly active table..lots of inserts/updates). An insert into the version enabled table is causing a UL type lock and the non-versioned table is locked (literally the table is inaccessible) and we see blocking locks. How can I avoid this situation? Is there any OWM settings that will help me resolve this issue? I am using workspace manager version 10.2.0.4.2.
    Thanks.

    Hi,
    An insert into a child table requires a lock on the parent table which will block updates and deletes into its parent table(s) until the lock is released. This is done to maintain the validity of the constraint. Otherwise, it would be possible to have child rows without parents, which we obviously need to prevent from happening.
    If possible, you could commit/rollback the transaction involving the child table more frequently, so that the locks are released and dmls can proceed on the parent table.
    You can also take a look at the following thread.
    RIC in OWM - ORA-20171 deadlock detected ...
    It is specifically referring to deadlock situations, but it also explains our locking behavior for RIC tables.
    Regards,
    Ben

  • Locking a custom table

    Hi All !!
    I want to update one custom table which has key fields K1, K2 and K3.
    I am using ENQUEUE_E_TABLE  to lock the table.But I dont know how to send the table for enqueue.
    Nextly, I need to send keys of table .Should I use any structure where I append the key fields and export the structure. The function call is as :
      CALL FUNCTION 'ENQUEUE_E_TABLE'
       EXPORTING
         MODE_RSTABLE         = 'E'
         TABNAME             = ?
         VARKEY               =?
       EXCEPTIONS
         FOREIGN_LOCK         = 1
         SYSTEM_FAILURE       = 2
         OTHERS               = 3
    Please help in this regard..
    Thanks in advance..
    Prabhas.

    Hai.
    Check this.
    Lock objects are use in SAP to avoid the inconsistancy at the time of data is being insert/change into database.
    SAP Provide three type of Lock objects.
    - Read Lock(Shared Locked)
    protects read access to an object. The read lock allows other transactions read access but not write access to
    the locked area of the table
    - Write Lock(exclusive lock)
    protects write access to an object. The write lock allows other transactions neither read nor write access to
    the locked area of the table.
    - Enhanced write lock (exclusive lock without cumulating)
    works like a write lock except that the enhanced write lock also protects from further accesses from the
    same transaction.
    You can create a lock on a object of SAP thorugh transaction SE11 and enter any meaningful name start with EZ Example EZTEST_LOCK.
    Use: you can see in almost all transaction when you are open an object in Change mode SAP could not allow to any other user to open the same object in change mode.
    Example: in HR when we are enter a personal number in master data maintainance screen SAP can't allow to any other user to use same personal number for changes.
    Technicaly:
    When you create a lock object System automatically creat two function module.
    1. ENQUEUE_<Lockobject name>. to insert the object in a queue.
    2. DEQUEUE_<Lockobject name>. To remove the object is being queued through above FM.
    You have to use these function module in your program.
    check this link for example.
    http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
    tables:vbak.
    call function 'ENQUEUE_EZLOCK3'
    exporting
    mode_vbak = 'E'
    mandt = sy-mandt
    vbeln = vbak-vbeln
    X_VBELN = ' '
    _SCOPE = '2'
    _WAIT = ' '
    _COLLECT = ' '
    EXCEPTIONS
    FOREIGN_LOCK = 1
    SYSTEM_FAILURE = 2
    OTHERS = 3
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    Normally ABAPers will create the Lock objects, because we know when to lock and how to lock and where to lock the Object then after completing our updations we unlock the Objects in the Tables
    http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
    purpose: If multiple user try to access a database object, inconsistency may occer. To avoid that inconsistency and to let multiple user give the accessibility of the database objects the locking mechanism is used.
    Steps: first we create a loc object in se11 . Suppose for a table mara. It will create two functional module.:
    1. enque_lockobject
    1. deque_lockobject
    before updating any table first we lock the table by calling enque_lockobject fm and then after updating we release the lock by deque_lockobject.
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
    GO TO SE11
    Select the radio button "Lock object"..
    Give the name starts with EZ or EY..
    Example: EYTEST
    Press Create button..
    Give the short description..
    Example: Lock object for table ZTABLE..
    In the tables tab..Give the table name..
    Example: ZTABLE
    Save and generate..
    Your lock object is now created..You can see the LOCK MODULES..
    In the menu ..GOTO -> LOCK MODULES..There you can see the ENQUEUE and DEQUEUE function
    Lock objects:
    http://www.sap-img.com/abap/type-and-uses-of-lock-objects-in-sap.htm
    http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
    Match Code Objects:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/41/f6b237fec48c67e10000009b38f8cf/content.htm
    http://searchsap.techtarget.com/tip/0,289483,sid21_gci553386,00.html
    See this link:
    http://www.sap-img.com/abap/type-and-uses-of-lock-objects-in-sap.htm
    Check these links -
    lock objects
    Lock Objects
    Lock Objects
    Regards.
    Sowjanya.B.

Maybe you are looking for