Wikipedia

Search results

Thursday 31 July 2014

How to compile all Oracle schema objects using dbms_utility.complie_schema

compile_schema is used to compile a whole schema which means you can use the procedure to re-compile procedures, functions, packages and triggers. This procedure in Oracle built-in called DBMS_UTILITY package.

The package should be run with caution as this will take a long time to execute – depending on the size and number of objects in your schema.

Precedure signature (Oracle 8x):
procedure compile_schema(schema varchar2);

Paramemters:
schema – The name of schema that you want to compile.

Oracle 11g Syntax:

procedure compile_schema(schema varchar2,
compile_all boolean default TRUE,
reuse_settings boolean default FALSE);

Paramemters:
schema – The name of schema that you want to compile.
compile_all – a boolean flag to indicate if all schema objects should be compiled even if they are INVALID
reuse_settings – a boolean flag to indicate if the sessions settings should be reused

Example:

To compile objects in SCOTT schema

exec dbms_utility.compile_schema(‘SCOTT’);

exec dbms_utility.compile_schema(‘SCOTT’,TRUE, TRUE);

Wednesday 16 July 2014

Restrict users with read only privilege for all objects in database level


Method which i adhered

You can simply achieve this goal by giving him three permission.

1)Create Session: With this privilege he will be able to log on into the database.

2)Select any Table: With this privilege he will be able to select any table schema rather than SYS objects. Though if O7_DICTIONARY_ACCESSIBILITY parameter is set to TRUE then SELECT ANY TABLE privilege provides access to all SYS and non-SYS objects.

3)Select any dictionary: If O7_DICTIONARY_ACCESSIBILITY parameter is set to TRUE then this privilege is not required to select data dictionary objects or in other word SYS objects. If O7_DICTIONARY_ACCESSIBILITY parameter is set to false then this privilege is required to give select permission on the data dictionary objects.

Following is an example. User arju will be globally read only user.
SQL> create user arju identified by a;
User created.

SQL> grant create session,select any dictionary,select any table to arju;
Grant succeeded.

References :
https://community.oracle.com/thread/1093477?start=0&tstart=0
https://community.oracle.com/thread/1042230
http://arjudba.blogspot.in/2008/09/create-read-only-user-for-schema.html



Create Read only user for a Schema

One thing you need to remember before read this post is there is no easy or shortcut way to make a read only user of another schema. Like grant select on username to another_username- there is no such single command like this. However you may have several alternatives to make read only user for a schema.

I will demonstrate the procedure with examples to make a read only user for a schema. In the example I will make devels user which will have read only permission on prod schema.
Let's start by creating PROD user.
SQL> CREATE USER PROD IDENTIFIED BY P;
User created.

SQL> GRANT DBA TO PROD;
Grant succeeded.

SQL> CONN PROD/P;
Connected.

SQL> CREATE TABLE PROD_TAB1 ( A NUMBER PRIMARY KEY, B NUMBER);
Table created.

SQL> INSERT INTO PROD_TAB1 VALUES(1,2);
1 row created.

SQL> CREATE TABLE PROD_TAB2(DATE_COL DATE);
Table created.

SQL> CREATE OR REPLACE TRIGGER PROD_TAB2_T AFTER INSERT ON PROD_TAB1 
BEGIN
INSERT INTO PROD_TAB2 VALUES(SYSDATE);
END;
/
Trigger created.

SQL>CREATE VIEW A AS SELECT * FROM PROD_TAB2;
View created.


Method 1: Granting Privilege Manually

Step 1: Create devels user
SQL> CREATE USER DEVELS IDENTIFIED BY D;
User created.

Step 2: Grant only select session and create synonym privilege to devels user.
SQL> GRANT CREATE SESSION ,CREATE SYNONYM TO DEVELS;
Grant succeeded.

Step 3:Make script to grant select privilege.
$vi /oradata2/script.sql
SET PAGESIZE 0
SET LINESIZE 200
SET HEADING OFF
SET FEEDBACK OFF
SET ECHO OFF
SPOOL /oradata2/select_only_to_prod.sql
@@/oradata2/select_only_script.sql
SPOOL OFF

This script will run the /oradata2/select_only_script.sql and generate a output script /oradata2/select_only_to_prod.sql which need to be run in fact.

Step 4:
Prepare the /oradata2/select_only_script.sql script which will work as input for /oradata2/script.sql file.

$vi /oradata2/select_only_script.sql
SELECT 'GRANT SELECT ON PROD.' ||TABLE_NAME || ' TO DEVELS;' FROM DBA_TABLES WHERE OWNER='PROD';
SELECT 'GRANT SELECT ON PROD.' ||VIEW_NAME || ' TO DEVELS;' FROM DBA_VIEWS WHERE OWNER='PROD';


Step 5:
Now execute the /oradata2/script.sql which will in fact generate scipt /oradata2/select_only_to_prod.sql.
SQL> @/oradata2/script.sql
GRANT SELECT ON PROD.PROD_TAB1 TO DEVELS;
GRANT SELECT ON PROD.PROD_TAB2 TO DEVELS;


Step 6:
Execute the output script select_only_to_prod.sql which will be used to grant read only permission of devels user to prod schema.
SQL> @/oradata2/select_only_to_prod.sql

Step 7:
Log on devels user and create synonym so that the devels user can access prod's table without any dot(.). Like to access prod_tab2 of prod schema he need to write prod.prod_tab2. But after creating synonym he simply can use prod_tab2 to access devels table and views.
To create synonym do the following,

SQL>CONN DEVELS/D;

SQL>host vi /oradata2/script_synonym.sql
SET PAGESIZE 0
SET LINESIZE 200
SET HEADING OFF
SET FEEDBACK OFF
SET ECHO OFF
SPOOL /oradata2/synonym_to_prod.sql
@@/oradata2/synonym_script.sql
SPOOL OFF


SQL>host vi /oradata2/synonym_script.sql
SELECT 'CREATE SYNONYM ' ||TABLE_NAME|| ' FOR PROD.' ||TABLE_NAME||';' FROM ALL_TABLES WHERE OWNER='PROD';
SELECT 'CREATE SYNONYM ' ||VIEW_NAME|| ' FOR PROD.' ||VIEW_NAME||';' FROM ALL_VIEWS WHERE OWNER='PROD';
SQL>@/oradata2/script_synonym.sql
SQL>@/oradata2/synonym_to_prod.sql

Step 8: At this stage you have completed your job. Log on as devels schema and see,
SQL> select * from prod_tab1;
1 2

SQL> show user
USER is "DEVELS"

Only select privilege is there. So DML will throw error. Like,

SQL> insert into prod_tab1 values(4,3);
insert into prod_tab1 values(4,3)
*
ERROR at line 1:
ORA-01031: insufficient privileges

Method 2: Writing PL/SQL Code
This is script for table :

set serveroutput on
DECLARE
sql_txt VARCHAR2(300);
CURSOR tables_cur IS
SELECT table_name FROM dba_tables where owner='PROD';
BEGIN 
dbms_output.enable(10000000);
FOR tables IN tables_cur LOOP
sql_txt:='GRANT SELECT ON PROD.'||tables.table_name||' TO devels';
execute immediate sql_txt;
END LOOP;
END;
/


This is the script for grant select permission for views :

DECLARE
sql_txt VARCHAR2(300);
CURSOR tables_cur IS
SELECT view_name FROM dba_views where owner='PROD';
BEGIN dbms_output.enable(10000000);
FOR tables IN tables_cur LOOP
sql_txt:='GRANT SELECT ON PROD.'||tables.view_name||' TO devels';
--dbms_output.put_line(sql_txt);
execute immediate sql_txt;
END LOOP;
END;
/

To create synonym on prod schema,


Log on as devels and execute the following procedure.
SQL>CONN DEVELS/D
SQL>
DECLARE
sql_txt VARCHAR2(300);
CURSOR syn_cur IS
SELECT table_name name FROM all_tables where owner='PROD'
UNION SELECT VIEW_NAME name from all_views where owner='PROD' ;
BEGIN dbms_output.enable(10000000);
FOR syn IN syn_cur LOOP
sql_txt:='CREATE SYNONYM '||syn.name|| ' FOR PROD.'||syn.name ;
dbms_output.put_line(sql_txt);
execute immediate sql_txt;
END LOOP;
END;
/


Method 3: Writing a Trigger


After granting select permission in either of two ways above you can avoid creating synonym by simply creating a trigger.

Create a log on trigger that eventually set current_schema to prod just after log in DEVELS user.

create or replace trigger log_on_after_devels
after logon ON DEVELS.SCHEMA
BEGIN
EXECUTE IMMEDIATE 'alter session set CURRENT_SCHEMA = prod';
END;
/

Monday 14 July 2014

11i/R12 Concurrent Program/Request : Pending Standby or Inactive No Manager

.
When I run a Concurrent request I get Phase – Pending and the Status – Standby. What does pending standby means and how to fix it ?
When I run a request in GL,the status appears Inactive and phase as No Manager. Please tell me what the problem could be ?
These are some of common questions I receive in my mail box so I decided to dedicate a post on concurrent request life-cycle.
.
Concurrent Request Lifecycle
Concurrent Request/Program can be under one of four Phases . Each phase has different Status .
Phase : Pending, Running , Completed, Inactive
.
Status :
Pending - Normal, Standby, Schedules, Waiting
Running – Normal, Paused, Resuming, Terminating
Completed – Normal, Error, Warning, Cancelled, Terminated, Disabled
Inactive – Disabled , On Hold, No Manager
.
.
A. Pending Standby  - Phase Pending and Status Standby means Program to run request is incompatible with other program(s) currently running.
How to check Incompatible Program/Request for any Program/Request ?
  • Login with Application Developer responsibility
  • Click on Concurrent > Program
  • Query Program
  • Click on Incompatibilities button
.
B. Inactive – No Manager
i) No manager is defined to run the request
or
ii) All managers are locked by run-alone requests
or
iii) Concurrent Manager Service is down
or
iv) No concurrent manager process because of workshift
To check Work Shift for any Concurrent Manager From System Administrator responsibility > Concurrent > Manager > Define > Work Shifts > Processes

For Description of other Concurrent Request Phase/Status

Concurrent Request Phase and Status

A concurrent request has a life cycle consisting of the following phases: pending, running, completed, and inactive.
During each phase, a concurrent request has a specific condition or statusTable 1 - 38 lists each phase/status combination and describes its meaning in relation to a request.
If a request is pending, you can determine when it will start by using the Concurrent Managers For the Request window from the Requests window to review the request's position in the queues of current managers that can run that request.


Concurrent Request Phase and Status

PhaseStatusDescription
PENDINGNormalRequest is waiting for the next available manager.
 StandbyProgram to run request is incompatible with other program(s) currently running.
 ScheduledRequest is scheduled to start at a future time or date.
 WaitingA child request is waiting for its Parent request to mark it ready to run. For example, a request in a request set that runs sequentially must wait for a prior request to complete.
RUNNINGNormalRequest is running normally.
 PausedParent request pauses for all its child requests to finish running. For example, a request set pauses for all requests in the set to complete.
 ResumingAll requests submitted by the same parent request have completed running. The Parent request resumes running.
 TerminatingRequest is terminated by choosing the Cancel Request button in Requests window.
COMPLETEDNormalRequest completed successfully.
 ErrorRequest failed to complete successfully.
 WarningRequest completed with warnings. For example, a request is generated successfully but fails to print.
 CancelledPending or Inactive request is cancelled by choosing the Cancel Request button in the Requests window.
 TerminatedRequest is terminated by choosing the Cancel Request button in the Requests window.
INACTIVEDisabledProgram to run request is not enabled. Contact your system administrator.
 On HoldPending request is placed on hold by choosing the Hold Request button in the Requests window.
 No ManagerNo manager is defined to run the request. Check with your system administrator. A status of No Manager is also given when all managers are locked by run-alone requests.

Individual Request Progress

Generally when you submit a request, its phase is Pending, which means that it has not yet started running. When it does start running, its phase changes to Running. Upon completion the status of the request becomes either Success, Warning or Error. If your request ends in warning or error, you can use the Special Menu to select Diagnostics from the Requests window to view any diagnostic messages stored in the log file.

Request Set Progress for Stages

When you submit a request set, all the requests in a stage run simultaneously and the phase and status of the set begins as Pending Normal until an available concurrent manager can process it. When a concurrent manager becomes available, the stages's phase and status change to Running Paused as the stage waits for all of its requests to finish. Then the stage changes from Running Paused to Running Normal to write completion information in the report and log files. Finally, the stage phase changes to Completed and its status becomes Success, Warning, or Error.

Progress of Individual Requests in a Stage

When a stage submits its requests, all requests start as Pending Normal, then change to Running Normal, and finally end as either Completed Success, Completed Warning, or Completed Error.

Progress of Linked Stages

When you submit a request set with more than one stage, the request set submits all the stages but only runs one stage at a time, ensuring that each stage completes before submitting the next. Each stage shows a phase of Pending and a status of Normal while it waits for a concurrent manager to process it. As the next available concurrent manager processes the stage, the request set phase and status changes to Running and Paused, as the first stage begins to run. After each stage finishes, the request set temporarily changes to a Normal status to check whether the stage ended in error and to determine whether to stop or which stage should be processed next based on how you linked the stages when you defined the request set.
Once the check is done for a completed stage, the set goes back to Paused status during which the next stage runs. The set alternates between Normal and Paused status for each stage in the set. The set itself resumes running (Running Normal), after all the requests finish, to write completion information in the report and log files. The set ends in a Completed phase, either with Success, Warning or Error status. A request set ends when a stage ends with a completion status that does not link to a subsequent stage.

Thursday 3 July 2014

ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired

Issue :
******
Our end user has faced this error while trying to approve a PO.

Solution :
********
I have found the SID and Serial# using the below query,

SELECT O.OBJECT_NAME, S.SID, S.SERIAL#, P.SPID, S.PROGRAM,S.USERNAME,S.MACHINE,S.PORT ,S.LOGON_TIME,SQ.SQL_FULLTEXT FROM V$LOCKED_OBJECT L, DBA_OBJECTS O, V$SESSION S, V$PROCESS P, V$SQL SQ WHERE L.OBJECT_ID = O.OBJECT_ID AND L.SESSION_ID = S.SID AND S.PADDR = P.ADDR AND S.SQL_ADDRESS = SQ.ADDRESS;

Then i have killed that process using below command

alter system kill session '953,40807';

This resolved my issue but we need to be careful before killing a process.


Finding and Fixing ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired
---------------------------------------------------------------------------------------------------------

Recently we ran into an error Oracle error which says

Caused By: Error executing SQL ALTER TABLE ***_ALLOCATION ADD REGION_ID NUMBER(38):         
Caused By: ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired

The most common reason for this are either 'SELECT FOR UPDATE ' or some uncommitted INSERT statements.

Combining the information I got from several Google searches, I ended up with this sql

SELECT O.OBJECT_NAME, S.SID, S.SERIAL#, P.SPID, S.PROGRAM,SQ.SQL_FULLTEXT, S.LOGON_TIME FROM V$LOCKED_OBJECT L, DBA_OBJECTS O, V$SESSION S, V$PROCESS P, V$SQL SQ WHERE L.OBJECT_ID = O.OBJECT_ID AND L.SESSION_ID = S.SID AND S.PADDR = P.ADDR AND S.SQL_ADDRESS = SQ.ADDRESS;

This gave me info about the sql and the table which it has locked and the logon time.
OBJECT_NAME
SID
SERIAL#
SPID
PROGRAM
LOGON_TIME
SQL_FULLTEXT
TABLE_USER
953
40807
9179
JDBC Thin Client
26-Jul-12
INSERT INTO TABLE_USER VALUES (BLAH…BLAH)
TABLE _USER
953
40807
9179
JDBC Thin Client
26-Jul-12
INSERT INTO TABLE_USER VALUES (BLAH…BLAH)
TABLE _USER
953
40807
9179
JDBC Thin Client
26-Jul-12
INSERT INTO TABLE_USER VALUES (BLAH…BLAH)

The info on the user name and the machine name can also be obtained from the table V$SESSION.  Just add S.USERNAME and S.MACHINE to the above sql.

We have 3 options to fix this error
      Kill the DB session and get the tables unlocked
      Kill the application which holds this particular session(sql connection)
      The ideal solution is to get to the actual process(application) to debug/fix the issue

1. Killing the DB session

To kill the DB session execute the  sql
alter system kill session 'sid,serial#'
In my case it will be
                alter system kill session '953,40807'
2. Killing the Application which holds the session

Get the column value of MACHINE from the table V$SESSION and search for the running processes in that machine. 

SELECT O.OBJECT_NAME, S.SID, S.SERIAL#, P.SPID, S.PROGRAM,S.USERNAME,S.MACHINE,S.PORT ,S.LOGON_TIME,SQ.SQL_FULLTEXT FROM V$LOCKED_OBJECT L, DBA_OBJECTS O, V$SESSION S, V$PROCESS P, V$SQL SQ WHERE L.OBJECT_ID = O.OBJECT_ID AND L.SESSION_ID = S.SID AND S.PADDR = P.ADDR AND S.SQL_ADDRESS = SQ.ADDRESS; 

In my case I just had a look and I knew who the culprit was from the LOGON_TIME from the sql results

[bash]$ ps aux | grep java

user     30745  0.0  3.3 677336 63172 ?        Sl   Jul26   3:26 /usr/local/jdk1.6.0_14/jre/bin/java -jar /opt/ea/nova/jenkins/jobs/project/workspace/target/surefire/surefirebooter5649151821229923783.jar /opt/ea/nova/jenkins/jobs/ project /workspace/target/surefire/surefire1933027872679766101tmp /opt/ea/nova/jenkins/jobs/ project/workspace/target/surefire/surefire5320833548219373656tmp

Now that we got to the process, we can easily debug the problem (or just kill the process :P) I did a
    kill -15 30745
and puff!!!! Problem solved!!!! Yay!!
3. Getting to the Actual Process on the application server


The better way to find the process is to get the V$SESSION.PORT from the above sql  and find the process listening on that port.


SELECT O.OBJECT_NAME, S.SID, S.SERIAL#, P.SPID, S.PROGRAM,S.USERNAME,S.MACHINE,S.PORT ,S.LOGON_TIME,SQ.SQL_FULLTEXT FROM V$LOCKED_OBJECT L, DBA_OBJECTS O, V$SESSION S, V$PROCESS P, V$SQL SQ WHERE L.OBJECT_ID = O.OBJECT_ID AND L.SESSION_ID = S.SID AND S.PADDR = P.ADDR AND S.SQL_ADDRESS = SQ.ADDRESS;


To get to the process listening on the port, execute the below command.For me, the port number was  34465 

   netstat -ap | grep 34465

which gave me

tcp        0      0 machine.name:34465  oracle.db.com:ncube-lm ESTABLISHED 4030/java

Bingo!!! We got the process id 4030. Debug or Kill; Your Choice!!!

Capturing html output from SQL Queries

spool /tmp/check.html 
set markup html on 
set echo on 
select to_char(sysdate,'hh24:mi'), username, program , a.sid, a.serial#, b.name, c.value from v$session a, v$statname b, v$sesstat c where b.STATISTIC# =c.STATISTIC# and c.sid=a.sid and b.name like 'redo%' order by value; 
SELECT s.sid, s.serial#, s.username, s.program,i.block_changes FROM v$session s, v$sess_io i WHERE s.sid = i.sid ORDER BY 5 desc, 1, 2, 3, 4; 
SELECT s.sid, s.serial#, s.username, s.program,t.used_ublk, t.used_urec FROM v$session s, v$transaction t WHERE s.taddr = t.addr ORDER BY 5 desc, 6 desc, 1, 2, 3, 4; 
set markup html off 
spool off 

Wednesday 2 July 2014

Script for killing Inactive forms Sessions

Ref : http://practicalappsdba.wordpress.com/

Lots of time, due to user training issues, users leave their forms sessions open and do not end thier sessions. This can cause lots of issues as sometime even querying in a forms sessions places a lock (I know of Order Entry forms which used to behave like that) and as DBAs you will end up clearing blocking sessions in the database.

Oracle apps has timeout profiles (e.g. ICX Session Timeout) options and confirguration options (Apache timeouts etc) , but most of them do not end the database session. Following script checks the forms sessions in the database and kill the database and their corresponding forms (f60webmx) sessions, which were “INACTIVE” and idle (LAST_CALL_ET) for more than 1 hour.

This works for all types of configurations, whether single node or multi-node. For multi-node the requirement is to enable remsh (remote shell), otherwise change the script to use ssh (for more secure option). It also create log and appends to it and send e-mail if there are any sessions that needs to be killed.



#!/bin/ksh
# ============================================================================
# Program kill_forms_db_long.ksh - Kill long running/inactive forms processes 
# History:
# Date Who Description
# -------- ------------- -----------------------------------
# 04/09/07 Navdeep Saini Initial Creation
# 04/20/07 Navdeep Saini Hard coded the forms: INVTTMTX, INVTVQOH, INVTOTRX
# Usage:
# kill_forms_db_long.ksh [SID] 
# ============================================================================
##############################################################
# userror: echos the usage error line and exits with an exit code of 1
#############################################################
# Set environmental variables
#
command=$(print $0 | awk -F/ '{print $NF }')
typeset -xu ORACLE_SID
LOG=${HOME}/local/log/kill_forms_db_long.log
PW=/usr/local/bin/GetPass.ksh
typeset -x HOSTNAME=$(hostname)
typeset -x DATE=$DATE
function userror
{
 print "Usage: $command [<sid>]"
 exit 2
}
#############################################################
# check that applmgr is running this script
#
if [[ $(/usr/bin/whoami) != applmgr ]]; then
 echo "You must be applmgr to run this script."
 exit 1
fi
############################################################
# if there are no command line parameters the script is in error
#
if [[ $# = 0 ]]; then
 print "Please enter the proper number of command line parameters"
 userror
fi
ORAENV_ASK=NO
typeset -x ORACLE_SID=$1
. /usr/local/bin/db
. ${PW} system
# Check to see if the SYSTEM password is available
if [[ -z ${SYSTEM_PASS} ]]; then
 print "${PW} does not have the SYSTEM password for $ORACLE_SID"
 userror
 fi
############################################################
#Main
#############################################################
sqlplus -s <<EOF
system/${SYSTEM_PASS}@${ORACLE_SID}
set lines 200
set head off
column machine format a10
column logon_time format a19
column spid format a10
column process format a10
column module format a18
spool /tmp/kill_forms_db.lst
select '------------------------------'||to_char(sysdate,'mm-dd-yyyy hh24:mi:ss')||'-------------------------------------' Time from dual;
select 'Following user forms session, inactive for more than 60 min, are killed' from dual;
set head on
set pagesize 1000
SELECT
 p.spid,
 s.process,
 s.status,
 s.machine,
 to_char(s.logon_time,'mm-dd-yy hh24:mi:ss') Logon_Time,
 s.last_call_et/3600 Last_Call_ET,
 s.action,
 s.module,
 s.sid,
 s.serial#
 FROM
 V\$SESSION s
 , V\$PROCESS p
 WHERE
 s.paddr = p.addr
 AND
 s.username IS NOT NULL
 AND
 s.username = 'APPS'
 AND
 s.osuser = 'applmgr'
 AND
 s.last_call_et/3600 > 1
 and
 s.action like 'FRM%' 
 -- and s.module in ('INVTTMTX','INVTVQOH','INVTOTRX') 
 and 
 s.status='INACTIVE' order by logon_time;
spool off
set head off
set feedback off
spool /tmp/db_sessions.lst
Select
'alter system kill session '''||s.sid||','||s.serial#||''';'
 FROM
 V\$SESSION s
 , V\$PROCESS p
 WHERE
 s.paddr = p.addr
 AND
 s.username IS NOT NULL
 AND
 s.username = 'APPS'
 AND
 s.osuser = 'applmgr'
 AND
 s.last_call_et/3600 > 1
 and
 s.action like 'FRM%'
 -- and s.module in ('INVTTMTX','INVTVQOH','INVTOTRX')
 and
 s.status='INACTIVE';
spool off
spool /tmp/forms_session.sh
SELECT
 'remsh '||s.machine||' kill -7 '||s.process
 FROM
 V\$SESSION s
 , V\$PROCESS p
 WHERE
 s.paddr = p.addr
 AND
 s.username IS NOT NULL
 AND
 s.username = 'APPS'
 AND
 s.osuser = 'applmgr'
 AND
 s.last_call_et/3600 > 1
 and
 s.action like 'FRM%'
 -- and s.module in ('INVTTMTX','INVTVQOH','INVTOTRX')
 and
 s.status='INACTIVE';
spool off
EOF
#cat /tmp/kill_forms_db.lst |awk '{print "alter system kill session ('" $7 "\,'" $8}'
#mail -s "Long running forms sessions in "$HOSTNAME navdeep.saini@echostar.com < /tmp/kill_forms_db.lst
cat /tmp/kill_forms_db.lst >> $LOG
file:///C|/blog/kill_forms_db_long.txt (3 of 4) [5/22/2007 2:34:54 PM]file:///C|/blog/kill_forms_db_long.txt
cat /tmp/db_sessions.lst >> $LOG
cat /tmp/forms_session.sh >> $LOG
#Check to see if any rows returned and run the kill db and forms
NUMROWS=`cat /tmp/kill_forms_db.lst|grep "no rows selected"`
#echo $NUMROWS
if [[ $NUMROWS != "no rows selected" ]] then
sqlplus -s <<EOF
system/${SYSTEM_PASS}@${ORACLE_SID}
@/tmp/db_sessions.lst
EOF
#echo "inside if condition"
sh /tmp/forms_session.sh
cat /tmp/kill_forms_db.lst | mailx -s "Ran kill long running forms in "$ORACLE_SID DBATeam@yourdomain.com
fi

Recover database without having required archive log file using _ALLOW_RESETLOGS_CORRUPTION


Last week, I had come across an interesting recovery scenario at client side; we had to recover one of our development databases from old backup.

As part of recovery process, we were able to re-create control file and it prompted for some missing archive logs.

It was critical for us to recover database because of some project deadline.

Error:

SQL> recover database until cancel using backup controlfile;
ORA-00279: change 9867098396261 generated at 03/21/2008 13:37:44 needed for
thread 1
ORA-00289: suggestion : /arcredo/XSCLFY/log1_648355446_2093.arc
ORA-00280: change 9867098396261 for thread 1 is in sequence #2093

Specify log: {=suggested | filename | AUTO | CANCEL}
cancel
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01195: online backup of file 1 needs more recovery to be consistent
ORA-01110: data file 1: ‘/u100/oradata/XSCLFY/SYSTEM01_SCLFY.dbf’
ORA-01112: media recovery not started

SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01195: online backup of file 1 needs more recovery to be consistent
ORA-01110: data file 1: ‘/u100/oradata/XSCLFY/SYSTEM01_SCLFY.dbf’

After doing some research, I found out one hidden parameter (_ALLOW_RESETLOGS_CORRUPTION=TRUE) will allow us to open database even though it’s not properly recovered.

We forced open the database by setting the _ALLOW_RESETLOGS_CORRUPTION=TRUE. It allows us to open database but instance crashed immediately after open. I checked the alert.log file and found out we have undo tablespace corruption.

Alert log shows below error

Errors in file /u01/XSCLFYDB/admin/XSCLFY/udump/xsclfy_ora_9225.trc:
ORA-00600: internal error code, arguments: [4194], [17], [9], [], [], [], [], []
Tue Mar 25 12:45:55 2008
Errors in file /u01/XSCLFYDB/admin/XSCLFY/bdump/xsclfy_smon_24975.trc:
ORA-00600: internal error code, arguments: [4193], [53085], [50433], [], [], [], [], []
Doing block recovery for file 433 block 13525
Block recovery from logseq 2, block 31 to scn 9867098416340

To resolve undo corruption issue, I changed undo_management to “Manual” in init.ora. Now it allowed us to open database successfully. Once database was up and running, I created new undo tablespace and dropped old corrupted undo tablespace. I changed back the undo_management to “Auto” and undo_tablespace to “NewUndoTablespace”.

It resolved our issue and database was up and running without any issue.

_ALLOW_RESETLOGS_CORRUPTION=TRUE allows database to open without consistency checks. This may result in a corrupted database. The database should be recreated.

As per Oracle Metalink, there is no 100% guarantee that setting _ALLOW_RESETLOGS_CORRUPTION=TRUE will open the database. However, once the database is opened, then we must immediately rebuild the database. Database rebuild means doing the following, namely: (1) perform a full-database export, (2) create a brand new and separate database, and finally (3) import the recent export dump. This option can be tedious and time consuming, but once we successfully open the new database, then we expect minimal or perhaps no data loss at all. Before you try this option, ensure that you have a good and valid backup of the current database.Solution:

1) Set _ALLOW_RESETLOGS_CORRUPTION=TRUE in init.ora file.
2) Startup Mount
3) Recover database
4) Alter database open resetlogs.
5) reset undo_management to “manual” in init.ora file.
6) startup database
7) Create new undo tablespace
changed undo_management to “AUTO” and undo_tablespace to “NewTablespace”
9) Bounce database.

Missing standard button in a form & How to enable those buttons manually in R12

Issue :

While checking the asset information of a particular responsibility, its not having Split and Open buttons. But its visible to the other responsibilities.

Solution :

1. I will have to enable these buttons manually.
2. We need to go to the form which is having issue and then Click -> Help -> About Oracle Applications
3. We can find Forms name and Responsibility Name from it.

Responsibility : XXXX Asset for Store
Form Name : FAXMADDS
Form Path : /TESTAPP/R12/apps/apps_st/appl/fa/12.0.0/forms/US/FAXMADDS.fmx

4. Using responsibility name, Query under system administrator -> Security -> Responsibility -> Define. You can find Menu name.

Menu Name : XXXX_ASSET_STORE

5. Using Menu, Query under Application Developer -> Menu. We can find Sub Menus under Menus.

Sub Menu : FA_MASS_ADDITION
  FA_TRANSACTIO_STORE

6. Using Sub Menu, Query under Application Developer -> Menu. We can find functions under Sub Menus.

Function(FA_MASS_ADDITION) : Mass Additions:Add to Asset
    Mass Additions:Open
    Mass Additions:Split

7. The above three functions are not present in that form and that is existing for another responsibility and after adding these, the buttons are visible now.

Tuesday 1 July 2014

R12 application credentials for DEMO purporse

Home URL : http://vis1213.solutionbeacon.net
Username : VS2131
Password : welcome