Thursday, April 24, 2014

Locking Scripts


SELECT l.session_id||','||v.serial# sid_serial,
       l.ORACLE_USERNAME ora_user,
       o.object_name,
       o.object_type,
       l.locked_mode,
       DECODE(l.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(l.locked_mode)
       ) lock_mode,
       o.status,
       to_char(o.last_ddl_time,'dd.mm.yy') last_ddl
FROM dba_objects o, gv$locked_object l, v$session v
WHERE o.object_id = l.object_id
      and l.SESSION_ID=v.sid
order by 2,3;

SELECT SUBSTR(TO_CHAR(session_id),1,5) "SID",
       SUBSTR(lock_type,1,15) "Lock Type",
       SUBSTR(mode_held,1,15) "Mode Held",
       SUBSTR(blocking_others,1,15) "Blocking?"
  FROM dba_locks;


SELECT vh.sid locking_sid,
     vs.status status,
     vs.program program_holding,
     vw.sid waiter_sid,
     vsw.program program_waiting
    FROM v$lock vh,
     v$lock vw,
     v$session vs,
     v$session vsw
    WHERE     (vh.id1, vh.id2) IN (SELECT id1, id2
     FROM v$lock
     WHERE request = 0
     INTERSECT
     SELECT id1, id2
     FROM v$lock
     WHERE lmode = 0)
     AND vh.id1 = vw.id1
     AND vh.id2 = vw.id2
     AND vh.request = 0
     AND vw.lmode = 0
     AND vh.sid = vs.sid
     AND vw.sid = vsw.sid;
  
  
   select s1.username || '@' || s1.machine
    || ' ( SID=' || s1.sid || ' )  is blocking '
    || s2.username || '@' || s2.machine || ' ( SID=' || s2.sid || ' ) ' AS blocking_status
    from v$lock l1, v$session s1, v$lock l2, v$session s2
    where s1.sid=l1.sid and s2.sid=l2.sid
    and l1.BLOCK=1 and l2.request > 0
   and l1.id1 = l2.id1
    and l2.id2 = l2.id2 ;
   
   
    select
  object_name,
  object_type,
  session_id,
  type,         -- Type or system/user lock
  lmode,        -- lock mode in which session holds lock
  request,
  block,
  ctime         -- Time since current mode was granted
from
  v$locked_object, all_objects, v$lock
where
  v$locked_object.object_id = all_objects.object_id AND
  v$lock.id1 = all_objects.object_id AND
  v$lock.sid = v$locked_object.session_id
order by
  session_id, ctime desc, object_name
;

SELECT sid, to_char(start_time,'hh24:mi:ss') stime,
message,( sofar/totalwork)* 100 percent
FROM v$session_longops
WHERE sofar/totalwork < 1;

select s.username,s.sid,s.serial#,s.last_call_et/60 mins_running,q.sql_text from v$session s
join v$sqltext_with_newlines q
on s.sql_address = q.address
 where status='ACTIVE'
and type <>'BACKGROUND'
and last_call_et> 60
order by sid,serial#,q.piece;

select sesion.sid,
       sesion.username,
       optimizer_mode,
       hash_value,
       address,
       cpu_time,
       elapsed_time,
       sql_text
  from v$sqlarea sqlarea, v$session sesion
 where sesion.sql_hash_value = sqlarea.hash_value
   and sesion.sql_address    = sqlarea.address
   and sesion.username is not null ;
  
   select sess_io.sid,
       sess_io.block_gets,
       sess_io.consistent_gets,
       sess_io.physical_reads,
       sess_io.block_changes,
       sess_io.consistent_changes
  from v$sess_io sess_io, v$session sesion
 where sesion.sid = sess_io.sid
   and sesion.username is not null ;

Saturday, December 1, 2012

Launch workflow from PLSQL.



This procedure can be used to launch workflow from PLSQL.

PROCEDURE start_training_wf(p_po_id IN INTEGER) IS
    l_itemtype VARCHAR2(30) := 'XXXXPTR';
    l_itemkey  VARCHAR2(300) := 'TRAINING-' || p_po_id;
    CURSOR c_get IS
      SELECT *
      FROM   po_headers
      WHERE  po_id = p_po_id;
    p_get c_get%ROWTYPE;
  BEGIN
    OPEN c_get;
    FETCH c_get
      INTO p_get;
    CLOSE c_get;

    wf_engine.createprocess(l_itemtype, l_itemkey, 'MAIN_TRAINING_PROCESS');
 
    wf_engine.setitemuserkey(itemtype => l_itemtype
                            ,itemkey  => l_itemkey
                            ,userkey  => 'USERKEY: ' || l_itemkey);
    wf_engine.setitemowner(itemtype => l_itemtype
                          ,itemkey  => l_itemkey
                          ,owner    => 'SYSADMIN');
 
    wf_engine.setitemattrnumber(itemtype => l_itemtype
                               ,itemkey  => l_itemkey
                               ,aname    => 'PO_ID'
                               ,avalue   => p_po_id);

    wf_engine.setitemattrtext(itemtype => l_itemtype
                             ,itemkey  => l_itemkey
                             ,aname    => 'SEND_TO_EMAIL'
                             ,avalue   => p_get.send_email_to);
    wf_engine.setitemattrtext(itemtype => l_itemtype
                             ,itemkey  => l_itemkey
                             ,aname    => 'PO_DESCRIPTION'
                             ,avalue   => p_get.po_description);
    wf_engine.startprocess(l_itemtype, l_itemkey);
 
  END start_training_wf;

Checking Devices on a network

To find all connected devices on a network try arp -a from windows and arp -e in unix.

Tuesday, November 13, 2012

Workflow Language Setting

SELECT
    L.NLS_LANGUAGE ||'_'|| L.NLS_TERRITORY ||'.'||NLS_CODESET NLS_LANG_CODE,
    L.NLS_CODESET NLS_CODESET,
    L.LANGUAGE_CODE CODE,
    LTL.DESCRIPTION DISPLAY_NAME,
    L.NLS_LANGUAGE NLS_LANGUAGE,
    L.NLS_TERRITORY NLS_TERRITORY,
    L.NLS_CODESET NLS_CODESET,
    DECODE(INSTALLED_FLAG, 'B', 'Y', 'I', 'Y', 'N') INSTALLED_FLAG
  FROM
    FND_LANGUAGES L,
    FND_LANGUAGES_TL LTL
  WHERE
    LTL.LANGUAGE_CODE = L.LANGUAGE_CODE
    and DECODE(INSTALLED_FLAG, 'B', 'Y', 'I', 'Y', 'N') = 'Y';
1. Define NLS_LANG Environment Variable on your PC, following below navigation:
For Windows
Start / Settings / Control Panel / System / Advanced / Environment Variables
Define new "System Variable" NLS_LANG and assign it the value from NLS_LANG_CODE in he first step.
Save
NB : the above assumes language AMERICAN is installed in the database. It could be replaced by any other installed language, for instance FRENCH_FRANCE.WE8MSWIN1252 if French has been installed.

2. Re-start the PC as needed.

3. Try again database connection from the Workflow Builder.

OAF bouncing for changes

To bounce the apps to show changes for OAF you will have to do the following:
R12:
1)adapcctl.sh stop
2)adoacorectl.sh stop
3)adoacorectl.sh start
4)adapcctl.sh start

R11
1)adapcctl.sh stop
2)adapcctl.sh start

All these scripts are in $ADMIN_SCRIPTS_HOME
or $COMMON_TOP/admin/scripts

R12 on IE10

Just Starting to useIE10 on Windows 8 and it is throwing up some interesting items for R12.1.3. Looks like compatability views are the only way to get it to work properly.

Without the compatability view everything is undefined. Beware when Microsoft releases IE10 on windows 7. We kow it will not be released for XP so a few people should be OK.

Chrome kind of works where you use an extension to change the user agent for the browser to another one.

Oracle Support Notes 1395050.1 for fusion apps and 285218.1 for eBusiness will show the recommended browsers.