Send your questions to appsdbauniverse@gmail.com
Showing posts with label Queries. Show all posts
Showing posts with label Queries. Show all posts

Wednesday, March 2, 2016

How to check locks on a particular table/object


set lines 400
col Object format a40
col Locker format a6
col Type format a9
SELECT
SESSION_ID "SID",
serial#,
c.status,
c.audsid "ora_sess_id",
OWNER||'.'||OBJECT_NAME "Object",
  ORACLE_USERNAME "Locker",
-- mysessf(lockwait) "Wait",
-- lockwait "Wait",
  DECODE(LOCKED_MODE,
    2, 'ROW SHARE',
    3, 'ROW EXCLUSIVE',
    4, 'SHARE',
    5, 'SHARE ROW EXCLUSIVE',
    6, 'EXCLUSIVE',  'UNKNOWN') "Lockmode",
  OBJECT_TYPE "Type",
  c.ROW_WAIT_ROW#,
  c.inst_id
-- PROGRAM "Program"
FROM
  SYS.gV_$LOCKED_OBJECT A,
  SYS.ALL_OBJECTS B,
  SYS.gV_$SESSION c
WHERE
  A.OBJECT_ID = B.OBJECT_ID AND
  C.SID = A.SESSION_ID
  and object_name in ('&object_name')
ORDER BY 1 ASC, 5 Desc
/

Provide table_name or object_name in question to check the locks on it. 

========================================================================

How to check progress of a long running job


For example:
Let say you are trying to rebuild a table ML_SYSTEM_ITEMS_B with move command

alter table INV.ML_SYSTEM_ITEMS_B move;

This session keep on running and you want to check the status.

select target, opname, totalwork, sofar,units, (sofar/totalwork)*100 PERCENTAGE,elapsed_seconds from v$session_longops where target like '%MTL%SYSTEM%' and totalwork <> sofar;

========================================================================

Sunday, February 21, 2016

Query to check Debug profile options


set lines 400 pages 400; 
col profile_option_value format a25 
col user_profile_option_name format a50 
col Level format a14 

select user_profile_option_name, 
decode(level_id,10001,'Site', 
10002,'Application', 
10003,'Responsibility', 
10004,'User', 
10005,'Server', 
10006,'Organization', 
10007, 'ServResp', 
level_id) "Level", 
profile_option_value, 
level_value 
from fnd_profile_option_values, fnd_profile_options_vl 
where upper(user_profile_option_name) like upper('%Debug%') 
AND fnd_profile_option_values.profile_option_id = fnd_profile_options_vl.profile_option_id 
order by 2;

========================================================================

Query to check history of a particular Concurrent Program


col progname for a50
set lines 400 pages 400

SELECT fcp.user_concurrent_program_name progName, fcr.phase_code,fcr.status_code,
TO_CHAR (actual_Start_date, 'DD-MON-YYYY HH24:MI:SS') StartDate,
TO_CHAR (actual_completion_date, 'DD-MON-YYYY HH24:MI:SS') EndDate,
request_id RequestId,
(SYSDATE - actual_start_date) * 24 * 60 * 60 ETime
FROM apps.fnd_concurrent_requests fcr,
apps.fnd_concurrent_programs_tl fcp,
apps.fnd_user fusr,
gv$session sess
WHERE fcp.concurrent_program_id = fcr.concurrent_program_id
AND fcr.program_application_id = fcp.application_id
AND fcp.language = 'US'
AND fcr.requested_by = fusr.user_id
AND fcr.oracle_session_id = sess.audsid(+)
AND fcp.user_concurrent_program_name like '%&program_name%'
ORDER BY 6 DESC;

========================================================================

Query to check SSO related profile options


set lines 400 pages 400
col USER_PROFILE_OPTION_NAME for a60
col PROFILE_OPTION_VALUE for a50
col user_name for a15

select fpot.user_profile_option_name, fpov.profile_option_value,fpov.last_update_date,fu.user_name
from apps.fnd_profile_options fpo, apps.fnd_profile_options_tl fpot, apps.fnd_profile_option_values fpov, apps.fnd_user fu
where fpo.profile_option_id = fpov.profile_option_id
and fpov.level_id=10001
and fpov.last_updated_by=fu.user_id
and fpo.profile_option_name in ('APPS_FRAMEWORK_AGENT','APPS_SSO','APPS_SSO_LDAP_SYNC','APPS_SSO_LOCAL_LOGIN','APPS_SSO_ALLOW_MULTIPLE_ACCOUNTS','APPS_SSO_USER_CREATE_UPDATE','APPS_SSO_LINK_TRUTH_SRC','APPS_SSO_AUTO_LINK_USER','FND_OVERRIDE_SSO_LANG')
and fpo.profile_option_name=fpot.profile_option_name
and fpot.language='US'
order by 1;
========================================================================

Query to check recently updated profile options


SET LINES 400 PAGES 400
col PROFILE_OPTION_NAME for a50
col PROFILE_OPTION_VALUE for a50

select a.PROFILE_OPTION_NAME,b.profile_option_value,to_char(b.last_update_date,'DD-MON-YYYY HH24:MM'),b.LAST_UPDATED_BY,b.level_id 
from apps.fnd_profile_options a, apps.fnd_profile_option_values b 
where a.profile_option_id=b.profile_option_id 
and b.last_update_date > sysdate - 10;

Above query show you profile options updated in last 10 days.

========================================================================

Query to display a list of tablespaces and their usage information


SET LINES 400 PAGES 400
COLUMN used_pct FORMAT A11

SELECT tablespace_name,
size_mb,
free_mb,
max_size_mb,
max_free_mb,
TRUNC((max_free_mb/max_size_mb) * 100) AS free_pct,
RPAD(' '|| RPAD('X',ROUND((max_size_mb-max_free_mb)/max_size_mb*10,0), 'X'),11,'-') AS used_pct
FROM (SELECT a.tablespace_name, b.size_mb, a.free_mb, b.max_size_mb, a.free_mb + (b.max_size_mb - b.size_mb) AS max_free_mb
      FROM (SELECT tablespace_name, TRUNC(SUM(bytes)/1024/1024) AS free_mb 
            FROM dba_free_space
            GROUP BY tablespace_name) a,
            (SELECT tablespace_name, TRUNC(SUM(bytes)/1024/1024) AS size_mb, TRUNC(SUM(GREATEST(bytes,maxbytes))/1024/1024) AS max_size_mb
             FROM dba_data_files
             GROUP BY tablespace_name) b
      WHERE  a.tablespace_name = b.tablespace_name)
ORDER BY tablespace_name;

========================================================================

Query to check concurrency locks in database


set lines 400 pages 400
col wait_class for a50

SELECT blocking_session, sid, serial#, wait_class, seconds_in_wait, inst_id, status 
FROM gv$session
WHERE blocking_session IS NOT NULL
ORDER BY blocking_session;

========================================================================

Query to check session details of a HOST Concurrent request


SELECT a.request_id, d.sid, d.serial#, d.osuser, d.process, b.session_id, c.SPID  
FROM apps.fnd_concurrent_requests a,  
apps.fnd_concurrent_processes b,  
gv$process c,  
gv$session d 
WHERE a.controlling_manager = b.concurrent_process_id  
AND c.pid = b.oracle_process_id  
AND b.session_id=d.audsid  
AND a.request_id = &Request_ID  
AND a.phase_code = 'R';

========================================================================

How to check application object version in Oracle Apps database


set long 10000

select text from dba_source where name = '<object_name>' and type='<object_type>' and rownum < 5;

select dbms_metadata.get_ddl('<object_type>', '<object_name>', '<owner>') from dual;

========================================================================