Monday 31 August 2020

Oracle Database Find blocking sessions

 select v.sql_text,v.sql_fulltext,sub.* from v$sql v,

(select sample_time,s.sql_id sql_id, session_state, blocking_session,

owner||'.'||object_name||':'||nvl(subobject_name,'-') obj_name,s.program,s.module,s.machine

from dba_hist_active_sess_history s, dba_objects o

where event = 'enq: TX - row lock contention'

and o.data_object_id = s.current_obj#

order by 1 desc) sub where sub.sql_id=v.sql_id;



select s1.username || '@' || s1.machine

|| ' ( THIS SID=' || s1.sid || ' )  is blocking '

|| s2.username || '@' || s2.machine || ' ( SID=' || s2.sid || ' ) ' AS blocking_status

from gv$lock l1, gv$session s1, gv$lock l2, gv$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 

'alter system kill session ''' || SID || ',' || s.serial# || ',@'||inst_id||''' immdiate;',sid,username,serial#,process,NVL (sql_id, 0),

sql_address,blocking_session,wait_class,event,p1,p2,p3,seconds_in_wait

FROM gv$session s WHERE blocking_session_status = 'VALID'

OR sid IN (SELECT blocking_session

FROM gv$session WHERE blocking_session_status = 'VALID');

Thursday 6 August 2020

Import an Oracle APEX Application export file from a higher version into a lower version

Follow the below process to know how and where to change required details:

  • Create one dummy application in target instance and export it
  • Compare export files from source instance and target instance as shown in below table. It can be seen that the p_version and p_release parameter values are different in both the files
In source instance (18.1)  

begin

wwv_flow_api.import_begin (

 p_version_yyyy_mm_dd=>'2018.04.04'

,p_release=>'18.1.0.00.45'

,p_default_workspace_id=>XXXXXXX

,p_default_application_id=>XXXXXX

,p_default_owner=>'XXX'

);

end;
In target instance (5.1.4)

begin

wwv_flow_api.import_begin (

 p_version_yyyy_mm_dd=>'2016.08.24'

,p_release=>'5.1.4.00.08'

,p_default_workspace_id=>XXXXXXX

,p_default_application_id=>XXXXXXX

,p_default_owner=>'XXXX'

);

end;
  • So, change the parameter values of import_begin procedure in source export file. For e.g., the release and the version parameters in export file
    from ‘18.1.0.00.45’  to ‘5.1.4.00.08‘ and
    from    ‘2018.04.04’    to ‘2016.08.24’ respectively
  • Import edited export file in target instance this time it will allow you to run the script

Number of Visitors