Thursday, February 21, 2013

CONC-SM TNS FAIL Call to PingProcess failed for FNDCPGSC


End users begin to see issues running requests, checking the ICM logfile shows the following errors:

CONC-SM TNS FAIL
Call to PingProcess failed for FNDCPGSC
CONC-SM TNS FAIL
Call to StopProcess failed for FNDCPGSC
CONC-SM TNS FAIL
Call to PingProcess failed for FNDOPP
CONC-SM TNS FAIL
Call to StopProcess failed for FNDOPP


Changes

Issue can occur after fresh installs, after patching/maintenance, or after other configuration changes
Cause

To manage non concurrent processing middle tier services, Service Managers calls into control cartridges (shared object libraries) to Start, Stop, Ping, Suspend, Resume, Verify GSM service processes. Following are the two control cartridges supplied with GSM.

1. AQCART (for Java services)
 Examples:
 Service Fulfillment Manager Adapters
 Workflow Notification Mailer
2. CMDCART (for C services)
Examples:
Forms Listener
Metrics Server
Metrics Client
Reports Server
Apache Listener
Each service may have one or more active OS processes. These processes are monitored by the ICM and controlled via the Service Manager acting as the ICM's agent. All communication between Concurrent Processing and the integrated service will take place through the  StartProcess,PingProcess and StopProcess functions.

For example to check the status of generic services, the ICM will call the PingProcess function from the appropriate control cartridge. Following messages are expected when the control cartridge is unable to communicate with generic services.

Call to PingProcess failed for FNDCPGSC
Call to PingProcess failed for FNDOPP

Hence issue can have multiple causes, usually due to instance specific issues during installs,patching/maintenance, or other configuration changes.
Solution

Potential Solutions

Please perform the following steps:

1. Stop all middle tier services including the concurrent managers. Make sure no FNDLIBR, FNDSM, or other dead processes are running.

2. Stop and then restart the database.

3. Connect to SQLPLUS as APPS user and run the following :

EXEC FND_CONC_CLONE.SETUP_CLEAN;
COMMIT;
EXIT;

4.  Reference Note.260887.1 regarding the Steps to Clean Nonexistent Nodes or IP Addresses from FND_NODES.

5.. Run AutoConfig on all tiers, firstly on the DB tier and then the APPS tiers and Web tiers to repopulate the required system tables.

6. Connect to SQLPLUS as APPS user and run the following statement :

select CONCURRENT_QUEUE_NAME
from FND_CONCURRENT_QUEUES
where CONCURRENT_QUEUE_NAME like 'FNDSM%';

If the above SQL does not return any value please do the following:

cd $FND_TOP/patch/115/sql

Connect to SQLPLUS as APPS user and run the following script :

SQL> @afdcm037.sql;

Reference Note 218893.1 How to Create The Service Manager 'FNDSM' on Oracle Applications
to create libraries for FNDSM and create managers for preexisting nodes.

Check again that FNDSM entries now exist:

select CONCURRENT_QUEUE_NAME
from FND_CONCURRENT_QUEUES
where CONCURRENT_QUEUE_NAME like 'FNDSM%';

7. . Run the CMCLEAN.SQL script from the referenced note below (don't forget to
commit). Reference Note.134007.1 CMCLEAN.SQL - Non Destructive Script to Clean Concurrent Manager Tables

8. Start the middle tier services including your concurrent manager.

9. Retest the issue.

If the above potential solutions do not resolve the issue, please seek support assistance to reference limited distribution Note.1312980.1 to generate diagnostics and debugging to further investigate the issue.

Scripts for Apps DBA


Scripts for Apps DBA

Important Queries for Apps DBA

Blocking Sessions
Connect as sysdba and execute below Query to find out blocking sessions

set lines 130
set pages 200
column module format a20
column program format a20
column username format a15

select s.sid,s.serial#,s.status,p.spid,s.module,s.action,s.program
from v$session s,v$process p
where s.sid in (select session_id from dba_locks where blocking_others='Blocking')
and s.paddr=p.addr

Note: Kill only INACTIVE blocking sessions. For Inactive blocking sessions,
Event will be as shown below:
SQL> select EVENT from gv$session_wait where sid=&sid;
Enter value for sid: 19
old   1: select EVENT from gv$session_wait where sid=&sid
new   1: select EVENT from gv$session_wait where sid=19

EVENT
----------------------------------------------------------------
SQL*Net message from client

Locks in Specific Modules
Locks in AP Module
column object_name format a40
SELECT a.object_id, a.session_id, b.object_name
FROM v$locked_object a, dba_objects b
WHERE a.object_id = b.object_id
AND b.owner in ('AP')

Another Query with more details
select s.sid sid_no,s.serial#,p.spid,s.action  action,a.user_name user_name,
to_char(b.start_time,'DD-MON-YYYY HH24:MI') stime
from fnd_user a, fnd_logins b, v$session s, v$process p
  where a.user_id = b.user_id
  and p.addr = s.paddr
  and s.process = b.spid
  and b.end_time is null
  and b.start_time > trunc(sysdate) - 1
  and a.user_name = '&login_id'
  and s.module like 'AP%'


Runaway Forms Sessions
set lines 130
set pages 200
column userinfo heading "ORACLE/OS User" format a25
column terminal heading "Term" format a6
column process heading "Parent|Process ID" format a10
column "sid (audsid)" format a20
column spid heading "Shadow|Process ID" format a10
column event heading "Waiting" format a30

select s.username||' '||s.osuser||' ('||decode(s.terminal,'unknown','?','UNKNOWN','?',s.terminal) ||')' userinfo,
s.sid||','|| s.serial# ||' ('|| s.audsid ||')' "sid (audsid)",   p.spid, w.event , w.p1
from v$session s, v$process p ,v$session_wait w
where p.addr = s.paddr and s.sid = w.sid and s.process = '&form_process_id' ;

Sample Output:
Enter value for form_process_id: 19721
old   5:      and s.process = '&form_process_id'
new 5:      and s.process = '19721'

                                               Shadow                
ORACLE/OS User            sid (audsid)         Process ID                Waiting                                P1
------------------------- -------------------- ----------     ------------------------------ ----------
APPS applmgr ()           22,21485 (615657)    27872                    SQL*Net message from client    1952673792

Concurrent jobs Details

à List of Running Requests

set lines 130
set pages 200
col os form A7 head AppProc
col spid form a6 head SPID
col program form A50 trunc
set pages 38
col time form 99999.99 head Elapsed
col "Req Id" form 99999999
col "Parent" form a8
col "Prg Id" form 9999999
col serial# form 999999 head Serial#
col qname head "Manager" format a10 trunc
col sid format 9999 head SID
col user_name form A12 head User trunc
set recsep off




select
       q.concurrent_queue_name qname
      ,f.user_name
      ,a.request_id "Req Id"
      ,decode(a.parent_request_id,-1,NULL,a.parent_request_id) "Parent"
      ,a.concurrent_program_id "Prg Id"
      ,a.phase_code,a.status_code
--      ,b.os_process_id "OS"
--      ,vs.sid
--      ,vs.serial# "Serial#"
--      ,vp.spid
      ,a.oracle_process_id "spid"
      ,(nvl(a.actual_completion_date,sysdate)-a.actual_start_date)*1440 "Time"
      ,c.concurrent_program_name||' - '||
       c2.user_concurrent_program_name||' '||a.description "Program"
from APPLSYS.fnd_Concurrent_requests a
    ,APPLSYS.fnd_concurrent_processes b
    ,applsys.fnd_concurrent_queues q
    ,APPLSYS.fnd_concurrent_programs_tl c2
    ,APPLSYS.fnd_concurrent_programs c
    ,APPLSYS.fnd_user f
--    ,v$session vs
--    ,v$process vp
where
      a.controlling_manager = b.concurrent_process_id
  and a.concurrent_program_id = c.concurrent_program_id
  and a.program_application_id = c.application_id
  and c2.concurrent_program_id = c.concurrent_program_id
  and c2.application_id = c.application_id
  and a.phase_code in ('I','P','R','T')
  and a.requested_by = f.user_id
  and b.queue_application_id = q.application_id
  and b.concurrent_queue_id = q.concurrent_queue_id
  and c2.language = 'US'
--  and vs.process (+) = b.os_process_id
--  and vs.paddr = vp.addr (+)
order by 9 desc;

à List of pending Jobs waiting for managers:

set lines 130
col USER_CONCURRENT_QUEUE_NAME format a39
SELECT b.USER_CONCURRENT_QUEUE_NAME , count(*)
FROM apps.FND_CONCURRENT_WORKER_REQUESTS a,apps.FND_CONCURRENT_QUEUES_VL b
WHERE (Phase_Code = 'P' ) and a.hold_flag != 'Y'
and a.Requested_Start_Date <= SYSDATE
AND ('' IS NULL OR ('' = 'B' AND PHASE_CODE = 'R' AND
STATUS_CODE IN ('I'))) and a.CONCURRENT_QUEUE_ID!=1003
and a.CONCURRENT_QUEUE_ID=b.CONCURRENT_QUEUE_ID
group by b.USER_CONCURRENT_QUEUE_NAME ,status_code;

col program_description format a60
col user_concurrent_queue_name format a40



SELECT count(b.request_id) count, b.program_description, a.user_concurrent_queue_name
FROM apps.FND_CONCURRENT_QUEUES_VL a, apps.FND_CONCURRENT_WORKER_REQUESTS b
WHERE a.enabled_flag='Y'
AND  a.concurrent_queue_id = b.concurrent_queue_id
AND  (b.Phase_Code = 'P' OR b.Phase_Code = 'R') AND b.hold_flag != 'Y'
AND  b.Requested_Start_Date <= SYSDATE
AND  1=1
-- and a.user_concurrent_queue_name like 'Inventory%'
group by a.user_concurrent_queue_name, b.program_description order by 3,1 asc

à Long Running Requests (over a specified amount of time hard coded as 4 hours)

set lines 130
column start_time format a15
column USER_CONCURRENT_PROGRAM_NAME format a40
select b.REQUEST_ID, a.USER_CONCURRENT_PROGRAM_NAME, b.phase_code,
       (sysdate - b.actual_start_date) * 24 "running",
       to_char(b.request_date, 'mm/dd/yyyy hh24:mi') "request_date",
       to_char(b.actual_start_date, 'mm/dd/yyyy hh24:mi') "start_time"
   from APPS.FND_CONCURRENT_PROGRAMS_VL a,
       APPS.FND_CONCURRENT_REQUESTS b
 where a.CONCURRENT_PROGRAM_ID = b.CONCURRENT_PROGRAM_ID
   and a.APPLICATION_ID = b.PROGRAM_APPLICATION_ID
   and b.STATUS_CODE = 'R'
   and b.PHASE_CODE = 'R'
   and ((sysdate - b.actual_start_date) * 24) > 4
   and a.CONCURRENT_PROGRAM_ID NOT IN(36887,43393,38121,42789,31556);

à Total scheduled requests

set lines 130
select 'Scheduled requests:' schedt, count(*) schedcnt
from fnd_concurrent_requests
WHERE (requested_start_date > sysdate OR
status_code = 'P')
AND phase_code = 'P';

SELECT request_id id,
nvl(meaning, 'UNKNOWN') status,
user_concurrent_program_name pname,
to_char(request_date, 'DD-MON-RR HH24:MI:SS') submitd,
to_char(requested_start_date, 'DD-MON-RR HH24:MI:SS') requestd
FROM fnd_concurrent_requests fcr,
fnd_lookups fl,
fnd_concurrent_programs_vl fcpv
WHERE phase_code = 'P'
AND (fcr.requested_start_date >= sysdate OR
status_code = 'P')
AND LOOKUP_TYPE = 'CP_STATUS_CODE'
AND lookup_code = status_code
AND fcr.concurrent_program_id = fcpv.concurrent_program_id
AND fcr.program_application_id = fcpv.application_id
ORDER BY pname, request_date;

à pending requests Kept (on hold)

set lines 130
select 'Requests on hold:' schedt, count(*) schedcnt
from fnd_concurrent_requests
WHERE hold_flag = 'Y'
AND phase_code = 'P';

SELECT request_id id,
nvl(meaning, 'UNKNOWN') status,
user_concurrent_program_name pname,
to_char(request_date, 'DD-MON-RR HH24:MI:SS') submitd
FROM fnd_concurrent_requests fcr,
fnd_lookups fl,
fnd_concurrent_programs_vl fcpv
WHERE phase_code = 'P'
AND hold_flag = 'Y'
AND fcr.requested_start_date <= sysdate
AND status_code != 'P'
AND LOOKUP_TYPE = 'CP_STATUS_CODE'
AND lookup_code = status_code
AND fcr.concurrent_program_id = fcpv.concurrent_program_id
AND fcr.program_application_id = fcpv.application_id
ORDER BY request_date, request_id;

à List of pending Requests (used for Pending jobs threshold Monitor)

set lines 130
set pages 200
column REQUEST heading 'Request' format 9999999999
column PHASE heading 'Phase' format A8
column STATUS heading 'Status' format A8
column PROGRAM heading 'Program Name' format A40
column SHORT heading 'Short Name' format A15
column REQUESTOR heading 'Requestor' format A15
column START_TIME heading 'Start Time' format A15
column RUN_TIME justify left heading 'Time(m)' format 999999.9
column description format a75
 select  b.REQUEST_ID "Request", a.description,
       to_char(b.request_date, 'mm/dd/yyyy hh:mi:ss') "request_date",
       to_char(b.requested_start_date, 'mm/dd/yyyy hh:mi:ss') "request_start"
  from APPS.FND_CONCURRENT_PROGRAMS_VL a,
       APPS.FND_CONCURRENT_REQUESTS b
 where a.CONCURRENT_PROGRAM_ID = b.CONCURRENT_PROGRAM_ID
   and a.APPLICATION_ID = b.PROGRAM_APPLICATION_ID
   and b.PHASE_CODE = 'P'
   and b.HOLD_FLAG !='Y'
   and b.requested_start_date <= sysdate



à Steps to terminate a Concurrent request from backend

set lines 130
set pages 200

A)
select oracle_process_id ,
decode(status_code,'R','Running','D','Canceled','E','Error','X','Terminated','G',       'Warning','T','Terminating')"Status_code",
 phase_code,to_char(actual_start_date,'DD-MON-YYYY=>hh24:mi:ss') "Login Time"
from apps.fnd_concurrent_requests where request_id='&Enter_conn_req_id'

B)
select s.sid,s.serial#,module,s.status from v$session s,v$process p
where s.paddr=p.addr
and p.spid=&oracle_process_id

C)
update fnd_concurrent_requests
set  phase_code='C',
status_code='X'
where request_id=&Enter_REQUESTID;
commit;

Make sure that database session for the request id is killed using the output from step A and B.

à steps to Cancel pending jobs

update fnd_concurrent_requests
set phase_code='C',status_code='D'
WHERE phase_code = 'P' AND status_code in ('Q','I');
Commit;

à steps to Terminate pending jobs
update fnd_concurrent_requests
set phase_code='C',status_code='X'
WHERE phase_code = 'P' AND status_code in ('Q','I');
Commit;

à Query to find out list of NLS installed in Applications
set lines 130
select LANGUAGE_CODE from fnd_languages where INSTALLED_FLAG='I';
select NLS_LANGUAGE,LANGUAGE_CODE ,INSTALLED_FLAG from fnd_languages
where INSTALLED_FLAG in ('I','B');




à To get the list of installed products and patch level

set lines 130
set pages 400
col application_id      format 99990    heading "ID"
col application_name    format a40      heading "Name"
col application_prefix  format a6       heading "Prefix"
col application_short_name format a10   heading "Short name"
col apps                format a8       heading "Product"
col install_group_num   format 90       heading "Inst Grp"
col installed_flag      format a9       heading "Type"
col language_code       format a4       heading "Code"
col module_short_name   format a8       heading "Module"
col module_version      format a8       heading "Version"
col product_group_id    format 990      heading "ID"
col product_group_name  format a28      heading "Product Group Name"
col product_group_type  format a10      heading "Type"
col product_version     format a8       heading "Version"
col argument1           format a20      heading "Arguments"
col release_name        format a12      heading "Release"
col updated             format a11      heading "Updated"
col patchset            format a20      heading "Patchset Level"
col status              format a14      heading "Appl Status"

prompt --> Product Installation Status, Version Info and Patch Level
select decode(nvl(a.APPLICATION_short_name,'Not Found'), 'SQLAP','AP','SQLGL','GL','OFA','FA',
'Not Found','id '||to_char(fpi.application_id), a.APPLICATION_short_name) apps,
decode(fpi.status,'I','Installed','S','Shared','N','Inactive',fpi.status) status,
fpi.product_version,nvl(fpi.patch_level,'-- Not Available --') Patchset,
to_char(fpi.last_update_date,'dd-Mon-RRRR') "Update Date"
from fnd_oracle_userid o, fnd_application a, fnd_product_installations fpi
where fpi.application_id = a.application_id(+)
  and fpi.oracle_id = o.oracle_id(+)
order by 1,2;

àWorkflow Mailer configuration without login into OAM

set lines 130
set pages 200
col value format a30

select p.parameter_id,p.parameter_name,v.parameter_value value
from apps.fnd_svc_comp_param_vals_v v,
apps.fnd_svc_comp_params_b p,
apps.fnd_svc_components c
where c.component_type = 'WF_MAILER'
and v.component_id = c.component_id
and v.parameter_id = p.parameter_id
and p.parameter_name in
('OUTBOUND_SERVER', 'INBOUND_SERVER',
'ACCOUNT', 'FROM', 'NODENAME', 'REPLYTO','DISCARD' ,'PROCESS','INBOX')
order by p.parameter_name;          



àScript to backup database links

connect to database as sysdba
set lines 130
set pages 200
select  'DB link for '||b.username||chr(10)||'  create  database  link '||c.name||' connect to '||c.userid|| ' identified  by '||c.password||'   using '''||c.host||''';'
from dba_users b ,link$ c
where c.owner#=b.user_id
union
select  'DB link for Public' ||chr(10)|| '  create public  database  link '||c.name||' connect to
'||c.userid|| ' identified  by '||c.password||'   using '''||c.host||''';'
from link$ c
where owner#=1;

Wednesday, February 20, 2013

Concurrent Manager and program related scripts


Concurrent Manager and program related scripts

SQL Script to Troubleshoot a long-running concurrent request

set term on
set feedback on
set echo on
set arraysize 4
set linesize 200
set pages 9999
set underline =;
column username format A15
column sid format 9990 heading SID
column type format A4
column lmode format 990 heading 'HELD'
column request format 990 heading 'REQ'
column id1 format 9999990
column id2 format 9999990
column sql_text format a100
column name format a80
break on id1 skip 1 dup
undefine v_request_id
define v_request_id
undefine v_spid
define v_spid
undefine v_sid
define v_sid
spool vj_concurrent_monitor.lst

Prompt Enter the concurrent_request_id
Accept v_request_id
prompt checking requests
select oracle_process_id from fnd_concurrent_requests where request_id='&v_request_id';

Prompt Enter the operating system oracle process id for this concurrent request
accept v_spid
Prompt Getting the sid
SELECT SID,SERIAL#,LOGON_TIME FROM V$SESSION WHERE PADDR IN
(SELECT ADDR FROM V$PROCESS WHERE SPID='&v_spid');

prompt Enter the session id for this concurrent request
accept v_sid
prompt memory usage for this session
SELECT A.SID,A.USERNAME,B.VALUE,c.name FROM V$SESSION a,V$SESSTAT B,V$STATNAME C WHERE A.SID=B.SID
AND B.STATISTIC#=C.STATISTIC# AND C.NAME like'%memor%' and a.sid='&v_sid';

prompt resource usage for this session
SELECT A.SID,A.USERNAME,B.VALUE,c.name FROM V$SESSION a,V$SESSTAT B,V$STATNAME C WHERE A.SID=B.SID
AND B.STATISTIC#=C.STATISTIC# and a.sid='&v_sid' order by b.value;


prompt this session waited on
select sid,event,wait_time,state from v$session_wait where sid='&v_sid' order by wait_time;


prompt current sql executing by this session
select a.sid,b.sorts,b.executions,b.loads,b.parse_calls,b.disk_reads,
b.buffer_gets,b.rows_processed,C.sql_text from v$session a,v$sqlarea b,V$SQLTEXT C
where a.sql_address=b.address and b.address=c.address and a.sid='&v_sid';


prompt sql which is taking more than 3mb in shared pool
prompt nosql should take morethan 1mb in shared pool.
prompt please ask the developers to tune the following sql statements
select name,
namespace,type,sharable_mem/(1024*1024) sharablemem,loads,executions,locks,pins,kept from v$db_object_cache
where SHARABLE_MEM>3000000;


prompt sort segments using by this session
SELECT s.username,s.sid,s.osuser,s.process,s.machine,u.extents, u.blocks,u.tablespace FROM v$session s, v$sort_usage u
WHERE s.saddr=u.session_addr order by extents;
and s.sid='&v_sid';

prompt current temp segments free in this instance
SELECT tablespace_name, extent_size, total_extents, used_extents, free_extents, max_used_size FROM v$sort_segment;



prompt total system events at this time
select event,total_waits waits, total_timeouts timeouts, time_waited total_time from v$system_event order by total_waits;

prompt latch contention if thery is any
SELECT latch#, name, gets, misses, sleeps FROM v$latch WHERE sleeps>0 ORDER BY sleeps ;


prompt the latch which is sleeping
select name, sleeps,latch# from v$latch_children where sleeps>4 order by sleeps;


spool off
clear columns
clear breaks

How to find out which request is handle by which concurrent queue.
a) First find out short_name of a program and then pass it as parameter to below query.

b) The below query will give you output
 I - Included  - Included in new concurrent queue
 E - excluded from Standard Manager

This way you know now this running program (concurrent request) is handled by new manager and not part of standard manager.

SELECT A.INCLUDE_FLAG, A.QUEUE_APPLICATION_ID, C.USER_CONCURRENT_QUEUE_NAME,
 B.CONCURRENT_PROGRAM_NAME
FROM APPLSYS.FND_CONCURRENT_QUEUE_CONTENT A, APPLSYS.FND_CONCURRENT_PROGRAMS B, APPS.FND_CONCURRENT_QUEUES_VL C
WHERE type_id = b.concurrent_program_id and b.concurrent_program_name = ‘&SHORT_NAME’ and c.concurrent_queue_id = a.concurrent_queue_id


How to find out Summary of Concurrent requests.

SELECT
request_id, SUBSTR(requestor,1,25), SUBSTR(program,1,50), SUBSTR(user_concurrent_program_name,1,100),
TO_CHAR(actual_start_date,’dd/mm/yy :hh24:mi’) start_date,
TO_CHAR(actual_completion_date,’dd/mm/yy :hh24:mi’) completion_date,
FLOOR((ACTUAL_COMPLETION_DATE- ACTUAL_START_DATE)*24) “in Hours”,
(((ACTUAL_COMPLETION_DATE- ACTUAL_START_DATE)*24)-(FLOOR((ACTUAL_COMPLETION_DATE- ACTUAL_START_DATE)*24)))*60 “In_Min”
–requestor, program, user_concurrent_program_name
FROM fnd_conc_req_summary_v
WHERE (ACTUAL_COMPLETION_DATE- ACTUAL_START_DATE)*24*60 >10

How to find database SID from a Concurrent request.

column process heading “FNDLIBR PID”
SELECT a.request_id, d.sid, d.serial# ,d.osuser,d.process , c.SPID
FROM apps.fnd_concurrent_requests a,
apps.fnd_concurrent_processes b,
v$process c,
v$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’;
You need your concurrent request ID as an input.
c.SPID= is the operating system process id
d.sid= is the Oracle process id

Cancel Concurrent requests. We don't need concurrent requests which are scheduled in production to keep running in test. We use the following update to cancel them.
update fnd_concurrent_requests
set phase_code='C',
status_code='D'
where phase_code = 'P'
and concurrent_program_id not in (
select concurrent_program_id
from fnd_concurrent_programs_tl
where user_concurrent_program_name like '%Synchronize%tables%'
or user_concurrent_program_name like '%Workflow%Back%'
or user_concurrent_program_name like '%Sync%responsibility%role%'
or user_concurrent_program_name like '%Workflow%Directory%')
and (status_code = 'I' OR status_code = 'Q');

Use the SQL below to only cancel the running requests connecting as sys
UPDATE applsys.fnd_concurrent_requests
SET phase_code = 'C', status_code = 'X'
WHERE phase_code = 'R' and status_code ='R'
/
commit

Also, please put all Pending Jobs on Hold, using the SQL below connecting as sys

update applsys.fnd_concurrent_requests
set hold_flag='Y' where
phase_code='P' and hold_flag='N'
/
commit
update fnd_concurrent_requests fcr
set phase_code = 'C',
status_code = 'D'
where fcr.PHASE_CODE <> 'C'
and (fcr.program_application_id,fcr.CONCURRENT_PROGRAM_id) in
(select fcp.application_id,fcp.concurrent_program_id from fnd_concurrent_programs fcp,fnd_executables_vl fev
where fcp.executable_application_id=fev.application_id and fcp.executable_id=fev.executable_id
and (upper(fev.user_executable_name) like 'AL%MAIL%'
or upper(fev.user_executable_name) like 'AL%FTP%'
or upper(fev.user_executable_name) like 'AL%EXCEL%'))
/


To change the number of processes for the standard manager
update FND_CONCURRENT_QUEUE_SIZE
set min_processes = 4
where concurrent_queue_id = 0;

how to find params passed to request from backend

select CONCURRENT_PROGRAM_ID,CONCURRENT_PROGRAM_NAME from fnd_concurrent_programs where concurrent_program_name like '';

select REQUEST_ID,CONCURRENT_PROGRAM_ID,substr(ARGUMENT_TEXT,1,60)params,status_code,phase_code from fnd_concurrent_requests where CONCURRENT_PROGRAM_ID=;

To increase the jvm for OPP

"From Note ID 737311.1 we need to do step 3 We are changing this parameter to 2048m as mentioned below in script.
Configure the Output Post Processor's JVM. These steps set the JVM to 2GB, depending upon
your server's size you might find 3 GB (-mx3072m), 4GB (-mx4096m) or even 5GB (-mx5120m) is a better value. This setting prevents the error ""java.lang.OutOfMemoryError: Java heap space""
in the Output Post Processor's log associated to the Subledger Accounting Program.
Login to SQL*Plus as APPS.
SQL>update FND_CP_SERVICES set DEVELOPER_PARAMETERS =
'J:oracle.apps.fnd.cp.gsf.GSMServiceController:-mx2048m'
where SERVICE_ID = (select MANAGER_TYPE from FND_CONCURRENT_QUEUES
where CONCURRENT_QUEUE_NAME = 'FNDCPOPP');
Bounce the concurrent managers.

one more eg:
To determine current heap size:
select DEVELOPER_PARAMETERS
from FND_CP_SERVICES
where SERVICE_ID = (select MANAGER_TYPE from FND_CONCURRENT_QUEUES where CONCURRENT_QUEUE_NAME = 'FNDCPOPP');

To increase heap size to 1024:
update FND_CP_SERVICES
set DEVELOPER_PARAMETERS = 'J:oracle.apps.fnd.cp.gsf.GSMServiceController:-mx1024m'
where SERVICE_ID = (select MANAGER_TYPE from FND_CONCURRENT_QUEUES where CONCURRENT_QUEUE_NAME = 'FNDCPOPP');


Query to find pending concurrent requests

select count(*)
from APPS.FND_ 2 CONCURRENT_PROGRAMS_VL a,
APPS.FND_CONCURRENT_REQUESTS b
where a.CONCURRENT_PROGRAM_ID = b.CONCURRENT_PROGRAM_ID
and a.APPLICATION_ID = b.PROGRAM_APPLICATION_ID
and b.PHASE_CODE = 'P'
and b.requested_start_date <= sysdate

Pending job details
"SELECT c.user_name, request_id, phase_code, status_code, hold_flag,
TO_CHAR(requested_start_date,'DD-MON-YY:HH24:MM:SS') Requested_Start_Date,
user_concurrent_program_name, b.concurrent_program_id
FROM applsys.fnd_concurrent_requests a,
applsys.fnd_concurrent_programs_tl b,
applsys.fnd_user c
WHERE a.phase_code = 'P'
AND a.concurrent_program_id = b.concurrent_program_id
AND b.LANGUAGE = 'US'
AND c.user_id = a.requested_by
ORDER BY user_concurrent_program_name;"


Cancel scheduled concurrent Request “Gather Schema Statistics” sqlplus apps/apps
sql>
update fnd_concurrent_requests
set phase_code='C',status_code='D'
WHERE phase_code = 'P'
AND status_code in ('Q','I') and concurrent_program_id=38121;
Commit;
Exit


Putting all concurrent jobs on hold:
Update applsys.fnd_concurrent_requests set hold_flag='Y' where phase_code in ('R','P','I');

Cancel scheduled concurrent Request “Gather Schema Statistics”
sqlplus apps/apps
sql>
update fnd_concurrent_requests
set phase_code='C',status_code='D'
WHERE phase_code = 'P'
AND status_code in ('Q','I') and concurrent_program_id=38121;
Commit;
Exit

To terminate request from backend
SQL> select REQUEST_ID,ORACLE_ID,ORACLE_PROCESS_ID,ORACLE_SESSION_ID,OS_PROCESS_ID from applsys.FND_CONCURRENT_REQUESTS where REQUEST_ID=577945;

REQUEST_ID ORACLE_ID ORACLE_PROCESS_ID ORACLE_SESSION_ID
---------- ---------- ------------------------------ -----------------
OS_PROCESS_ID
------------------------------------------------------------------------------------------------------------------------------------
577945 900 13348 1242142
13299

SQL> !kill -9 13348
/bin/ksh: kill: 13348: No such process

SQL> update APPLSYS.fnd_Concurrent_requests set PHASE_CODE='C', STATUS_CODE='D' where REQUEST_ID=577945;

1 row updated.

SQL> commit;

Commit complete.

Schedule “Purge Concurrent Request and/or Manager Data”
Cancel existing scheduled request before scheduling new.
# ebappsenv
# sqlplus apps
update fnd_concurrent_requests
set phase_code='C',status_code='D'
WHERE phase_code = 'P'
AND status_code in ('Q','I')
and concurrent_program_id=32263;

Parameter:
Entity : REQUEST
Mode : Age
Mode Value : 15  On non-prod environments as per case# 734780

Schedule:
on specific days : Wednesday and Saturday at 19:00 CET


Run Gather Schema Statistics as a Concurrent request
Cancel any pending jobs for “Gather Schema Statistics”
Sqlplus apps/appspasswd
Sql>
update fnd_concurrent_requests
set phase_code='C',status_code='D'
WHERE phase_code = 'P'
AND status_code in ('Q','I') and concurrent_program_id=38121;

Login to Oracle applications of target instance as sysadmin thru Appjump
Select system administrator Responisibility
Verify whether Concurrent Request “Gather Schema Statistics” is running or not
If not running, schedule the request to run immediately with Parameters : ALL,10


To check status fo running requests:

column REQUEST heading 'Request' format a8
column PHASE heading 'Phase' format A8
column STATUS heading 'Status' format A8
column PROGRAM heading 'Program Name' format A40
column SHORT heading 'Short Name' format A15
column REQUESTOR heading 'Requestor' format A10
column START_TIME heading 'Start Time' format A15
column RUN_TIME justify left heading 'Time(m)' format 999999.9
column OSPID heading 'OSPID' format a5
column OS_PIDa heading 'OSPIDA' format a6
column SID heading 'SID' format 99999
column serial# heading 'Serial#' format 99999

select substr(fcrv.request_id,1,8)REQUEST,
decode(fcrv.phase_code,'P','Pending','R','Running','I','Inactive','Completed')PHASE,
decode(fcrv.status_code,
'A','Waiting',
'B','Resuming',
'C','Normal',
'F','Scheduled',
'G','Warning',
'H','On Hold',
'I','Normal',
'M','No Manager',
'Q','Standby',
'R','Normal',
'S','Suspended',
'T','Terminating',
'U','Disabled',
'W','Paused',
'X','Terminated',
'Z','Waiting',fcrv.status_code)STATUS,
substr(fcrv.program,1,40)PROGRAM,substr(fcrv.PROGRAM_SHORT_NAME,1,15)SHORT,
substr(fcrv.requestor,1,15)REQUESTOR,
-- to_char(fcrv.actual_start_date,'MM/DD/RR HH24:MI')START_TIME,
round(((sysdate - fcrv.actual_start_date)*1440),1)RUN_TIME,
substr(fcr.oracle_process_id,1,7)OSPID,s.sid,s.serial#
from apps.fnd_conc_req_summary_v fcrv,
apps.fnd_concurrent_requests fcr,
v$session s,v$process p
where fcrv.phase_code = 'R'
and fcrv.request_id = fcr.request_id
and s.paddr = p.addr
and fcr.oracle_process_id = p.spid
and fcrv.concurrent_program_id not in ('40112','40113','36887')
--and trunc(fcrv.actual_start_date) like trunc(sysdate)
order by PHASE, STATUS, REQUEST desc;

Take export dump of concurrent tables and import

exp userid=applsys/xxxx file=conc.dmp log=exp.log tables=FND_CONCURRENT_QUEUES,FND_CONCURRENT_QUEUES_TL,
FND_CONCURRENT_QUEUE_SIZE, FND_CONCURRENT_QUEUE_CONTENT

Truncate the fnd concurrent tables

SQL> truncate table fnd_Concurrent_queues;

Table truncated.

SQL> truncate table FND_CONCURRENT_QUEUES_TL;

Table truncated.

SQL> truncate table FND_CONCURRENT_QUEUE_SIZE;

Table truncated.

SQL> truncate table FND_CONCURRENT_QUEUE_CONTENT;

Table truncated.
Import the data back into the fnd tables which was exported as part of step above

imp userid=applsys/apps ignore=y file=conc.dmp full=y log=imp.log


Check whether the GSM is Up and Running in the system --> Profile option or using the Following Query :
select DECODE(b.profile_option_value, 'Y', 'Enabled', 'Disabled') DETAILS
from fnd_profile_options a, fnd_profile_option_values b
where a.APPLICATION_ID = b.APPLICATION_ID
and a.PROFILE_OPTION_ID = b.PROFILE_OPTION_ID
and a.PROFILE_OPTION_NAME = 'CONC_GSM_ENABLED';


Check whether the Service Manager is up and Running by the following Query :
select CONCURRENT_QUEUE_NAME, ENABLED_FLAG, MAX_PROCESSES, RUNNING_PROCESSES
from FND_CONCURRENT_QUEUES
where CONCURRENT_QUEUE_NAME like 'FNDSM%';

The following SQL scripts located under $FND_TOP/sql are useful when diagnosing concurrent manager problems:

afimchk.sql Tells the status of the ICM and PMON method

afcmstat.sql Lists active manager processes

afrqrun.sql Lists all the running, waiting and Terminating requests

afrqwait.sql Lists requests that are constrained and waiting for the ICM to release them.

afrqscm.sql Prints log file name of managers that can run a given request. It can be used to check for possible errors when a request stays in pending status. It requires a request id value.

afcmcreq.sql Prints the log file name of the manager that processed the request

afrqstat.sql Summary of completed concurrent requests grouped by completion status and execution type. It requires number of days prior to today on which to report parameter.

afimlock.sql Lists locks that the ICM is waiting to get

afcmrrq.sql Lists managers that currently are running a request


Reports on requests that having been running for over a specified amount of time (hard coded as 4 hours). Exceptions, in addition to the defaults below, can be added by entering the program ID for the program exceptions under multi-items.

Runs Every 20 minutes

Uses the following query:
select b.REQUEST_ID, a.DESCRIPTION, b.phase_code,
(sysdate - b.actual_start_date) * 24 "running",
to_char(sysdate, 'mm/dd/yyyy hh:mi') "now",
to_char(b.request_date, 'mm/dd/yyyy hh:mi') "request_date",
to_char(b.actual_start_date, 'mm/dd/yyyy hh:mi') "start_time",
b.program_application_id "program_application_id",
b.concurrent_program_id "concurrent_program_id"
from APPS.FND_CONCURRENT_PROGRAMS_VL a,
APPS.FND_CONCURRENT_REQUESTS b
where a.CONCURRENT_PROGRAM_ID = b.CONCURRENT_PROGRAM_ID
and a.APPLICATION_ID = b.PROGRAM_APPLICATION_ID
and b.STATUS_CODE = 'R'
and b.PHASE_CODE = 'R'
and ((sysdate - b.actual_start_date) * 24) > 4
and a.CONCURRENT_PROGRAM_ID NOT IN(36887,43393,38121,42789,31556)

Excludes:
36887 - Workflow Mailer
43393 - ITM Adapter
38121 - Gather Schema Statistics
42789 - OAM Applications Dashboard Collection
31556 - Planning Manager

Monitors pending jobs exceeds the specified threshold. Excessive pending jobs may indicate an issue with the Concurrent Manager. Uses the following query:

select a.concurrent_program_name, b.REQUEST_ID, a.description,
to_char(b.request_date, 'mm/dd/yyyy hh:mi:ss') ""request_date"",
to_char(b.requested_start_date, 'mm/dd/yyyy hh:mi:ss') ""request_start""
from APPS.FND_CONCURRENT_PROGRAMS_VL a,
APPS.FND_CONCURRENT_REQUESTS b
where a.CONCURRENT_PROGRAM_ID = b.CONCURRENT_PROGRAM_ID
and a.APPLICATION_ID = b.PROGRAM_APPLICATION_ID
and b.PHASE_CODE = 'P'
and b.requested_start_date <= sysdate


The error threshold monitor will alert if the number of failed jobs exceeds the user defined threshold in a 30 minute period.

select a.concurrent_program_name, b.REQUEST_ID, a.description,
b.status_code, b.phase_code
from APPS.FND_CONCURRENT_PROGRAMS_VL a,
APPS.FND_CONCURRENT_REQUESTS b
where a.CONCURRENT_PROGRAM_ID = b.CONCURRENT_PROGRAM_ID
and a.APPLICATION_ID = b.PROGRAM_APPLICATION_ID
and b.STATUS_CODE IN ('E')
and b.actual_completion_date > sysdate - 1/48


Find request which are put on hold
SQL> select REQUEST_ID from fnd_concurrent_requests where phase_code ='P' and hold_flag='Y';


To find oracle_process id for a request id to pull trace file from udump:

select oracle_process_id ,
decode(status_code,'R','Running','D','Canceled','E','Error','X','Terminated','G','Warning','T','Terminating')""Status_code"",
phase_code,to_char(actual_start_date,'DD-MON-YYYY=>hh24:mi:ss') ""Login Time""
from apps.fnd_concurrent_requests where request_id='&Enter_conn_req_id'


To find spid of a request to get the trace file
prompt accept request prompt 'Please enter the concurrent request id for the appropriate concurrent program:
prompt

column traceid format a8
column tracename format a80
column user_concurrent_program_name format a40
column execname format a15
column enable_trace format a12
set lines 80
set pages 22
set head off

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
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 ='&request'
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


To check failed jobs submitted by an user
set lines 1000 pages 100
clear columns
col "Submitted By" format a15 word_wrap
select user_name "Submitted By", request_id "Request #",
to_char(cr.request_date,'dd-mon-rr hh24:mi') "Submitted on",
to_char(cr.last_update_date,'dd-mon-rr hh24:mi') "Failed on"
from applsys.fnd_concurrent_requests cr,
applsys.fnd_user u
where u.user_id = cr.requested_by
and user_name like '%BATCH%'
and cr.status_code ='E'
and cr.phase_code ='C'
and cr.request_date > sysdate - 1
order by 1

Statement to put the jobs on hold and release them lateron
To hold the requests (as apps user):
1) Drop table apps.str_dba_conc_req_hold ;
2) Create table apps.str_dba_conc_req_hold as select * from fnd_Concurrent_requests where PHASE_CODE='P' and hold_flag='N';
3) select count(*) from apps.str_dba_conc_req_hold ;
4) update fnd_Concurrent_requests set hold_flag='Y' where PHASE_CODE='P' and hold_flag='N' and request_id in (select request_id from apps.str_dba_conc_req_hold) ;

NOTE: You have to commit if select & update are same number of records. Otherwise rollback and try again till the numbers are same

5) Commit;

To Release these requests in prod after patching, here is the step :

6) a. update fnd_Concurrent_requests set hold_flag='N' where request_id in (select request_id from apps.str_dba_conc_req_hold);
b. commit;


How to take cm program trace.

Responsibility: System Administrator
Navigate: Concurrent > Program > Define
Query Concurrent Program
Select the Enable Trace Checkbox

Responsibility: System Administrator
Navigate: Profiles > System
Query Profile Option Concurrent: Allow Debugging
Set profile to Yes

Logon to the Responsibility that runs the Concurrent Program
In the Submit Request Screen click on Debug Options (B)
Select the Checkbox for SQL Trace


To submit active user request from backend
CONCSUB APPS/APPS SYSADMIN "System Administrator" SYSADMIN CONCURRENT FND FNDSCURS PROGRAM_NAME='"Active Users"'

sql program to submit request from backend
"SET SERVEROUTPUT ON
declare
req_id number;
begin
DBMS_OUTPUT.PUT_LINE('In begin');
fnd_global.APPS_INITIALIZE (0, 21758, 671);
req_id := FND_REQUEST.SUBMIT_REQUEST(application => 'FND',program => 'FNDSCURS',description => '',start_time =>
'',sub_request => FALSE);

if (req_id = 0) then
/* Handle submission error */
DBMS_OUTPUT.PUT_LINE('Request ID :' || req_id);
DBMS_OUTPUT.PUT_LINE('As the request ID is 0, the request was not submitted');
DBMS_OUTPUT.PUT_LINE('Please verify this part again');
else
DBMS_OUTPUT.PUT_LINE('Request ID :' || req_id);
DBMS_OUTPUT.PUT_LINE('Request submitted successfully');
commit;
end if;
end;
/

Meaning of status_code and phase_code in FND_CONCURRENT_REQUESTS table STATUS_CODE Column:

A - Waiting
B - Resuming
C - Normal
D - Cancelled
E - Error
F - Scheduled
G - Warning
H - On Hold
I - Normal
M - No Manager
Q - Standby
R - Normal
S - Suspended
T - Terminating
U - Disabled
W - Paused
X - Terminated
Z - Waiting


PHASE_CODE column

C - Completed
I - Inactive
P - Pending
R - Running

Thursday, February 14, 2013

How to Configure DG4ODBC on 64bit Unix OS (Linux, Solaris, AIX, HP-UX Itanium) to Connect to Non-Oracle Databases Post Install


How to Configure DG4ODBC on 64bit Unix OS (Linux, Solaris, AIX, HP-UX Itanium) to Connect to Non-Oracle Databases Post Install

How to Setup DG4ODBC (Oracle Database Gateway for ODBC) on 64bit Unix platforms
0) The ODBC driver
1) The listener needs a new SID entry like:

2) The tnsnames.ora needs an entry for the DG4ODBC alias:
 
3) init.ora of the gateway:
4) Configuring the Oracle database

Ask Questions, Get Help, And Share Your Experiences With This Article
References
Applies to:

Oracle Server - Enterprise Edition - Version 11.1.0.6 to 11.2.0.1 [Release 11.1 to 11.2]
IBM AIX on POWER Systems (64-bit)
Oracle Solaris on SPARC (64-bit)
HP-UX Itanium
Linux x86-64

***Checked for relevance on 15-MAR-2011***


Goal

Starting with 11g Oracle now provides a Database Gateway for ODBC for the 64bit Unix operating systems on the following platforms: Linux 64bit, AIX 64bit, Solaris 64bit and HP-UX Itanium 64bit.

It can be used to connect to any 3rd party database using a suitable 3rd party ODBC driver.
Please be aware: Installing the 32bit DG4ODBC gateway on a 64bit platform is not supported.

Differences between the older product (Generic Connectivity or sometimes also called HSODBC) and DG4ODBC (Database Gateway for ODBC):
- DG4ODBC is now a stand alone product. It is no longer required to have DG4ODBC running on the
   same machine and within the same ORACLE_HOME as the Oracle database.
- DG4ODBC is now a 64bit application for 64bit platforms and requires a 64bit ODBC driver manager as
  well as a 64bit ODBC driver EXCEPTION: DG4ODBC on HP-UX RSIC 11.1 is still 32bit and needs a 32bit ODBC driver and a 32bit ODBC DRIVER MANAGER - se also DG4ODBC on HP-UX RISC configuration covered in <<466228 .1="">>.
- DG4ODBC requires now a ODBC LEVEL 3 COMPLIANT ODBC driver.

The gateway is certified also for older Oracle releases like 10.2.0.4, 10.2.0.5 and for a small amount of 9.2 and 10.1 databases where the gateway compatibility patch bug <> has been ported to.

You'll find the gateway compatibility patch on "My Oracle Support" by performing a simple search under the 'Patches & Updates' tab at the top of the page. Choose 'Simple Search' and enter 5965763 in the block for the patch number and select the appropriate platform from the Platform or Language list.

If the patch is not available for your platform and/or release you have to update the Oracle database to a newer version.

Fix

How to Setup DG4ODBC (Oracle Database Gateway for ODBC) on 64bit Unix platforms

The Oracle Database Gateway for ODBC for 64bit Unix platforms comes on a separate CD. It can be installed into an existing 11g database Oracle_Home (please pay attention: if the Oracle_Home contains an already patched release of the database, you MUST apply this patchset again. The reason is the gateway installation might overwrite already patched libraries with the base version as delivered on the CD. To get a proper environment again, the already applied patchset needs to be reapplied).

After the installation the following items must be configured:

0) ODBC driver
1) listener (in the ORACLE_HOME where the gateway software is installed)
2) tnsnames (in the ORACLE_HOME where the Oracle database software is installed)
3) init.ora of the hs subsystem (in the ORACLE_HOME where the gateway software is installed)
4) Oracle database

0) The ODBC driver

There are several ODBC vendors for UNIX platforms.

Below is a description using the ODBC driver from Data Direct Technologies. They also provide a 15 day trial license for Linux based platforms. More information is available at the following URL:


The libraries of other ODBC vendors will vary; so please make sure to change the libraries to the libraries of your odbc vendor.

As mentioned, Data Direct Technologies provides a trial version. If you download this trial version, please make sure you download also the service pack for the odbc driver -if it exists-.

Another feature of this driver is that it also contains some mechanism to check the ODBC connectivity.

Install the ODBC driver into a separate home directory. Let's call this home directory ODBC_HOME (i.e. /home/odbc/dd) directory.
To install the driver, you can create a new user called odbc who owns the software.
Install the ODBC driver as mentioned in the documentation.

- Configuring the odbc.ini file:
The odbc.ini file is similar to an address book for the odbc driver. It is located by default in the ODBC_HOME directory, but can be placed anywhere you like.

A side note how odbc works: The odbc driver (nothing else than a library) gets a request to connect to a server described in the odbc.ini file. The alias for the description of the server is called:
Data Source Name (=DSN).
Then the driver reads the information from the odbc.ini file according to the specified DSN and connects to the server.

The prerequisite for the odbc driver to connect to the server is the configured odbc.ini.
It is divided into 3 different sections:

[ODBC Data Sources]
[
[ODBC]

[ODBC Data Source] is the section that contains all the available DSNs.
[] contains the different names of the DSNs and specifies the connect details. 
[ODBC] is the general section for the odbc driver

A very simple file of the odbc.ini file may look like:



[ODBC Data Sources]
mssql=MS SQL Server

[mssql]
Driver=/home/odbc/dd/lib/ivmsss22.so
Description=DataDirect 5.2 SQL Server Wire Protocol
Database= 
LogonID= 
Password= 
Address=, 
QuotedId=YES
AnsiNPW=YES

[ODBC]
IANAAppCodePage=4
InstallDir=/home/odbc/dd
Trace=0
TraceDll=/home/odbc/dd/lib/odbctrac.so
TraceFile=odbctrace.out
UseCursorLib=0
UseCursorLib=0



The section [ODBC Data Sources] contains one datasource called mssql. The configuration behind the data source mssql is found in the section [mssql].
It contains the address (and port) of the database server to contact, the driver library being used and the user id and password of the remote database server.
The [ODBC] section contains general paremeters like tracing (Trace=1 enables tracing, Trace=0 disables it).

After configuring the odbc.ini file, the first step is to check if the ODBC configuration works. Data Direct Technologies provides a demo program to test the connectivity and fetches some data from the remote server.
The directory $ODBC_HOME/demo contains some sql scripts to create a demo table called EMP on the foreign database.
For the Microsoft SQL Server for example the script is called empsqlsrv.sql. Run this script on the SQL Server to create the EMP table. (Please make sure that you don't overwrite/delete any tables you need).

Before calling the program demoodbc, you need to set two environment variables:
a) LD_LIBRARY_PATH/LIBPATH must contain the odbc library path
      AIX:       export LIBPATH=$ODBC_HOME/lib:$LIBPATH
      OTHER: export LD_LIBRARY_PATH=$ODBC_HOME/lib:$LD_LIBRARY_PATH
b) ODBCINI
export ODBCINI=$ODBC_HOME/odbc.ini
The ODBCINI parameter will guarantee the newly configured odbc.ini file from above is used.

Now calling the odbc demo program to query the remote MS SQL Server:
demoodbc -uid -pwd  
like
demoodbc -uid sa -pwd sa mssql
should connect to the server and query the EMP table.

Please make sure you can successfully query the table AND don't proceed if this configuration fails!
If you have problems configuring the odbc driver, please contact the vendor of the driver.

Normally the ODBC driver is installed as a different user then the Oracle user. To test the odbc connectivity for the Oracle user the following should be performed:
Set the ODBCINI and ODBC_HOME environment variable and add the $ODBC_HOME/lib directory to the $LD_LIBRARY_PATH/LIBPATH. (The details how to do it are described in Part I.)

Now execute as the ORACLE User (who starts the listener) the demoodbc program:
$ODBC_HOME/demo/demoodbc -uid sa -pwd sa mssql
A similar output should be generated:
DataDirect Technologies, Inc. ODBC Sample Application.
will connect to data source 'mssql' as user 'sa/sa'.

First Name Last Name Hire Date Salary Dept
---------- --------- --------- ------ ----
Tyler Bennett 1977-01-06 00:00:00.000 32000.0 D101
George Woltman 1982-07-08 00:00:00.000 53500.0 D101
Rich Holcomb 1983-01-06 00:00:00.000 49500.0 D202
Richard Potter 1986-12-04 00:00:00.000 15900.0 D101
David Motsinger 1985-05-05 00:00:00.000 19250.0 D202
Tim Sampair 1987-02-12 00:00:00.000 27000.0 D101
SQLFetch returns: SQL_NO_DATA_FOUND

SIDE NOTE: Please make sure QuotedId is set to yes; else DG4ODBC might fail with error:

hgopoer, line 159: got native error 170 and sqlstate 42000; message follows...
[DataDirect][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near 's
ubq1'.
Exiting hgopoer, rc=0 at 2008/06/19-14:10:17
hgopars, line 347: calling SQLNumResultCols got sqlstate 42000
Exiting hgopars, rc=28500 at 2008/06/19-14:10:17 with error ptr FILE:hgopars.c L
INE:377 FUNCTION:hgopars() ID:Preprocess number of columns

1) The listener needs a new SID entry like:



For AIX:


(SID_NAME=DG4ODBC)
(ORACLE_HOME=/home/oracle/oracle/product/11.1)
(ENV="LIBPATH=//lib:/home/oracle/product/11.1/lib") 
(PROGRAM=dg4odbc)



For all other 64bit Unix systems:

(SID_NAME=DG4ODBC)
(ORACLE_HOME=/home/oracle/oracle/product/11.1)
(ENV="LD_LIBRARY_PATH=//lib:/home/oracle/product/11.1/lib") 
(PROGRAM=dg4odbc)


Please correct the ORACLE_HOME entry and the ENV entry according to your installation.
We strongly recommend to add the LD_LIBARARY_PATH/LIBPATH to the listener.ora file to avoid any conflicts with already existing ODBC driver managers.
The LD_LIBRARY_PATH/LIBPATH must contain the fully qualified path to the $ORACLE_HOME/lib and also the library paths of the ODBC driver manager and the ODBC driver itself.
Please do NOT use $ORACLE_HOME variable in the ENV path.


So a listener.ora file with a listener listening on port 1511 might look like:



SID_LIST_LISTENER =
   (SID_LIST =
      (SID_DESC =
       (SID_NAME=DG4ODBC)
      (ORACLE_HOME=/home/oracle/oracle/product/11.1)
      (ENV="LD_LIBRARY_PATH=/home/odbc/dd/lib:/home/oracle/product/11.1/lib")
      (PROGRAM=DG4ODBC)
      )
   )

LISTENER =
   (DESCRIPTION_LIST =
      (DESCRIPTION =
         (ADDRESS_LIST =
            (ADDRESS = (PROTOCOL = TCP)(HOST = ) (PORT = 1511)) 
         )
      )
   )


The listener must be stopped and started after changing the listener.ora file!


2) The tnsnames.ora needs an entry for the DG4ODBC alias:



DG4ODBC.de.oracle.com =
   (DESCRIPTION=
      (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1511)) 
      (CONNECT_DATA=(SID=DG4ODBC))
      (HS=OK)
   )


The domain of the tns alias can differ from the one used above (de.oracle.com), depending on the parameter in the sqlnet.ora:
NAMES.DEFAULT_DOMAIN = de.oracle.com

The important entry is the (HS=OK) key word. (HS=) is also a valid entry, but DBCA and NetCA will only recognize (HS=OK) entries and remove any (HS=) entries.

After adding the tnsnames alias and restarting the listener, a connectivity check is to use tnsping
tnsping DG4ODBC
It should come back with a success message.


3) init.ora of the gateway:

There are some restrictions on how to name the SID (described in the Net Administrators Guide in detail).  At this place only a short note: don't use dots in the SID and keep it short!

The SID is also relevant for the initialisation file of the gateway. The name of the file is init.ora. In this example it is called initDG4ODBC.ora. 
The file is located at $ORACLE_HOME/hs/admin.
It should contain at least the connect details:



#
# HS init parameters
#
HS_FDS_CONNECT_INFO = mssql
HS_FDS_TRACE_LEVEL = off
HS_FDS_SHAREABLE_NAME = /home/odbc/dd/lib/libodbc.so
#
# ODBC specific environment variables
#
set ODBCINI=/home/odbc/dd/odbc.ini
#
# Environment variables required for the non-Oracle system
#
#set =



Short explanation of the parameters:
HS_FDS_CONNECT_INFO points to the ODBC DSN configured in step "0" of this note.
HS_FDS_SHAREABLE_NAME points to the ODBC Driver Manager library at
$ODBC_HOME/lib/
For the Data Direct Technologies odbc driver the generic odbc library on Linux is called libodbc.so. This library checks the ODBC DSN configuration and loads the driver to the foreign database server. The name of this library may differ from odbc vendor to vendor. Please check out the driver documentation to figure out the generic odbc library. Also some ODBC driver vendors do not require an ODBC Driver Manager; so the ODBC driver library itself can be specified here. To determine if an ODBC Driver Manager is required, please contact the ODBC driver vendor.
(As not each ODBC Driver vendor documents its ODBC Driver Manager library and the library name might differ from Driver Manager to Driver Manager. A possible way to figure out the Driver Manager library name could be to check for the existence of SQLAllocConnect ODBC function within this library:
strings |grep -i sqlalloc 
)

The set ODBCINI=/home/odbc/dd/odbc.ini points to the location of an odbc.ini file you want to use with this hsodbc configuration.

4) Configuring the Oracle database

The only thing that must be done here is to create a database link:
 connect with the username/password that has sufficient rights to create a database link (i.e. system).
 The syntax is:
 create [public] database link  
 connect to identified by using ''; 

 In other words, to connect to the MS SQL Server configured in the last steps, the syntax must be:
 CREATE DATABASE LINK sqlserver
 CONNECT TO "sa" IDENTIFIED BY "sa" USING 'DG4ODBC';

 The db link name is sqlserver. Username and password must be in double quotes, because the username and password are case sensitive in SQL Server. 'DG4ODBC' points to the alias in the tnsnames.ora file that calls the HS subsystem.

 If everything is configured well, a select of a SQL Server table should be successful:

 select * from "systables"@sqlserver;
 ...

 Side note: The systables table name at the MS SQL Server is in small letters. As the MS SQL Server is case sensitive this table name must be surrounded by double quotes. "@sqlserver" points to the name of the database link to the MS SQL Server.
Ask Questions, Get Help, And Share Your Experiences With This Article

Would you like to explore this topic further with other Oracle Customers, Oracle Employees, and Industry Experts?

Click here to join the discussion where you can ask questions, get help from others, and share your experiences with this specific article.
Discover discussions about other articles and helpful subjects by clicking here to access the main My Oracle Support Community page for Database Gateways.



dblink from oracle database to non oracle database


First, I'm sure you are aware that Oracle v9 products have been desupported for a long time. Also, since this thread was opened all the v10 gateways are now desupported and have been replaced by the 11g Database Gateways.
These are certified with Oracle 9i RDBMS as long as it is at 9.2.0.8 and which has had patch 5965763 applied.
The good news is that the 11g Database Gateway for SQL*Server (DG4MSQL) is now available to run standalone on Unix platforms, so you you could install that on the same machine as your RDBMS in a separate ORACLE_HOME and use that to access SQL*Server.
You could also use the 11g Database Gateway for ODBC (DG4ODBC) which needs a third party ODBC driver but can also be used standalone. DG4MSQL needs a license but Dg4ODBC is included in your RDBMS license.
Of course, you can also install either of these standalone on a Windows machine and access from your 9i RDBMS on Unix.
See the following notes on My Oracle Support for details -

Note.466228.1 How to Setup DG4ODBC on Linux x86 32bit
Note.561033.1 How to Setup DG4ODBC on 64bit Unix OS (Linux, Solaris, AIX, HP-UX)
Note.466225.1 How to Setup DG4ODBC (Oracle Database Gateway for ODBC) on Windows 32bit

Note.437374.1 How to Setup DG4MSQL (Oracle Database Gateway for MS SQL Server) Release 11 on Linux
Note.466267.1 How to Setup DG4MSQL (Database Gateway for MS SQL Server) on Windows 32bit
Note.1086365.1 How to Setup DG4MSQL (Database Gateway for MS SQL Server) on a 64bit Windows
Note.562509.1 How to Setup DG4MSQL (Oracle Database Gateway for MS SQL Server) 64bit Unix OS (Linux, Solaris, AIX,HP-UX)

How to Configure DG4ODBC on Linux x86 32bit or on HP-UX RISC (DG4ODBC 11.1 only) to Connect to Non-Oracle Databases post install



How to Configure DG4ODBC on Linux x86 32bit or on HP-UX RISC (DG4ODBC 11.1 only) to Connect to Non-Oracle Databases post install


Fix   How to Setup DG4ODBC (Oracle Database Gateway for ODBC) on LINUX x86 32bit or on HP-UX RISC

Oracle Server - Enterprise Edition - Version 11.1.0.6 to 11.2.0.4 [Release 11.1 to 11.2]
Linux x86
***Checked for relevance on 16-Apr-2010***


Goal

LINUX specific:

Starting with 11g Oracle now provides a Database Gateway for ODBC for 32bit Linux operating systems which can be used to connect to any 3rd party database using a suitable 3rd party ODBC driver.
Please be aware: Installing the 32bit DG4ODBC gateway for Linux on a 64bit platform is not supported.



HP UX RISC specific:

The last distributed version of DG4ODBC on HP-UX RISC is 11.1. This 11.1 gateway release is still a 32bit gateway so the steps how to configure Dg4ODBC on this platform will be included here as well.



General:

The difference between the older product (Generic Connectivity or sometimes also called HSODBC) is DG4ODBC is now a stand alone product. It is no longer required to have DG4ODBC running on the same machine as the Oracle database.

The gateway is certified also for older Oracle releases like 10.2.0.4, 10.2.0.5 and for a small amount of 9.2 and 10.1 databases where the gateway compatibility patch bug <> has been ported to.

You'll find the gateway compatibility patch on "My Oracle Support" by performing a simple search under the 'Patches & Updates' tab at the top of the page. Choose 'Simple Search' and enter 5965763 in the block for the patch number and select the appropriate platform from the Platform or Language list.

If the patch is not available for your platform and/or release you have to update the Oracle database to a newer version.



Fix

How to Setup DG4ODBC (Oracle Database Gateway for ODBC) on LINUX x86 32bit or on HP-UX RISC

The Oracle Database Gateway for ODBC comes on a separate CD. It can be installed into an existing 11g database Oracle_Home (please pay attention: if the Oracle_Home contains an already patched release of the database, you MUST apply this patchset again. The reason is the gateway installation might overwrite already patched libraries with the base version as delivered on the CD. To get a proper environment again, the already applied patchset needs to be reapplied).

After the installation the following items must be configured:

0) ODBC driver
1) listener (in the ORACLE_HOME where the gateway software is installed)
2) tnsnames (in the ORACLE_HOME where the Oracle database software is installed)
3) init.ora of the hs subsystem (in the ORACLE_HOME where the gateway software is installed)
4) Oracle database

0) The ODBC driver

There are several ODBC vendors for UNIX platforms. Below is a description using the ODBC driver from Data Direct Technologies. They also provide a 15 day trial license for Linux based platforms. More information is available at the following URL:


The libraries of other ODBC vendors will vary; so please make sure to change the libraries to the libraries of your odbc vendor.

As mentioned, Data Direct Technologies provides a trial version. If you download this trial version, please make sure you download also the service pack for the odbc driver -if it exists-.

Another feature of this driver is that it also contains some mechanism to check the ODBC connectivity.

Install the ODBC driver into a separate home directory. Let's call this home directory ODBC_HOME (i.e. /home/odbc/dd) directory.
To install the driver, you can create a new user called odbc who owns the software.
Install the ODBC driver as mentioned in the documentation.

- Configuring the odbc.ini file:
The odbc.ini file is similar to an address book for the odbc driver. It is located by default in the ODBC_HOME directory, but can be placed anywhere you like.

A side note how odbc works: The odbc driver (nothing else than a library) gets a request to connect to a server described in the odbc.ini file. The alias for the description of the server is called:
Data Source Name (=DSN).
Then the driver reads the information from the odbc.ini file according to the specified DSN and connects to the server.

The prerequisite for the odbc driver to connect to the server is the configured odbc.ini.
It is divided into 3 different sections:



[ODBC Data Sources]
[
[ODBC]



[ODBC Data Source] is the section that contains all the available DSNs.
[] contains the different names of the DSNs and specifies the connect details. 
[ODBC] is the general section for the odbc driver

A very simple file of the odbc.ini file may look like:



[ODBC Data Sources]
mssql=MS SQL Server

[mssql]
Driver=/home/odbc/dd/lib/ivmsss23.so
Description=DataDirect 5.3 SQL Server Wire Protocol
Database= 
LogonID= 
Password= 
Address=, 
QuotedId=YES
AnsiNPW=YES

[ODBC]
IANAAppCodePage=4
InstallDir=/home/odbc/dd
Trace=0
TraceDll=/home/odbc/dd/lib/odbctrac.so
TraceFile=odbctrace.out
UseCursorLib=0
UseCursorLib=0




The section [ODBC Data Sources] contains one datasource called mssql. The configuration behind the data source mssql is found in the section [mssql].
It contains the address (and port) of the database server to contact, the driver library being used and the user id and password of the remote database server.
The [ODBC] section contains general paremeters like tracing (Trace=1 enables tracing, Trace=0 disables it).

After configuring the odbc.ini file, the first step is to check if the ODBC configuration works. Data Direct Technologies provides a demo program to test the connectivity and fetches some data from the remote server.
The directory $ODBC_HOME/demo contains some sql scripts to create a demo table called EMP on the foreign database.
For the Microsoft SQL Server for example the script is called empsqlsrv.sql. Run this script on the SQL Server to create the EMP table. (Please make sure that you don't overwrite/delete any tables you need).

Before calling the program demoodbc, you need to set two environment variables:
a) LD_LIBRARY_PATH/SHLIB_PATH which must contain the odbc library path
on Linux LD_LIBRARY_PATH is used:export LD_LIBRARY_PATH=$ODBC_HOME/lib:$LD_LIBRARY_PATH
on HP-UX SHLIB_PATH is used for 32bit libs: export SHLIB_PATH=$ODBC_HOME/lib:$SHLIB_PATH
b) ODBCINI
export ODBCINI=$ODBC_HOME/odbc.ini
The ODBCINI parameter will guarantee the newly configured odbc.ini file from above is used.

Now calling the odbc demo program to query the remote MS SQL Server:
demoodbc -uid -pwd  
like
demoodbc -uid sa -pwd sa mssql
should connect to the server and query the EMP table.

Please make sure you can successfully query the table AND don't proceed if this configuration fails!
If you have problems configuring the odbc driver, please contact the vendor of the driver.

Normally the ODBC driver is installed as a different user then the Oracle user. To test the odbc connectivity for the Oracle user the following should be performed:
Set the ODBCINI and ODBC_HOME environment variable and add the $ODBC_HOME/lib directory to the $LD_LIBRARY_PATH. (The details how to do it are described in Part I.)

Now execute as the ORACLE User (who starts the listener) the demoodbc program:
$ODBC_HOME/demo/demoodbc -uid sa -pwd sa mssql
A similar output should be generated:
DataDirect Technologies, Inc. ODBC Sample Application.
will connect to data source 'mssql' as user 'sa/sa'.

First Name Last Name Hire Date Salary Dept
---------- --------- --------- ------ ----
Tyler Bennett 1977-01-06 00:00:00.000 32000.0 D101
George Woltman 1982-07-08 00:00:00.000 53500.0 D101
Rich Holcomb 1983-01-06 00:00:00.000 49500.0 D202
Richard Potter 1986-12-04 00:00:00.000 15900.0 D101
David Motsinger 1985-05-05 00:00:00.000 19250.0 D202
Tim Sampair 1987-02-12 00:00:00.000 27000.0 D101
SQLFetch returns: SQL_NO_DATA_FOUND

SIDE NOTE: Please make sure QuotedId is set to yes; else DG4ODBC might fail with error:

hgopoer, line 159: got native error 170 and sqlstate 42000; message follows...
[DataDirect][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near 's
ubq1'.
Exiting hgopoer, rc=0 at 2008/06/19-14:10:17
hgopars, line 347: calling SQLNumResultCols got sqlstate 42000
Exiting hgopars, rc=28500 at 2008/06/19-14:10:17 with error ptr FILE:hgopars.c L
INE:377 FUNCTION:hgopars() ID:Preprocess number of columns

1) The listener needs a new SID entry like:

      For 32bit Linux:

(SID_NAME=DG4ODBC)
(ORACLE_HOME=/home/oracle/oracle/product/11.1)
(ENV="LD_LIBRARY_PATH=//lib/:/lib:/home/oracle/product/11.1/lib") 
(PROGRAM=dg4odbc)

     For HP-UX RISC Dg4ODBC 11.1:

(SID_NAME=DG4ODBC)
(ORACLE_HOME=/home/oracle/oracle/product/11.1)
(ENV="SHLIB_PATH=//lib/:/lib:/home/oracle/product/11.1/lib32") 
(PROGRAM=dg4odbc)

Please correct the ORACLE_HOME entry and the ENV entry according to your installation.
We strongly recommend to add the LD_LIBARARY_PATH to the listener.ora file to avoid any conflicts with already existing ODBC driver managers.
The LD_LIBRARY_PATH must contain the fully qualified path to the $ORACLE_HOME/lib for Linux and $ORACLE_HOME/lib32 for HP-UX RISC and also the library paths of the ODBC driver manager and the ODBC driver itself.
Please do NOT use $ORACLE_HOME variable in the ENV path.


So a listener.ora file on Linux with a listener listening on port 1511 might look like:

SID_LIST_LISTENER =
   (SID_LIST =
      (SID_DESC =
       (SID_NAME=DG4ODBC)
      (ORACLE_HOME=/home/oracle/oracle/product/11.1)
      (ENV="LD_LIBRARY_PATH=/home/odbc/dd/lib/:/home/oracle/product/11.1/lib")
      (PROGRAM=DG4ODBC)
      )
   )

LISTENER =
   (DESCRIPTION_LIST =
      (DESCRIPTION =
         (ADDRESS_LIST =
            (ADDRESS = (PROTOCOL = TCP)(HOST = ) (PORT = 1511)) 
         )
      )
   )

The listener must be stopped and started after changing the listener.ora file!


2) The tnsnames.ora needs an entry for the DG4ODBC alias:

DG4ODBC.de.oracle.com =
   (DESCRIPTION=
      (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1511)) 
      (CONNECT_DATA=(SID=DG4ODBC))
      (HS=OK)
   )

The domain of the tns alias can differ from the one used above (de.oracle.com), depending on the parameter in the sqlnet.ora:
NAMES.DEFAULT_DOMAIN = de.oracle.com

The important entry is the (HS=OK) key word. (HS=) is also a valid entry, but DBCA and NetCA will only recognize (HS=OK) entries and remove any (HS=) entries.

After adding the tnsnames alias and restarting the listener, a connectivity check is to use tnsping
tnsping DG4ODBC
It should come back with a success message.


3) init.ora of the gateway:

There are some restrictions on how to name the SID (described in the Net Administrators Guide in detail).  At this place only a short note: don't use dots in the SID and keep it short!

The SID is also relevant for the initialisation file of the gateway. The name of the file is init.ora. In this example it is called initDG4ODBC.ora. 
The file is located at $ORACLE_HOME/hs/admin.
It should contain at least the connect details:

#
# HS init parameters
#
HS_FDS_CONNECT_INFO = mssql
HS_FDS_TRACE_LEVEL = off
HS_FDS_SHAREABLE_NAME = /home/odbc/dd/lib/libodbc.so
#
# ODBC specific environment variables
#
set ODBCINI=/home/odbc/dd/odbc.ini
#
# Environment variables required for the non-Oracle system
#
#set =

Short explanation of the parameters:
HS_FDS_CONNECT_INFO points to the ODBC DSN configured in step "0" of this note.
HS_FDS_SHAREABLE_NAME points to the ODBC Driver Manager library at
$ODBC_HOME/lib/
For the Data Direct Technologies odbc driver the generic odbc library on Linux is called libodbc.so. This library checks the ODBC DSN configuration and loads the driver to the foreign database server. The name of this library may differ from odbc vendor to vendor. Please check out the driver documentation to figure out the generic odbc library. Also some ODBC driver vendors do not require an ODBC Driver Manager; so the ODBC driver library itself can be specified here. To determine if an ODBC Driver Manager is required, please contact the ODBC driver vendor.
(As not each ODBC Driver vendor documents its ODBC Driver Manager library and the library name might differ from Driver Manager to Driver Manager. A possible way to figure out the Driver Manager library name could be to check for the existence of SQLAllocConnect ODBC function within this library:
strings |grep -i sqlalloc 
)

The set ODBCINI=/home/odbc/dd/odbc.ini points to the location of an odbc.ini file you want to use with this hsodbc configuration.


4) Configuring the Oracle database

The only thing that must be done here is to create a database link:
connect with the username/password that has sufficient rights to create a database link (i.e. system).
The syntax is:

create [public] database link  
connect to identified by using '';


In other words, to connect to the MS SQL Server configured in the last steps, the syntax must be:

CREATE DATABASE LINK sqlserver
CONNECT TO "sa" IDENTIFIED BY "sa" USING 'DG4ODBC';



The db link name is sqlserver. Username and password must be in double quotes, because the username and password are case sensitive in SQL Server. 'DG4ODBC' points to the alias in the tnsnames.ora file that calls the HS subsystem.

If everything is configured well, a select of a SQL Server table should be successful:

select * from "systables"@sqlserver;
...

Side note: The systables table name at the MS SQL Server is in small letters. As the MS SQL Server is case sensitive this table name must be surrounded by double quotes. "@sqlserver" points to the name of the database link to the MS SQL Server.