Friday, November 2, 2018

Trace details for a concurrent request along with the log and output file location details

Trace details for a concurrent request along with the log and output file location details

Script to get Trace details for a concurrent request along with the log file and output file location details
SELECT 'Request id: '
  || request_id,
  'Trace id: '
  || oracle_process_id,
  'Trace Flag: '
  || req.enable_trace,
  'Trace Name: '
  || dest.VALUE
  || '/'
  || LOWER (dbnm.VALUE)
  || '_ora_'
  || oracle_process_id
  || '.trc',
  'Prog. Name: '
  || prog.user_concurrent_program_name,
  'File Name: '
  || execname.execution_file_name
  || execname.subroutine_name,
  'Status : '
  || DECODE (phase_code, 'R', 'Running')
  || '-'
  || DECODE (status_code, 'R', 'Normal'),
  'SID Serial: '
  || ses.sid
  || ','
  || ses.serial#,
  'Module : '
  || ses.module ,
  TO_CHAR(req.actual_start_date,'DD-MON-YYYY HH24:MI:SS')
Request_start_date ,
  TO_CHAR(req.actual_completion_date,'DD-MON-YYYY HH24:MI:SS')
Request_completion_date ,
  req.logfile_name ,
  req.outfile_name ,
  req.argument_text parameters_passed
FROM fnd_concurrent_requests req,
  v$session ses,
  v$process PROC,
  v$parameter dest,
  v$parameter dbnm,
  fnd_concurrent_programs_vl prog,
  fnd_executables execname
WHERE req.request_id           = :p_request_id
AND req.oracle_process_id      = proc.spid(+)
AND proc.addr                  = ses.paddr(+)
AND dest.NAME                  = 'user_dump_dest'
AND dbnm.NAME                  = 'db_name'
AND req.concurrent_program_id  = prog.concurrent_program_id
AND req.program_application_id = prog.application_id
AND prog.application_id        = execname.application_id
AND prog.executable_id         = execname.executable_id
;

Get Version number for Oracle apps, Database, Workflow, XML, OS

Get Version number for Oracle apps, Database, Workflow, XML, OS

— Oracle Database version along with hostname and instance name
SELECT instance_name,
  host_name,
  version,
  status,
  database_status
FROM v$instance;
— Database version along with operating system platform
1
SELECT name, DB_UNIQUE_NAME, platform_name FROM v$database;
— Oracle Apps version
SELECT release_name,
  applications_system_name,
  aru_release_name
FROM FND_PRODUCT_GROUPS;
— Database Version, PLSQL Version, TNS Version
1
SELECT * FROM v$version;
— Oracle workflow version
1
SELECT text ,name FROM wf_resources WHERE name LIKE '%WF_VERSION%';
— Oracle XML Publisher / BI Publisher Version
1
SELECT WF_EVENT_XML.XMLVersion() XML_BI_VERSION FROM dual;

GL Account Balance

GL Account Balance

GL Account Balance:
The below SQL gets the beginning balance and ending balance of the specified GL Account for a giver ledger and period.
SELECT gcc.concatenated_segments Code_combination,
  SUM(NVL(gb.begin_balance_dr,0)-NVL(gb.begin_balance_cr,0)) beginning_bal,
  SUM(NVL(gb.begin_balance_dr,0)-NVL(gb.begin_balance_cr,0) +
            (NVL(gb.period_net_Dr,0) - NVL(gb.period_net_cr,0))) end_bal
FROM gl_balances gb,
  gl_code_combinations_kfv gcc
WHERE gb.code_combination_id = gcc.code_combination_id
AND gcc.CONCATENATED_SEGMENTS= '01-000-1110-0000-000' --Enter GL Account
AND gb.ledger_id             = 1 -- Enter the Ledger
AND gb.Actual_flag           = 'A'
AND gb.period_name           = 'Dec-13' --Enter the Period
AND gb.currency_code         = (SELECT currency_code FROM gl_ledgers
WHERE ledger_id = gb.ledger_id)
GROUP BY gcc.concatenated_segments;

Respond to workflow notification from a DB procedure

Respond to workflow notification from a DB procedure

The  below script can be used to auto approve notifications through database procedure.
Write your business logic with in the below procedure ,register it as a concurrent program and schedule it as needed to run periodically. The same script can also be used in custom forms, custom or third party applications to respond to notifications from backend procedure.
PROCEDURE approve_reject_proc (pAction IN VARCHAR2, --APPROVE/REJECT
pComments IN VARCHAR2, -- User Comments -- Optional
pNotification_id IN NUMBER, -- Notification ID
pStatus OUT VARCHAR2,
pMessage OUT VARCHAR2
)
IS
l_user_name VARCHAR2(250);
BEGIN
BEGIN
SELECT RECIPIENT_ROLE
INTO l_user_name
FROM WF_NOTIFICATIONS
WHERE notification_id = pNotification_id;
EXCEPTION
WHEN OTHERS THEN
l_user_name := NULL;
END;
wf_notification.SETATTRTEXT(pNotification_id,'RESULT',pAction);
wf_notification.Respond(pNotification_id,
pComments,
l_user_name,
pAction);
pStatus := 'S';
pMessage := 'Successfully '||initcap(pAction);
COMMIT;
EXCEPTION
WHEN OTHERS THEN
pStatus := 'E';
pMessage := 'Unexpected error while Approve/Reject the notification: '||SQLERRM;
END approve_reject_proc;

SQL Important Queries

  How to delete rows with no where clause The following example deletes  all rows  from the  Person.Person  the table in the AdventureWork...