Wednesday, July 13, 2016

SQL quries related to TEMP TABLESPACE

To check  total used TEMP 

set lines 152
col FreeSpaceGB format 999.999
col UsedSpaceGB format 999.999
col TotalSpaceGB format 999.999
col host_name format a30
col tablespace_name format a30
select tablespace_name,
(free_blocks*8)/1024/1024 FreeSpaceGB,
(used_blocks*8)/1024/1024 UsedSpaceGB,
(total_blocks*8)/1024/1024 TotalSpaceGB,
i.instance_name,i.host_name
from gv$sort_segment ss,gv$instance i where ss.tablespace_name in (select tablespace_name from dba_tablespaces where contents='TEMPORARY') and
i.inst_id=ss.inst_id;

Total Used and Total Free Blocks

select inst_id, tablespace_name, total_blocks, used_blocks, free_blocks  from gv$sort_segment;

to check TEMP USAGE

col name for a20
SELECT d.status "Status", d.tablespace_name "Name", d.contents "Type", d.extent_management
"ExtManag",
TO_CHAR(NVL(a.bytes / 1024 / 1024, 0),'99,999,990.900') "Size (M)", TO_CHAR(NVL(t.bytes,
0)/1024/1024,'99999,999.999') ||'/'||TO_CHAR(NVL(a.bytes/1024/1024, 0),'99999,999.999') "Used (M)",
TO_CHAR(NVL(t.bytes / a.bytes * 100, 0), '990.00') "Used %"
FROM sys.dba_tablespaces d, (select tablespace_name, sum(bytes) bytes from dba_temp_files group by
tablespace_name) a,
(select tablespace_name, sum(bytes_cached) bytes from
v$temp_extent_pool group by tablespace_name) t
WHERE d.tablespace_name = a.tablespace_name(+) AND d.tablespace_name = t.tablespace_name(+)
AND d.extent_management like 'LOCAL' AND d.contents like 'TEMPORARY';

Temporary Tablespace groups

SELECT * FROM DATABASE_PROPERTIES where PROPERTY_NAME='DEFAULT_TEMP_TABLESPACE';

select tablespace_name,contents from dba_tablespaces where tablespace_name like '%TEMP%';

select * from dba_tablespace_groups;

Block wise Check

select TABLESPACE_NAME, TOTAL_BLOCKS, USED_BLOCKS, MAX_USED_BLOCKS, MAX_SORT_BLOCKS, FREE_BLOCKS from V$SORT_SEGMENT;

select sum(free_blocks) from gv$sort_segment where tablespace_name = 'TEMP';
To Check Percentage Usage of Temp Tablespace

select (s.tot_used_blocks/f.total_blocks)*100 as "percent used"
from (select sum(used_blocks) tot_used_blocks
from v$sort_segment where tablespace_name='TEMP') s,
(select sum(blocks) total_blocks
from dba_temp_files where tablespace_name='TEMP') f;

To check Used Extents ,Free Extents available in Temp Tablespace

SELECT tablespace_name, extent_size, total_extents, used_extents,free_extents, max_used_size FROM v$sort_segment;

To list all tempfiles of Temp Tablespace

col file_name for a45
select tablespace_name,file_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_temp_files  order by file_name;

SELECT d.tablespace_name tablespace , d.file_name filename, d.file_id fl_id, d.bytes/1024/1024
size_m
, NVL(t.bytes_cached/1024/1024, 0) used_m, TRUNC((t.bytes_cached / d.bytes) * 100) pct_used
FROM
sys.dba_temp_files d, v$temp_extent_pool t, v$tempfile v
WHERE (t.file_id (+)= d.file_id)
AND (d.file_id = v.file#);

Additional checks

select distinct(temporary_tablespace) from dba_users;

select username,default_tablespace,temporary_tablespace from dba_users order by temporary_tablespace;

SELECT * FROM DATABASE_PROPERTIES where PROPERTY_NAME='DEFAULT_TEMP_TABLESPACE';

Changing the default temporary Tablespace

SQL> alter database default temporary tablespace TEMP;

Database altered.

To add tempfile to Temp Tablespace

alter tablespace  temp  add tempfile '&tempfilepath' size 1800M;

alter tablespace temp add tempfile '/m001/oradata/SID/temp02.dbf' size 1000m;

alter tablespace TEMP add tempfile '/SID/oradata/data02/temp04.dbf' size 1800M autoextend on maxsize 1800M;

To resize the  tempfile in Temp Tablespace

alter database tempfile '/u02/oradata/TESTDB/temp01.dbf' resize 250M

alter database tempfile '/SID/oradata/data02/temp12.dbf' autoextend on maxsize 1800M;

alter tablespace TEMP add tempfile '/SID/oradata/data02/temp05.dbf' size 1800m reuse;

To find Sort Segment Usage by Users

select username,sum(extents) "Extents",sum(blocks) "Block" from v$sort_usage group by username;

To find Sort Segment Usage by a particular User

SELECT s.username,s.sid,s.serial#,u.tablespace, u.contents, u.extents, u.blocks
FROM v$session s, v$sort_usage u WHERE s.saddr=u.session_addr order by u.blocks desc;

To find Total Free space in Temp Tablespace

select 'FreeSpace  ' || (free_blocks*8)/1024/1024 ||' GB'  from v$sort_segment where tablespace_name='TEMP';

select tablespace_name , (free_blocks*8)/1024/1024  FreeSpaceInGB,
(used_blocks*8)/1024/1024  UsedSpaceInGB, (total_blocks*8)/1024/1024  TotalSpaceInGB from v$sort_segment where tablespace_name like '%TEMP%'

To find  Total Space Allocated for Temp Tablespace

select 'TotalSpace ' || (sum(blocks)*8)/1024/1024 ||' GB'  from dba_temp_files where tablespace_name='TEMP';

Get 10 sessions with largest temp usage

cursor bigtemp_sids is
select * from (
select s.sid,
s.status,
s.sql_hash_value sesshash,
u.SQLHASH sorthash,
s.username,
u.tablespace,
sum(u.blocks*p.value/1024/1024) mbused ,
sum(u.extents) noexts,
nvl(s.module,s.program) proginfo,
floor(last_call_et/3600)||':'||
floor(mod(last_call_et,3600)/60)||':'||
mod(mod(last_call_et,3600),60) lastcallet
from v$sort_usage u,
v$session s,
v$parameter p
where u.session_addr = s.saddr
and p.name = 'db_block_size'
group by s.sid,s.status,s.sql_hash_value,u.sqlhash,s.username,u.tablespace,
nvl(s.module,s.program),
floor(last_call_et/3600)||':'||
floor(mod(last_call_et,3600)/60)||':'||
mod(mod(last_call_et,3600),60)
order by 7 desc,3)
where rownum < 11;

Displays the amount of IO for each tempfile

SELECT SUBSTR(t.name,1,50) AS file_name,
f.phyblkrd AS blocks_read,
f.phyblkwrt AS blocks_written,
f.phyblkrd + f.phyblkwrt AS total_io
FROM   v$tempstat f,v$tempfile t
WHERE  t.file# = f.file#
ORDER BY f.phyblkrd + f.phyblkwrt DESC;

select * from (SELECT u.tablespace, s.username, s.sid, s.serial#, s.logon_time, program, u.extents, ((u.blocks*8)/1024) as MB,
i.inst_id,i.host_name
FROM gv$session s, gv$sort_usage u ,gv$instance i
WHERE s.saddr=u.session_addr and u.inst_id=i.inst_id  order by MB DESC) a where rownum<10;

Show number of tables in the TEMP tablespace - SHOULD be 0:
select count(*)  from dba_all_tables
where tablespace_name = 'TEMP' ;

Shows all objects which exist in the TEMP tablespace - should get
-- NO rows for this:
column owner        format a20
column object_type  format a30
column object_name  format a40
select
o.owner  ,o.object_name
,o.object_type
from sys_objects s
,dba_objects o
,dba_data_files df
where df.file_id = s.header_file
and o.object_id = s.object_id
and df.tablespace_name = 'TEMP' ;

Identifying WHO is currently using TEMP Segments

SELECT sysdate,a.username, a.sid, a.serial#, a.osuser, (b.blocks*d.block_size)/1048576 MB_used, c.sql_text
FROM v$session a, v$tempseg_usage b, v$sqlarea c,
     (select block_size from dba_tablespaces where tablespace_name='TEMP') d
    WHERE b.tablespace = 'TEMP'
    and a.saddr = b.session_addr
    AND c.address= a.sql_address
    AND c.hash_value = a.sql_hash_value
    AND (b.blocks*d.block_size)/1048576 > 1024
    ORDER BY b.tablespace, 6 desc;

Thursday, May 12, 2016

oracle EBS Request flow.

 When user makes a request how request flow across different component in E-Business Suite or Oracle applications .

 different Services/Component in Oracle apps  are ,

1. Oracle Web Server ( Apache, Jserv, plssql ) IAS_ORACLE_HOME 9iAS, Ver. 10222
2. Forms Server ( 8.0.6 ) ORACLE_HOME
3. Report Server ( in side 8.0.6 ORACLE_HOME)
4. Concurrent Manager for Batch or Individual Job Processing
5. Admin Server ( These are used for application dba job like patching , cloning & lot more )
6. Database Server

A) So when User makes a request from browser by typing URL like http:// hostname : port so port number they mention is WebServer Port, request hit to Oracle WebServer ( these requests are recorded in logs where wait for next post )

B) Webserver checks that with http request there is no cookie attached (Cookie is message given by WebServer to Web Browser to identify client) so user is new & it passes login page to User .

C) User types his Username Password in login window & clicks submit button

D) Webserver checks that username and passwords need to authenticate against database FND_USER table , so it needs first some user to check client's username password in database . Guess which username password it uses ?? ( GUEST/ORACLE have you ever noticed why this user is there , Hope you know it now it Uses Guest User to autenticate your user in database )

E) Once user is authenticated its check against FND_RESPONSBILITY..(Confirm again , not sure table name) for Authorization about users responsibilities & assigned responsibilities are presented back to user.

F) Now these responsibilities are of two type Self Services(served by Jserv/Servlets) or Core Applications Server by Forms Server .

G) If this is Core responsibility , Apache transfers request to Forms Listener (Listening on Forms port, I will cover how to check Forms Port in my coming posts ), From here request is on Sockets (May be on forms servelets depending on forms config. ) which is persistense connection. From here onwards Client talks directly with Forms Server in forms session and if Client requested some data, forms server makes database connection ( How ?? using tnsnames.ora in 806 HOME or using dbc Database Connector file in FND_SECURE_TOP or wdbsvr.apps in Apache/modplsql/cfg ?) 

H) If User selected Self Service Responsibility like iProcurement, iRecruitement.., Apache forwards request to mod_jserv and request is fullfilled by jserv_component.
Have you ever noticed why webserver donot ask client to login again until session timeout ??( I know you know answer now its because of cookies as User have valid cookies , try deleting cookies from browser & see Oracle Apache asks you to relogin .

I) When your webserver tries to connect to database for plsql or any other type of connection it asks mod_pls to fulfill request but where is this connection information stored ? ( dbc file or wdbsvr.app file or somthing else ? )

J) Users submits his requests for batch processing or somthing else ( Gather Stats done by Sysadmins or Apps DBA's) these kind of requests are fullfilled by Concurrent Manager.

G) When user want to see reports of all these things request is being forwarded to Reports Server .

Friday, April 29, 2016

web adi errors and solutions

Error1:
Exception Name: oracle.apps.bne.exception.BneFatalException
Cause: Microsoft VBScript runtime error: 429. ActiveX component can't create object 

Solution for Error1: 
Do the setup changes in IE
1. On the Tools menu -> Internet Options -> Security tab and press the Custom Level button.
2. Set "Initialize and script ActiveX controls not marked as safe" to "Prompt".
3. Press 'OK' button after that press 'APPLY' button.
Error2:
Exception Name: oracle.apps.bne.exception.BneFatalException
Cause: Line 85 - Programmatic access to Visual Basic Project is not trusted
Solution for Error2:
Open excel -> Click on File -> Click on Options -> On the bottom left click on "Trust Center" -> On the bottom right click on "Trust Center Settings" button -> On the left click on "Macro Settings" -> on the right "Check" "Trust access to the VBA project object model" -> Click on OK -> Again click on OK button 
Error3:
Exception Name: oracle.apps.bne.exception.BneFatalException
Cause: Line 5397 - Cannot run the macro 'BneMain.SetSessionID'. The macro may be not be available in this workbook or all macros may be disabled.
Solution for Error3:
Check whether you are using 64 bit Microsoft Excel version. You need to uninstall 64bit MS Office and install 32 bit MS Office. (File -> Help, to check the Microsoft Excel version)

Error4:
Viewer "Excel 2010" is not showing in the list.
Solution for Error4:
Customers who are on R12.0.6 version of apps, please apply patch 10190536:R12.BNE.A
Customers who are on R12.1.1 version of apps, please apply patch 10107918:R12.BNE.B
Customers who are on R12.1.2 version of apps, please apply patch 10130099:R12.BNE.B
Customers who are on R12.1.3 version of apps, please apply patch 10108052:R12.BNE.B

Error5:
When clicking on Create Document Excel file opens with following message
Protected View This file was opened from a potentially unsafe location. Click for more details
When click on 'Enable Editing'
Security Warning Macros have been disabled 
Solution for Error5:
File > Options > Trust Center > Trust Center Settings > Protected View > Disable following 3 options.
Error6:
When you click on Create Document, Accounting Flex Field Segment Columns width is squeezed.
Solution for Error6:
Apply Patch 12947598
Refer following Note for additional details.
Web ADI Account Segment Columns Width not increasing individual KFF Segments width [ID 1377692.1]

Error 7:
Viewer : null
Viewer application profile is not set.
Solution for Error7:
Set the profile option GL : Default Desktop Viewer
Navigation: System Administrator > Profile > System

Error 8:
BNE_UIX_PHYSICAL_DIRECTORY is not configured
Solution for Error8:
Remove value for the profile BNE UIX Physical Directory

Error 9:
While uploading through webADI, it gives the success message that all the rows have got uploaded, but when checked from the application, it skips the rows randomly. 
Green smiley face appears [No Error] on this line even if it skips loading
Solution for Error9:
Apply patch 9090447 [For 12.1.3 version]

Error 10:
Unable To Create New Document In Web ADI and screen hangs saying "Verifying WebADI.xls from ..."
Solution for Error10:
Internet Explorer > Tools > Internet Options > Security > Clik on Custom level > Under Scripting > Enable "Allow status bar updates via script"