Oracle Apps Tech

Tuesday, April 24, 2012

Kill the locked Sessions

Query1:

select     oracle_username || ' (' || s.osuser || ')' username
,  s.sid || ',' || s.serial# sess_id
,  owner || '.' || object_name object
,  object_type
,  decode( l.block
,       0, 'Not Blocking'
,       1, 'Blocking'
,       2, 'Global') status
,  decode(v.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(lmode)) mode_held
from       v$locked_object v
,  dba_objects d
,  v$lock l
,  v$session s
where      v.object_id = d.object_id
and        v.object_id = l.id1
and        v.session_id = s.sid
order by oracle_username
,  session_id

Query2:

alter system kill session 'sessionId1,sessionId2';
commit;

Read Transaction Document from HR_API_TRANSACTIONS CLOB Data

Useful Queries
-----------------
Query 1:
SELECT extractvalue(VALUE(xx_row), '/ObjectiveEORow/Name') AS objective_name,
       extractvalue(VALUE(xx_row), '/ObjectiveEORow/StartDate') AS objective_start_date,
       decode(extractvalue(VALUE(xx_row),
                           '/ObjectiveEORow/WeightingPercent'),
              '(null)',
              0,
              '',
              0,
              extractvalue(VALUE(xx_row), '/ObjectiveEORow/WeightingPercent')) AS weightingpercent,
       extractvalue(VALUE(xx_row), '/ObjectiveEORow/GroupCode') AS groupcode,
       decode(extractvalue(VALUE(xx_row), '/ObjectiveEORow/ObjectiveId'),
              '(null)',
              0,
              extractvalue(VALUE(xx_row), '/PerAbsenceAttendancesEORow/AbsenceAttendanceId')) AS objectiveid
 
 
  SELECT  extractvalue(VALUE(xx_row), '/CNode/AbsenceAction') AS objective_name
  FROM HR_API_TRANSACTIONS xx_api,
       TABLE(xmlsequence(extract(xmlparse(document transaction_document
                                          wellformed),
                                 '/Transaction/TransCtx/CNode'))) xx_row
 WHERE xx_api.transaction_ref_id = *** Transaction id ********
------------------------------------------------------------------------------------------------
Query2: Leave Absence Cancelation employees

  SELECT selected_person_id, extractvalue(VALUE(xx_row), '/CNode/AbsenceAction') AS objective_name
  FROM HR_API_TRANSACTIONS xx_api,
       TABLE(xmlsequence(extract(xmlparse(document transaction_document
                                          wellformed),
                                 '/Transaction/TransCtx/CNode'))) xx_row
 WHERE extractvalue(VALUE(xx_row), '/CNode/AbsenceAction') = 'CancelMode'
 and TRANSACTION_REF_TABLE like 'PER_ABSENCE_ATTENDANCES'
 and trunc(creation_date) = trunc(sysdate)