Who is locking a Table ?
Hi
Is there some way to know who is locking a table ?
1) Do you really mean locking a table? Or locking a row within the table?
2) DBA_LOCKS will have information about locks at an object level. Information about row-level locks is stored in the row itself, so that is not generally visible. If session 1 has locked a row and session 2 is blocked waiting to lock that row, session 3 is able to see that fact, but only while session 2 is blocked.
Justin
Similar Messages
-
I just wanted to know , how the lock works on a table. I am very much confused..
Let me put down my requirement...
I am inserting a new record in a Table(Batches) for which one of the columns(no_batch) is an incrementing value. To acheive this, I select the max value of the above column from the same table and add 1 to it.
(Pl note: I cannot use sequence for this
nor I cannot have an UNIQUE constraint on this Column... )
Then I insert this new Record.
The problem what i faced was...
When Multiple users accessed to insert the record at the same time,
Selecting and inserting on the table allowed duplicate values to be inserted on the no_batch column in the batches Table.
Is there any way out to lock the Table exclusively, when a user is accessing this Table until he/she gives a COMMIT or ROLLBACK operation on the Table.
so that the next user should wait for the Resources.
The Time delay is okay for me.
Here is the skeleton of my insert procedure..
PROCEDURE insert_record IS
BEGIN
<set of statements>
SELECT max(no_batch) + 1
into var_no_batch
from batches
where <conditions> ;
insert into batches values
(val1, val2, val3,var_no_batch,........);
commit;
END;
I have an alternative, but I dont know whether this will work out.
Can I give an UPDATE statement which will update 0 rows on the same Table, so that it will be locked, and then, I SELECT and INSERT on the same table, which I guess will work, and a COMMIT will release the LOCK on this Table..
Let me know if this is correct...
This is very urgent.....
Any help and suggestions would be greatly appreciated. and Thanks in Advance..
nullThanks for your Help and Suggestions...
Sorry,I cannot use a select for update Clause, since the select has an aggregate function.
There are some other procedures which access this Table(only select statements). Will this LOCK stop the other users also who access this Table through the SELECT procedures. Please let me know about that. -
ORA-00054 - Find user who have lock
Hi,
I'm using "select for update NOWAIT" in my application for editing records. It works but after I catch ORA-00054 I want to find username who have the lock.
The basic step is propably to query view v$lock and propably after then some else view.
Thanks for any idea/solution
SASAYou'll need to scroll down a while to get to your particular question in the thread I linked... I believe it's about a third of the way down.
It is not possible to know who is locking a particular row unless there are two sessions that are blocking each other. If session 1 has a lock on a particular row and session 2 requests a lock on that same row and session 2 is waiting for that lock to free up, session 3 can query the v$lock table to see which session holds the lock and which session is waiting for the lock. Assuming everyone is logging in with their own user name, you can join this information with v$session to find out the username of the person holding the lock. In your case, though, no session is ever blocked, so you cannot determine who owns the lock.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
How to get info who is locking a specific row in the RDBMS 9i?
Hi,
could some one please helop me with this? I would like to know the Oracle user name of the user who is locking a specific row in my table. I can display all locking requests with the following SQL statements. What I could not igure out how to find the rownum that is being locked by others?
SELECT *
FROM v$lock lk, v$session s , DBA_OBJECTS ao, wf_users wu
WHERE lk.lmode > 1
AND s.username IS NOT NULL
AND lk.SID = s.SID
AND ao.OBJECT_ID(+) = lk.id1
AND s.username = wu.NAME(+)
AND ao.owner = USER
AND ao.object_name = 'BWF_IKTATASI_ADATLAPOK';
Thank you in advance,
Tamas SzecsyI'm not sure what's happening with your app. I wrote on up to see if it could handle the CTRL-C. Seems to work fine. Do you have any other JMenuItems with the same accelerator?
import java.awt.event.*;
import javax.swing.*;
public class Copy extends JFrame {
public Copy() {
this.initMenuBar();
this.setSize(400, 300);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
private void initMenuBar() {
JMenuBar menubar = new JMenuBar();
JMenu edit = new JMenu("Edit");
JMenuItem copy = new JMenuItem(new CopyAction("Copy"));
edit.setMnemonic(KeyEvent.VK_E);
copy.setMnemonic(KeyEvent.VK_C);
copy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK));
edit.add(copy);
menubar.add(edit);
this.setJMenuBar(menubar);
public static void main(String[] args) {
new Copy();
private class CopyAction extends AbstractAction {
public CopyAction(String label) {
super(label);
public void actionPerformed(ActionEvent e) {
System.out.println("Action Performed.");
} -
Identifying the procecure/function that has locked a table (or a resource)
Sometimes, I have a procedure failing saying that a table is locked (yes, I know, it could have been written to diligently wait for it to become available). Is there any system table from where I can figure out which procedure has locked a table and which procedures are waiting to access it, and in what order? I am trying to figure out who are the resource hogs here, and what resources are most hogged.
Thanks,
Regards,
SriniHi Keith,
This is bit difficult in GUI.
As mentioned by Mandy, try powershell
Use below to get all the open files:
Get-SMBOpenFile | flFileId SessionId Path ShareRelativePath ClientComputerName ClientUserName
4415226382229 4415226380377 C:\ClusterStorag... VM4\Virtual Mach... 192.168.102.14 Contoso\Contoso-HV2$
4415226382237 4415226380385 C:\ClusterStorag... VM4\VIRTUAL MACH... 192.168.102.14 Contoso\Contoso-HV2$
Identify the interested path and note the 'FileId', ClientComputerName (Is the user Workstation IP)
Use below cmdlet to identify if Locks(1) is Enabled on that path not.
Get-SmbOpenFile -FileId 4415226383569 | Select-Object -Property *ClientComputerName : 192.168.102.14
ClientUserName : Contoso\Contoso-HV2$
ClusterNodeName : Contoso-FS2
ContinuouslyAvailable : True
Encrypted : False
FileId : 4415226383569
Locks : 1
Path : C:\ClusterStorage\Volume2\VMS\VM4.VHDX
Once you find the correct FileId, use below command to ping and find the workstation name having the Lock,
ping -a <IP address>
There are few more cmdlets that you might be interested in.
Get-SMBConnection | fl
Get-SMBSession | fl
References:
Get-SmbOpenFile
http://technet.microsoft.com/en-us/library/jj635701.aspx
Regards,
Satyajit
Please“Vote As Helpful”
if you find my contribution useful or “MarkAs Answer” if it does answer your question. That will encourage me - and others - to take time out to help you. -
How to see lock on table and query?
Hi All,
How do we see lock on table and query?
Thanks,
RafiYes Rafi,
It is working fine at my end. See below:
Opened Session 1 with scott/tiger and:
update emp set ename='xx' where empno=7499;
Opened Session 2 with scott/tiger and:
update emp set ename='xx' where empno=7499;
<<Its lock here>> This session is locked by above one.
Opened Session 3 with sys/pw as sysdba and:
SQL> set serveroutput on
SQL> BEGIN
2 dbms_output.enable(1000000);
3 for do_loop in (select session_id, a.object_id, xidsqn, oracle_username, b.owner owner,
4 b.object_name object_name, b.object_type object_type
5 FROM v$locked_object a, dba_objects b
6 WHERE xidsqn != 0
7 and b.object_id = a.object_id)
8 loop
9 dbms_output.put_line('.');
10 dbms_output.put_line('Blocking Session : '||do_loop.session_id);
11 dbms_output.put_line('Object (Owner/Name): '||do_loop.owner||'.'||do_loop.object_name);
12 dbms_output.put_line('Object Type : '||do_loop.object_type);
13 for next_loop in (select sid from v$lock
14 where id2 = do_loop.xidsqn
15 and sid != do_loop.session_id)
16 LOOP
17 dbms_output.put_line('Sessions being blocked : '||next_loop.sid);
18 end loop;
19 end loop;
20 END;
21 /
Blocking Session : 139
Object (Owner/Name): SCOTT.EMP
Object Type : TABLE
Sessions being blocked : 134
PL/SQL procedure successfully completed.HTH
Girish Sharma -
How can I lock a table so that a person can only enter data, not manipulate the table?
I don't want to Lock the table as Numbers does it so perhaps locking is the wrong term. What I want to do is to lock the formatting of the table so it is possible to enter data but not possible to change the position, number of columns etc. I've been searching and all I can come up with is the regular lock function. But I still want to be able to use the cells. Just not change formatting.
Thanks, Bradyou cannot. When you lock a table the whole table is locked. I would consider segmenting the user input into a seprate, un-locked table and placing the calculations in a locked table
-
How to find out who is locking my database account ?
Hi,
Which dynamic view can help me to find out who is locking my database account ?
ThanksYoav wrote:
Hi,
Which dynamic view can help me to find out who is locking my database account ?
Thanksdoes account have PROFILE?
if so, repeated failed logons can result in locked account.
enable AUDIT to see from where logins originate. -
Help on locking MySQL tables (many can read, but only one can write) Java
Hi there,
I have a question regarding locking of tables so that only one person can write to the file, but many are able to read the files (or tables entities).
I am not sure if I need to lock the tables in my Java code or do I lock the tables within the MySQL syntax. I'm just a little confused on the matter.
This java code is a working prototype of inserting a customer data into the database and that works fine. I just don't know how to implement it so that only one person can update the table at a time.
Here is the Customer.java code that I have written.
Help would be greatly appreciated, thanks so much.
package business;
//~--- non-JDK imports --------------------------------------------------------
import shared.info.CustomerInfo;
//~--- JDK imports ------------------------------------------------------------
import java.sql.*;
* @author
public class Customer {
static Connection con = DBConnection.getConnection();
private CustomerInfo info = new CustomerInfo();
private String customerID;
private String firstName;
private String lastName;
private String email;
private String addressID;
private String homePhone;
private String workPhone;
private String unitNum;
private String streetNum;
private String streetName;
private String city;
private String provinceState;
private String country;
private String zipPostalCode;
public Customer(String id) {
try {
PreparedStatement pstmt = con.prepareStatement("SELECT * FROM " +
"Customer NATURAL JOIN Address WHERE CustomerID = ?");
pstmt.setString(1, id);
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
customerID = rs.getString("CustomerID");
firstName = rs.getString("FirstName");
lastName = rs.getString("LastName");
homePhone = rs.getString("HomePhone");
workPhone = rs.getString("WorkPhone");
email = rs.getString("Email");
city = rs.getString("City");
provinceState = rs.getString("ProvinceState");
country = rs.getString("Country");
zipPostalCode = rs.getString("ZipPostalCode");
unitNum = rs.getString("UnitNum");
streetNum = rs.getString("StreetNum");
streetName = rs.getString("StreetName");
addressID = rs.getString("AddressId");
} catch (SQLException e) {
e.printStackTrace();
info.setCustomerID(customerID);
info.setFirstName(firstName);
info.setLastName(lastName);
info.setHomePhone(homePhone);
info.setWorkPhone(workPhone);
info.setEmail(email);
info.setCity(city);
info.setProvinceState(provinceState);
info.setCountry(country);
info.setZipPostalCode(zipPostalCode);
info.setUnitNum(unitNum);
info.setStreetNum(streetNum);
info.setStreetName(streetName);
info.setAddressID(addressID);
public static void addCustomer(CustomerInfo cust) {
try {
int id = -1;
PreparedStatement pstmt = con.prepareStatement("INSERT INTO Address" +
"(UnitNum, StreetNum, StreetName, City, ProvinceState, Country," +
" ZipPostalCode) VALUES(?, ?, ?, ?, ?, ?, ?)");
pstmt.setString(1, cust.getUnitNum());
pstmt.setString(2, cust.getStreetNum());
pstmt.setString(3, cust.getStreetName());
pstmt.setString(4, cust.getCity());
pstmt.setString(5, cust.getProvinceState());
pstmt.setString(6, cust.getCountry());
pstmt.setString(7, cust.getZipPostalCode());
pstmt.executeUpdate();
ResultSet rs = pstmt.getGeneratedKeys();
rs.next();
id = rs.getInt(1);
pstmt = con.prepareStatement("INSERT INTO Customer" +
"(FirstName, LastName, HomePhone, WorkPhone, Email, AddressID)"
+ "VALUES(?, ?, ?, ?, ?, ?)");
pstmt.setString(1, cust.getFirstName());
pstmt.setString(2, cust.getLastName());
pstmt.setString(3, cust.getHomePhone());
pstmt.setString(4, cust.getWorkPhone());
pstmt.setString(5, cust.getEmail());
pstmt.setInt(6, id);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
public void setFirstName(String newName) {
try {
PreparedStatement pstmt = con.prepareStatement("UPDATE Customer"
+ " SET FirstName = ? WHERE CustomerID = ?");
pstmt.setString(1, newName);
pstmt.setString(2, customerID);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
firstName = newName;
public void setLastName(String newName) {
try {
PreparedStatement pstmt = con.prepareStatement("UPDATE Customer"
+ " SET LastName = ? WHERE CustomerID = ?");
pstmt.setString(1, newName);
pstmt.setString(2, customerID);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
lastName = newName;
public String getFirstName() {
return firstName;
public String getLastName() {
return lastName;
public void setHomePhone(String number) {
try {
PreparedStatement pstmt = con.prepareStatement("UPDATE Customer"
+ " SET HomePhone = ? WHERE CustomerID = ?");
pstmt.setString(1, number);
pstmt.setString(2, customerID);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
homePhone = number;
public String getHomePhone() {
return homePhone;
public void setWorkPhone(String number) {
try {
PreparedStatement pstmt = con.prepareStatement("UPDATE Customer"
+ " SET WorkPhone = ? WHERE CustomerID = ?");
pstmt.setString(1, number);
pstmt.setString(2, customerID);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
workPhone = number;
public String getWorkPhone() {
return workPhone;
public void setEmail(String email) {
try {
PreparedStatement pstmt = con.prepareStatement("UPDATE Customer" + " SET Email = ? WHERE CustomerID = ?");
pstmt.setString(1, email);
pstmt.setString(2, customerID);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
this.email = email;
public String getEmail() {
return email;
public void setUnitNum(String num) {
try {
PreparedStatement pstmt = con.prepareStatement("UPDATE Address" + " SET UnitNum = ? WHERE AddressId = ?");
pstmt.setString(1, num);
pstmt.setString(2, addressID);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
unitNum = num;
public String getUnitNum() {
return unitNum;
public void setCity(String city) {
try {
PreparedStatement pstmt = con.prepareStatement("UPDATE Address" + " SET City = ? WHERE AddressId = ?");
pstmt.setString(1, city);
pstmt.setString(2, addressID);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
this.city = city;
public String getCity() {
return city;
public void setStreetNum(String num) {
try {
PreparedStatement pstmt = con.prepareStatement("UPDATE Address" + " SET StreetNum = ? WHERE AddressId = ?");
pstmt.setString(1, num);
pstmt.setString(2, addressID);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
streetNum = num;
public String getStreetNum() {
return streetNum;
public void setStreetName(String name) {
try {
PreparedStatement pstmt = con.prepareStatement("UPDATE Address"
+ " SET StreetName = ? WHERE AddressId = ?");
pstmt.setString(1, name);
pstmt.setString(2, addressID);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
streetName = name;
public String getStreetName() {
return streetName;
public void setZipPostalCode(String code) {
try {
PreparedStatement pstmt = con.prepareStatement("UPDATE Address"
+ " SET ZipPostalCode = ? WHERE AddressId = ?");
pstmt.setString(1, code);
pstmt.setString(2, addressID);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
zipPostalCode = code;
public String getZipPostalCode() {
return zipPostalCode;
public CustomerInfo getInfo(){
return info;
static void deleteCustomer(String customerId) {
try{
PreparedStatement pstmt = con.prepareStatement("DELETE FROM Customer" +
" WHERE CustomerId = ?");
pstmt.setString(1, customerId);
pstmt.executeUpdate();
}catch(SQLException e){
e.printStackTrace();
static void updateCustomer(CustomerInfo custInf) {
try{
PreparedStatement pstmt = con.prepareStatement("UPDATE customer" +
" SET firstName = ?, SET lastName = ?," +
" SET homePhone = ?, SET workPhone = ?, SET email = ?" +
" WHERE CustomerId = ?");
pstmt.setString(1, custInf.getFirstName());
pstmt.setString(2, custInf.getLastName());
pstmt.setString(3, custInf.getHomePhone());
pstmt.setString(4, custInf.getWorkPhone());
pstmt.setString(5, custInf.getEmail());
pstmt.setString(6, custInf.getCustomerID());
pstmt.executeUpdate();
pstmt = con.prepareStatement("UPDATE address" +
" SET unitNum = ?, SET StreetNum = ?, SET StreetName = ?," +
" SET city = ?,SET Province = ?,SET country = ?,SET ZipPostalCode = ?" +
" WHERE AddressId = ?");
pstmt.setString(1, custInf.getUnitNum());
pstmt.setString(2, custInf.getStreetNum());
pstmt.setString(3, custInf.getStreetName());
pstmt.setString(4, custInf.getCity());
pstmt.setString(5, custInf.getProvinceState());
pstmt.setString(6, custInf.getCountry());
pstmt.setString(7, custInf.getZipPostalCode());
pstmt.setString(8, custInf.getAddressID());
pstmt.executeUpdate();
}catch(SQLException e){
e.printStackTrace();
}In addition, here is my customer sql table.
-- Table structure for table `customer`
DROP TABLE IF EXISTS `customer`;
CREATE TABLE `customer` (
`CustomerID` mediumint(9) NOT NULL auto_increment,
`FirstName` varchar(20) NOT NULL,
`LastName` varchar(20) NOT NULL,
`HomePhone` varchar(11) NOT NULL,
`WorkPhone` varchar(11) default NULL,
`Email` varchar(20) NOT NULL,
`AddressID` mediumint(9) default NULL,
PRIMARY KEY (`CustomerID`),
KEY `AddressID` (`AddressID`),
CONSTRAINT `customer_ibfk_1` FOREIGN KEY (`AddressID`) REFERENCES `address` (`AddressID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Dumping data for table `customer`
LOCK TABLES `customer` WRITE;
/*!40000 ALTER TABLE `customer` DISABLE KEYS */;
/*!40000 ALTER TABLE `customer` ENABLE KEYS */;
UNLOCK TABLES;to the best of my knowledge, this is something related to the database and not the programming. If you'd want to be the only user to read and edit the table, speicify only one user with that privilege and make it password protected. User must enter the password to write to the tables.
-
Killing all sessions at once who are locking the objects
Hello all,
i am working in 9i Oracle RDBMS on AIX IBM OS
most of the time we face locking issue and there comes more then different 50 sessions which locking different tables.
here is my script to find out what sessions are locking what tables.
set lines 200
set pages 50000
col SID for 99999
col SERIAL# for 999999
col username format a12
col sql format a55
col event format a50
col program format a40
col MINS for 9999
col ID1 for 999999
col object_name for a35
col locktype for a8;
select /*+ ORDERED */ s.sid,s.serial#,s.status,round(s.last_call_et/60) MINS,s.program,l.ID1,d.object_name,d.object_type,l.type as locktype
from v$lock l,v$session s, dba_objects d
where l.sid = s.sid
and l.ID1 = d.object_id
and s.username = 'MULDMS'
and last_call_et > 120 and l.type <> 'TX' order by s.status,MINS,l.ID1,l.type; and the out put it gives something like
SID SERIAL# STATUS MINS PROGRAM ID1 OBJECT_NAME OBJECT_TYPE LOCKTY
8981 1069 ACTIVE 2 frmweb@Appsdms31 (TNS V1-V3) 30407 VH_BTN TABLE TM
1642 512 ACTIVE 15 [email protected] (TNS V1-V3) 30407 VH_BTN TABLE TM
690 1057 ACTIVE 17 [email protected] (TNS V1-V3) 28846 AM_DOCS TABLE TM
699 1787 ACTIVE 17 [email protected] (TNS V1-V3) 30407 VH_BTN TABLE TM
690 1057 ACTIVE 17 [email protected] (TNS V1-V3) 30407 VH_BTN TABLE TM
690 1057 ACTIVE 17 [email protected] (TNS V1-V3) 30643 VT_CHECK_INOUT TABLE TM
10877 895 ACTIVE 18 [email protected] (TNS V1-V3) 28846 AM_DOCS TABLE TM
6654 1085 ACTIVE 18 [email protected] (TNS V1-V3) 28846 AM_DOCS TABLE TM
1912 1655 ACTIVE 18 [email protected] (TNS V1-V3) 28846 AM_DOCS TABLE TM
10877 895 ACTIVE 18 [email protected] (TNS V1-V3) 30407 VH_BTN TABLE TM
6654 1085 ACTIVE 18 [email protected] (TNS V1-V3) 30407 VH_BTN TABLE TM
1912 1655 ACTIVE 18 [email protected] (TNS V1-V3) 30407 VH_BTN TABLE TM
1754 1582 ACTIVE 18 [email protected] (TNS V1-V3) 30407 VH_BTN TABLE TM
10877 895 ACTIVE 18 [email protected] (TNS V1-V3) 30643 VT_CHECK_INOUT TABLE TM
6654 1085 ACTIVE 18 [email protected] (TNS V1-V3) 30643 VT_CHECK_INOUT TABLE TM
10708 982 ACTIVE 19 [email protected] (TNS V1-V3) 28846 AM_DOCS TABLE TM
5428 855 ACTIVE 19 [email protected] (TNS V1-V3) 28846 AM_DOCS TABLE TM
10708 982 ACTIVE 19 [email protected] (TNS V1-V3) 30407 VH_BTN TABLE TM
5428 855 ACTIVE 19 [email protected] (TNS V1-V3) 30407 VH_BTN TABLE TM
10278 897 ACTIVE 20 [email protected] (TNS V1-V3) 28846 AM_DOCS TABLE TM
6261 1056 ACTIVE 20 frmweb@appsdms12 (TNS V1-V3) 28846 AM_DOCS TABLE TM
6598 1413 ACTIVE 20 [email protected] (TNS V1-V3) 28846 AM_DOCS TABLE TM
1312 1000 ACTIVE 20 [email protected] (TNS V1-V3) 28846 AM_DOCS TABLE TM
10278 897 ACTIVE 20 [email protected] (TNS V1-V3) 30407 VH_BTN TABLE TM
6261 1056 ACTIVE 20 frmweb@appsdms12 (TNS V1-V3) 30407 VH_BTN TABLE TM
1312 1000 ACTIVE 20 [email protected] (TNS V1-V3) 30407 VH_BTN TABLE TM
3521 717 ACTIVE 20 [email protected] (TNS V1-V3) 30407 VH_BTN TABLE TM
6598 1413 ACTIVE 20 [email protected] (TNS V1-V3) 30407 VH_BTN TABLE TM
6598 1413 ACTIVE 20 [email protected] (TNS V1-V3) 30643 VT_CHECK_INOUT TABLE TM
1312 1000 ACTIVE 20 [email protected] (TNS V1-V3) 30643 VT_CHECK_INOUT TABLE TM
9131 1002 INACTIVE 2 [email protected] (TNS V1-V3) 30455 VH_PSF TABLE TM
4887 1040 INACTIVE 2 [email protected] (TNS V1-V3) 30455 VH_PSF TABLE TM
151 1982 INACTIVE 2 [email protected] (TNS V1-V3) 80224 RD_ENQEXD TABLE TM
846 988 INACTIVE 3 [email protected] (TNS V1-V3) 29228 GM_VIN TABLE TM
5364 1149 INACTIVE 3 [email protected] (TNS V1-V3) 30407 VH_BTN TABLE TM
9934 789 INACTIVE 3 [email protected] (TNS V1-V3) 30455 VH_PSF TABLE TM
7511 1092 INACTIVE 3 [email protected] (TNS V1-V3) 30455 VH_PSF TABLE TM
3595 1104 INACTIVE 3 [email protected] (TNS V1-V3) 30455 VH_PSF TABLE TM
846 988 INACTIVE 3 [email protected] (TNS V1-V3) 30455 VH_PSF TABLE TM
945 670 INACTIVE 3 [email protected] (TNS V1-V3) 30455 VH_PSF TABLE TMand then i have to kill the session one by one . thaat is a tedious task to do.
i want to modify this script which will give me all the kill statement and i just have to run it
can someone help me in this regard as i am weak in sql/plsql
thanks and many thanks>
i want to modify this script which will give me all the kill statement and i just have to run it
>
Karthick's script will 'kill' the sessions but before you use that script you may want to read the docs about the KILL and DISCONNECT clauses.
See the DISCONNECT SESSION and KILL SESSION clauses in the SQL Language doc
http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_2013.htm#sthref4724
>
DISCONNECT SESSION Clause
Use the DISCONNECT SESSION clause to disconnect the current session by destroying the dedicated server process (or virtual circuit if the connection was made by way of a Shared Sever).
The IMMEDIATE setting disconnects the session and recovers the entire session state immediately, without waiting for ongoing transactions to complete.
KILL SESSION Clause
The KILL SESSION clause lets you mark a session as terminated, roll back ongoing transactions, release all session locks, and partially recover session resources.
IMMEDIATE Specify IMMEDIATE to instruct Oracle Database to roll back ongoing transactions, release all session locks, recover the entire session state, and return control to you immediately.
>
For DISCONNECT the IMMEDIATE clause will recover the session state 'immediately'.
Using KILL, even with the IMMEDIATE clause, you are telliing Oracle to roll back any ongoing transactions and that can take a lot of time.
Make sure you are really doing the operation you want to do. If you want to get the locks released immediately you need to use 'DISCONNECT IMMEDIATE'. -
Lock Object (Not locking the table)
Hi Guys
I have a custom table ZDRAD same like standard table DRAD with an additional 'DATE' field . ZDRAD's Key fields are same like DRAD . I have created a lock object 'EZDRAD' where I put name = 'ZDRAD' (Custom table) and mode = 'EXCLUSIVE CUMULATIVE' . Now I want to lock the table(Whole table) before modifying/Inserting/deleting the records in se38. Please check the code below and suggest me if I am passing wrong values to the lock object Function module.
Code
TABLES : ZDRAD.
CALL FUNCTION 'ENQUEUE_EZDRAD'
EXPORTING
MODE_ZDRAD = 'E'
MANDT = SY-MANDT
DOKAR = ' '
DOKNR = ' '
DOKVR = ' '
DOKTL = ' '
DOKOB = ' '
OBZAE = 0
OBJKY = ' '
X_DOKAR = ' '
X_DOKNR = ' '
X_DOKVR = ' '
X_DOKTL = ' '
X_DOKOB = ' '
X_OBZAE = ' '
X_OBJKY = ' '
_SCOPE = '2'
_WAIT = 'X'
_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.
IF SY-SUBRC = 0.
ZDRAD table is locked.
P_L_LOCK_STAT = 'X'.
EXIT.
ELSE.
ZDRAD table is not locked
CLEAR P_L_LOCK_STAT .
ENDIF.Hi Kanthimathi
That is numeric field . Please suggest me how can i check the lock. -
An error occurred in lock management when attempting to set a lock on table
Hi All,
I am getting the error 'An error occurred in lock management when attempting to set a lock on table SWWWIHEAD.'
Sometimes the workitem is not created by the Workflow due to above error & this happens rarely but keeps coming.
cany anyone guide or help me how to correct this problem.Is it happening due to my custom code making locks on the above table?
Thanks in advance.
Pls do replyI think you should not use any code to lock the table SWWWIHEAD. Please let us know why you are writing code to put lock on this table.
Thanks
Arghadip -
Is there any function module to lock t024 table
is there lock object for t024 table?otherwise any fm for locking t024 table?
Hi Naren,
<b>Good ... check out the following documentation
Lock objects are used to lock the database table while making the modifications on the database table.
you can create your own lock objects using SE11.
if you create lock objects on any table system will create two function modules.
1.ENQUEUE....
2.DEQUEUE.....
first one is used to lock the table
second one used to removing lock on the table.
lock Table
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
tabname = table_name
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
Unlock Table
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
tabname = table_name
check this link :
http://help.sap.com/saphelp_40b/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
_SCOPE = 1: The lock is not sent to the update program. The lock is removed when the transaction is ended.
_SCOPE = 2: The lock is sent to the update program. The update program is responsible for removing the lock. The dialog program which requested the lock no longer has an influence on the lock behavior. This is the standard setting for the ENQUEUE function module.
_SCOPE = 3: The lock
Re: lock objects
Managingin lock entries
http://help.sap.com/saphelp_nw04/helpdata/en/37/a2e3ae344411d3acb00000e83539c3/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/7b/f9813712f7434be10000009b38f8cf/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/cb/168237d30d974be10000009b38f8cf/frameset.htm</b>
Good Luck and thanks
AK -
How to lock a table in a report program
Hi all,
I have a requirement inwhich if i have selected one radio button the table should locked .
and the i need to check wether the table is locked or not by checking the condition.if locked continue else i need to stop.
can any one help me doing this.Hi,
Hope this information will be useful for you.....
The description of an SAP lock to a table is made via the lock condition and the lock mode.
The lock condition is a logical condition for the lines of the table to be locked. It describes the area of the table which the lock is to protect from competitive access. To avoid the administration of the lock becoming complicated, the lock condition can not be formulated as freely as the WHERE clauses: only fully qualified key fields related by AND may appear in the condition.
Via the lock mode you define which operations on the table are to be protected by the lock. The lock modes available are:
Read lock (shared lock)
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 cumulation)
works like a write lock except that the enhanced write lock also protects from further accesses from the same transaction.
In order to be able to define SAP locks for a table, you must first create a lock object for the table via Development->Dictionary.
If the data for an application object is distributed among several database tables, it is often necessary to be able to lock these tables simultaneously. It is therefore possible to include several tables in a lock object, althought they must be related via appropriate foreign key relationships. The tables involved in a lock object are also known as its base tables.
Thanks
NITESH -
Problem related to locking the table
Hi all,
i am facing a problem while applying locks on the oracle table.my intention is stop the accessing of table to other users, if the table is locked by one user.
for this i wrote the code as follows
Class.forName("oracle.jdbc.driver.OracleDriver"); con = DriverManager.getConnection("jdbc:oracle:thin:@192.168.2.123:1521:xe", "root", "paridb"); con.setAutoCommit(false); System.out.println("Successfully connected to " + "Oracle server using TCP/IP..."); String lock="lock table report@xe in exclusive mode";-------------------------------------->1 query to lock the table Statement stmt1=con.createStatement(); stmt1.executeUpdate(lock); System.out.println("lock is applied"); Statement stmt=con.createStatement(); for(int i=0;i<6;i++) { sql="insert into report values(1921682123,'device','host')"; stmt.executeUpdate(sql); }
after locking i inserted some data into table, after insertion i am not commiting it because if i commit,the lock will be release.next i am trying to insert data into that table from another system,acutually the data don't insert.but data is inserted. how it is happening like that ??
in another scenario, if execute the locking query on the database directly then trying to insert into database through java application, at that time it is not giving permission to access table.
plz guide me
thanks®ards,
nagarajuHi! Thank you so much for your reply. Yes, I´m using ADF. I attach you the iterator´definition from the page definition:
<iterator id="MovimientosCtbView3Iterator" RangeSize="10"
Binds="MovimientosCtbView3" DataControl="AppModuleDataControl"/>
If I set the RangeSize to 11, the problem is solved, but my project manager want to find out why this situation happens with RangeSize=10.
Thank you so much and sorry for bothering you
Maybe you are looking for
-
Having difficulty connecting apple tv with amazon instant video
II'm having difficulty connecting apple tv with amazon instant video or it won't stay connected. Help!
-
Web form not updating database with stored procedure
Hello i have a problem with the web form updating the database i have a stored procedure which i need to connect to. If i execute the procedure in the SQL it will update the database but when i run the web form i get my catch error "could not update
-
How to find called T-code/Program of another T-code/Program
Hi Experts, Transaction 1 calls Transaction 2. I need to know, which transaction called transaction 2, being in transaction 2. How? i.e., Can I find the program which called the current program which is running?? Is there any function module to
-
I deleted and recreated iPhoto library file. Now the events do not appear as folders in the sidebar. How do I get them to list again ?
-
hello I have a JDBC Receiver in PI 7.1 with an INSERT statement. I see that the message is finish successfully in the SXMB MONI but the message was not insert to the table in the DB. I also enter in the JDBC RECEIVER, in order to see the statement, l