Tuesday, August 22, 2017

Query to find current running SQL for given Concurrent Program

SELECT a.address,
  s.status,
  s.username,
  s.osuser,
  a.sql_text,
  s.SID
FROM v$sql a,
  v$session s
WHERE s.sql_address = a.address
AND s.SID          IN
  (SELECT d.SID
  FROM apps.fnd_concurrent_requests a,
    apps.fnd_concurrent_processes b,
    v$process c,
    v$session d
    --v$sql e
  WHERE a.controlling_manager = b.concurrent_process_id
  AND c.pid                   = b.oracle_process_id
  AND d.paddr                 = c.addr
    --AND d.sql_address = e.address
  AND a.request_id = 10803707 (provide the actual request id)
  and a.PHASE_CODE = 'R'
  )

Query to find Indexed Column names in table

SELECT c.index_name, i.uniqueness, c.column_name
FROM   user_indexes i, user_ind_columns c
WHERE  i.index_name = c.index_name
  AND  i.table_name = UPPER(:P_TABLE_NAME)
ORDER  BY c.index_name, c.column_position;