How to find the id of a session which holds the lock on record
Hi,
I need to find the session id of a user who holds a lock on the records that i need to update.
for example if a user 'A' is update a emp record where emp = 15 and is holding a lock on it. And now when user 'B' tries to get a lock on the same record either he has to wait indefinitely till 'A' releases the lock or he has to skip that record to get lock.
But how can user 'B' find that 'A' holds the lock on that record ?
Can any one please help me ?
Thanks in Advance
Kalyan
try this:
---session A---------
test > conn hr/hr
Connected.
test > update employees set salary=100 where First_name='Shelley';
1 row updated.
-----session B--------
test > conn hr/hr
Connected.
test > set serveroutput on
test > DECLARE
2 CURSOR sal_cursor IS
3 SELECT *
4 FROM employees
5 WHERE First_name='Shelley'
6 FOR UPDATE OF salary NOWAIT;
7
8 e_emps_locked EXCEPTION;
9 PRAGMA EXCEPTION_INIT
10 (e_emps_locked, -54);
11 BEGIN
12 FOR emp_record IN sal_cursor
13 LOOP
14 UPDATE employees
15 SET salary = emp_record.salary * 1.10
16 WHERE CURRENT OF sal_cursor;
17 END LOOP;
18 EXCEPTION
19 WHEN e_emps_locked then
20 DBMS_OUTPUT.PUT_LINE ('Cannot update employees ' ||
21 'Shelley' || ' was locked by others. ');
22 END;
23 /
Cannot update employees Shelley was locked by others.
PL/SQL procedure successfully completed.
Similar Messages
-
How to find the number of records per months in cube
Hi,
how to find the number of records per months for my all cubes?
Can i use the ListCube transaction to find totl number f records per cube monthwise ?
JimmyHi,
Here is a program to generate no of records and list of ODS and Cubes in Active version.Schedule this program in background and create a cube to load this information and schedule to the data from the file generated by the program. Schedule this all per you requirement.
1.Copy the code into your Z<programname> from Se38.
2.change the FILENAME in CALL FUNCTION 'GUI_DOWNLOAD' in the program to the location from where you can pick the information to load data to cube(eg Application server).
3.Save program.
4.Schedule the program in background as required
5.Create cube with infoobjects to hold no of records and Infoprovider name
6.Load this cube based on event after the program job is done.
Hence you can report on this cube to see no of records in CUBE or ODS in your box.
Please find the code below.
Cheers,
Kavitha Kamesh.
types: begin of itabs ,
tabname type dd02l-tabname,
end of itabs.
data: itab type itabs occurs 0 with header line.
data: counter type i.
data: begin of itab1 occurs 0,
tabname type dd02l-tabname,
counter type i,
end of itab1.
DATA: ITABTABNAME TYPE STRING.
DATA: LENGTH TYPE I.
DATA: OBJECT(30).
data: str(6) type c.
select tabname from dd02l into table itab where ( tabname LIKE '/BIC/F%' or tabname LIKE '/BIC/A%00' )
and TABCLASS = 'TRANSP' and AS4LOCAL = 'A'.
loop at itab.
select count(*) from (itab-tabname) into counter.
str = itab-tabname.
if str = '/BIC/F'.
LENGTH = STRLEN( ITAB-TABNAME ).
SHIFT itab-tabname BY 6 PLACES LEFT.
ELSEIf str = '/BIC/A'.
SHIFT itab-tabname BY 6 PLACES LEFT.
LENGTH = STRLEN( ITAB-TABNAME ).
LENGTH = LENGTH - 2.
endif.
itab1-tabname = itab-tabname(LENGTH).
append itab1.
itab1-counter = counter.
clear itab-tabname.
clear: COUNTER.
endloop.
*********** itab1
loop at itab1.
write:/ itab1-tabname, itab1-counter.
endloop.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
FILENAME = 'c:records.xls'
FILETYPE = 'ASC'
* APPEND = ' '
WRITE_FIELD_SEPARATOR = ','
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = ' '
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* IMPORTING
* FILELENGTH =
TABLES
DATA_TAB = itab1
* FIELDNAMES =
* EXCEPTIONS
* FILE_WRITE_ERROR = 1
* NO_BATCH = 2
* GUI_REFUSE_FILETRANSFER = 3
* INVALID_TYPE = 4
* NO_AUTHORITY = 5
* UNKNOWN_ERROR = 6
* HEADER_NOT_ALLOWED = 7
* SEPARATOR_NOT_ALLOWED = 8
* FILESIZE_NOT_ALLOWED = 9
* HEADER_TOO_LONG = 10
* DP_ERROR_CREATE = 11
* DP_ERROR_SEND = 12
* DP_ERROR_WRITE = 13
* UNKNOWN_DP_ERROR = 14
* ACCESS_DENIED = 15
* DP_OUT_OF_MEMORY = 16
* DISK_FULL = 17
* DP_TIMEOUT = 18
* FILE_NOT_FOUND = 19
* DATAPROVIDER_EXCEPTION = 20
* CONTROL_FLUSH_ERROR = 21
* OTHERS = 22
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. -
How to find the number of records in ods?
how to find the number of records in ods?
Pls suggest the solution apart going to the table of ods and seeing the number of records.
Is there any program or function module to see the number of records in ods?
For eg: SAP_INFOCUBE_DESIGNS is a program which gives the detail (number of records) of infocube.Hi,
I was looking at this and found the following tables that may be of help.
One of these tables will include a summary of the record count of all the tables in your system based on the last time each table had it's database statistics calculated:
DBSTATTADA
DBSTATTDB2
DBSTATTDB4
DBSTATTDB6
DBSTATTINF
DBSTATTMSS
DBSTATTORA
We run on an Oracle database so the table record counts can be taken from DBSTATTORA. Type in AZ in table selection field in SE16 to restrict the output to ODS (or DSO) tables only.
The record count is at the time indicated in the timestamp field. Obviously this is not real time but should not be too out of date - if it is you may be having performance issues and should get your DBA / Basis to run a full refresh of DB stats.
Hope this helps, alhtough not real time the table should give you a decent indication of the size of all your ODS objects (or any other table for that matter!) -
How to find the LOCKED ROWS in a table?
Not locked objects, but for a table the locked rows.
Check below links :
http://www.jlcomp.demon.co.uk/faq/locked_rows.html
How to find the locked row.
who are waiting for same record?
HTH
Girish Sharma -
Urgent!! how to find the recent committed record
how to find the recent commited record
if the records are inserted at the same time?Use ORDER BY(DateColumn)...
I don't have any other idea... -
How to find the recent committed record
how to find the recent commited record
if the records are inserted at the same time?Use ORDER BY(DateColumn)...
I don't have any other idea... -
How to find the lock on a record??
Hi folks!!
Here is the gotcha!!
I am opening two sessions of the same applications with different users.
I am trying to access the same record in a table from both the sessions.
Once I tried to modify the data in one session the other session is getting hanged.
My motive is basically to throw/pop-up one box saying that the record is being modified by some other user.
My problem lies in how to track who (user) is modifying the record.
Plz help me out on this ASAP..
I would be really indebted..
Cheers...........PCZ..and
My problem lies in how to track who (user) is modifying the record.
No that's not possible, because Oracle doesn't keep track of all the individual locks. Oracle doesn't have a lock manager.
There are two thing you can do
1) Examine the table locks, and if there is only one on the table you are working with, you have a chance that the session you find is the one you are looking for. But this is only true when the lock is held for quite some time.
2) When your session is waiting for a lock, there will be a record in v$lock. Use a third session to examine which session is holding the lock.
I hope do you solve -
How to find the locked transaction?
Hi All,
Problem:
We are trying to VOID a cheque which was already accounted for some reason. We are unable to do that. The VOID option is there, but when we go to that option and give Check date and GL Date, system says it will void. On clicking OK in this screen, another message comes saying VOIDED..Requery to see changes... But when we requery we are unable to see the voided check. Still the check status is Negotiable.
Solution:
Usually happens when there is a database lock on that partucular check.
Some payment bacth of adjustment session had selected this particluar check but has not released it .
Pls ask ur dba to have it checked and if it is indeed locked , either try to release it or kill that session.
Now my query is how can I find out the locks via V$LOCK table.
Thanks
ShivankHi All,
I have found out the result of same.
We can find out the BLOCKING transactions from
SQL> select * from dba_locks where BLOCKING_OTHERS='BLOCKING';
Once you find out the blocking transactions you can check it with V$SESSION for the SID and SERIAL# i.e.
SQL> select * from V$SESSION where SID in (<SESSION_ID>);
Now you can release the locks by
SQL>ALTER SYSTEM KILL SESSION 'SID,SERIAL#';
Thanks
Shivank
Message was edited by:
anchorage.india -
How to find the First Modified record
Hi,
I have one table with the fields ID, branch and modified_date.
here nothing is unique. How can I modify a record with new
branch name of a perticular id(will have multiple) where
modified date is oldest.
here date is time stamp.
Though I created with date and time it is showing only date not
time when I query.
Ex:
1, Eng, 10-10-1999 10:10:10('mm-dd-yyyy hh:mi:ss')
1, Mat, 10-10-1999 10:10:09
is there any way to get this (1, Mat, 10-10-1999 10:10:09)
record.
Thanks in advance,
Srini.There are a few ways to do this ...
i) Start by writing code to identify the lowest modified_date
for each ID ...
select ID, min(modified_date)
from my_table group by ID
Then, since the result of a query is logically the same as a
table, you could do either ...
select * from my_table where (ID, modified_date) in
select ID, min(modified_date)
from my_table group by ID
... or ...
select t1.ID, t1.branch, t1.modified_date
from my_table t1,
select ID, min(modified_date) min_modified_date
from my_table group by ID
) t2
where t1.ID = t2.ID and t1.modified_date =
t2.min_modified_date
ii) You could create the requirement that no lower
modified_date should exist for a particular ID ...
select t1.ID, t1.branch, t1.modified_date
from my_table t1
where not exists (
select 0 from my_table t2 where t2.ID = t1.ID and
t2.modified_date < t1.modified_date)
iii) if you can guarantee the existence of an index defined on
the ID and modified_date columns (called my_index in this
example) you could do ...
select t1.ID, t1.branch, t1.modified_date
from my_table t1
where t1.modified_date = (
select /*+ index_asc (my_table my_index) */
t2.modified_date from my_table t2 where t2.ID = t1.ID and
rownum = 1)
You should test each of these options with your own data
set and see which works best for you. Some of them will
return the first matching rows of data very quickly but take
longer to return all of them, while others take a long time to
return the first rows but find the full set faster.
Make sure you run ANALYZE on your table whatever you do. -
How to find the Locked User Account in OBIEE Admin Console
We have recently implemented OBIEE and we are in Learning mode. An user complained that his user account is locked, since he tried to login several times with wrong password. Apparently we unlocked his account successfully. Is there any way to find which user accounts are locked? This may be really helpful for
Thanks in advance.Looks like using wlst code can get the list
Check this
http://weblogic-wonders.com/weblogic/2010/11/12/userlockout-feature-of-weblogic-server/
If you customize above code with the below, can get the list of locked users on console
ul= connection.invoke(ulr, "isLockedOut", new Object[] { username },new String[] { "java.lang.String" }).toString();
System.out.println("Rezultat isUserLocked " + ul);
pls mark correct/helpful if helps
Edited by: veeravalli on Oct 18, 2012 11:51 AM -
Finding the lock wait timeout in Oracle 11g
Want to know how to find the lock wait timeout set on Oracle 11g
Hi,
To find number of seconds a distributed transaction waits for a lock:
SELECT *
FROM v$parameter
WHERE NAME = 'distributed_lock_timeout';To find all parameter's related to lock you can use something like this:
SELECT *
FROM v$parameter
WHERE NAME like '%lock%';Thanks,
Shankar -
How to find the invalid form session in oracle Apps
Oracle Apps R12
Hai All
How to find the invalid form session in oracle Apps R12 and How to Kill the that.
Thanks & Regards
Srikkanth.MHi,
Please refer to these docs (for 11i and R12).
How to Kill Inactive Sessions Based on the Information in the Monitor User Form [ID 103516.1]
Script: How To Identify The apps User Using The O/S PID For Forms Users In 11i [ID 185762.1]
Thanks,
Hussein -
How to find the sessions which generated maximum redo amount at instance?
I use below query or Sql*Plus's set autotrace traceonly statistics > redo size statistic to calculate how much redo I generated in my session;
CREATE OR REPLACE VIEW redo_size AS
SELECT value
FROM v$mystat, v$statname
WHERE v$mystat.statistic# = v$statname.statistic#
AND v$statname.name = ‘redo size’;
But how to find the sessions which generated maximum(top 5 for example) redo from the last database startup on 9iR2 or also with new 10gR2 historic views?
We need this information because from the produced archived log files we observe something new producing almost 2 times more redo for a week. I looked at statspack report but couldnt find as I suspected for a massive update or delete.
Best regards,
TongucI tried v$sysstat but I didnt think about v$sesstat Mr.Gasparotto, thank you very much :)
SELECT ss.sid,
sq.sql_text,
se.status,
se.username,
se.osuser,
se.program,
se.machine,
ss.VALUE
FROM v$sesstat ss, v$statname sn, v$session se, v$sqlarea sq
WHERE ss.statistic# = sn.statistic#
AND se.sql_hash_value = sq.hash_value(+)
AND se.sql_address = sq.address(+)
AND ss.sid = se.sid
AND sn.NAME = 'redo size'
ORDER BY ss.VALUE DESC
Best regards. -
How to find the name of the program of session in sm35 ?
I have some session in sm35.
How to find the name of the program of session in sm35 ?
Could you please help me ?In the list of sessions displayed -> double click the session that an error (i.e. Transaction Ended with errors).
Then it will take you to another screen, here you choose the Screens tab.
Check
Re: BDC session's program name
Re: BDC session's program name
Regards,
Santosh
Message was edited by:
Santosh Kumar Patha -
How to find the max session count and process count for a database
Hi All,
How to find the maximum session count and process count reached for a database over a period of 15 days?
DB version:11.2.0.2
OS:AIXThanks for the link.
The output of the below query that is given in the link shows the results for the last 10 or 12 days.. Is there a query which gives a result for the last 30 days?
col metric_unit for a30
set pagesize 100
Select trunc(end_time),max(maxval) as Maximum_Value,metric_unit
from dba_hist_sysmetric_summary
where metric_id in ( 2118,2119) group by trunc(end_time),metric_unit order by 1; -
How to find the number of users connected to database from OS level(Linux)
Hi All,
Could anyone know , how to find the number of users connected to database without connecting with sql*plus
is there any command to find it?
example we have 10 databases in one server, how to find the number of users connected to particular database without connecting to database(v$session)?
oracle version:- 10g,11g
Operating System:- OEL4/OEL5/AIX/Solaris
any help will be appreciated.
Thanks in advance.
Thank you.
Regards,
Rajesh.Excellent.
Tested, works as long as you set the ORACLE_SID first ( to change databases )
ps -ef | grep $ORACLE_SID | grep "LOCAL=NO" | awk '{print $2}' | wc -l
Thanks!
select OSUSER
from V$SESSION
where AUDSID = SYS_CONTEXT('userenv','sessionid')
and rownum=1;Best Regards
mseberg
Maybe you are looking for
-
Export - Import data , important
Hi, Our systems: BPC 75 SP04, MS version (32 bits DEV server, 64 bits PROD server) I need help ASAP, finally I managed to "export data from server DEV - import this data to PROD" but there is an issue of corrupted data in my opinion, since only some
-
Help!!
-
Monitoring Status is Still Gray [Not Performed] When Technical Monitoring Setup DOne
Dear SAP Expert, I have problem when setup technical monitoring SAP system through t-code SOLMAN_SETUP in Solman. Managed system configuration (satellite system) was configured with green indicator for all steps. Technical monitoring (system monitori
-
What is the maximum number of children tabs related to one parent tab?
I have an application with several parent tabs, there are 21 children tabs related to one single parent tab. If I create the number 22 child tab, all the 22 pages related to this parent tab show an error and do not display. The only solution is to mo
-
Sometimes when I fast-forward tracks, the Zen Xtra freezes and the only way to recover it is to press the reset button or to take out the battery and put it back. This happened several times and I was wondering if this is normal or if my player is de