Wednesday, May 26, 2010

Select all data when parameter is null

Sometimes we need to display data based on report parameter and sometimes when user does not input anything, the default action is to display all data.
There are three ways we can use on WHERE clause on SQL:
where column_name = nvl(:parameter, column_name)
or
where column_name like nvl(:parameter, '%')
or
where (column_name = :parameter or :parameter is null)

Friday, May 21, 2010

Identify long running session and kill it

Sometimes you can find an Oracle database session that has been running for very long time. You can find it with this query:
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
Then you can kill it with (change sid and serial# using result from query above):
ALTER SYSTEM KILL SESSION 'sid,serial#';

Wednesday, May 19, 2010

Delete old archivelog

To delete old archivelog, use rman and login.
use this command:
change archivelog until time 'sysdate-x' delete;

Change x with number of days (1,2,3...).

Tuesday, April 13, 2010

adoafmctl.sh: exiting with status 152

Unable to start oafm using adstrtal.sh. Running adoafmctl.sh ends with timeout.

You are running adoafmctl.sh version 120.6.12000000.3
Starting OPMN managed OAFM OC4J instance ...
adoafmctl.sh: exiting with status 152

Solution:

Clear the TLD cache:

- stop all middle tier services

- Delete/backup files this file:

$COMMON_TOP/_TldCache

- start all middle tier services


Tuesday, February 16, 2010

Database link error

I cloned my database to another machine and when I tried to use Oracle database link, this error came out:
ORA-01017: invalid username/password; logon denied ORA-02063: preceding line from %s
I checked the connection using sqlplus, worked. Using connection description on sqlplus, also worked fine. I even recreated the database link, but still failed.
Then I cloned again to another machine, tested the database link, worked.
What was the difference between the two machine? It was the host name settings. The first one that failed had its host name only accessible locally. The second one had its host name registered on DNS server. So the database server I tried to access using database link could resolve host name of the second machine, but not of the first one.
Then I added the host name of first machine to DNS server, tested the database link, worked.

Tuesday, January 26, 2010

Patching OMS to 10.2.0.5 problem

When patching to OMS 10.2.0.5 on Windows, this error encountered:
ADMN-705021

The configuration files for this Oracle Application Server instance are inconsistent with the
configuration stored in the repository. In order to protect the repository,
no further configuration or deployment operations are allowed until the problem with the configuration on the filesystem is resolved. This condition arises when a prior operation was unsuccessful. The exception associated with this failed operation is:

{0}

. Please also check the logs located at
ORACLE_HOME/dcm/logs to determine why DCM was unsuccessful in updating
the configuration files on disk. Some possible causes are:

* permissions on files
* file contention issues on Windows NT
* internal Oracle error

After resolving the problem that prevented DCM from updating the configuration
files, you may use the dcmctl resyncInstance command to resolve the problem.
Alternatively, you can stop and then restart the active dcmctl or EMD
process and resyncInstance will automatically be performed.
Resolution:

Base Exception:
Transaction failed in Plugin cannot rename old configuration file:e:\OMS\oms10g\diagnostics\config\logloader.xml.
Resolution:
Transaction failed in Plugin.
Just run %ORACLE_HOME%\dcm\bin\dcmctl shutdown and retry the patch.

Wednesday, January 20, 2010

Install Enterprise Linux on HP dx2700

Installing Linux on HP dx2700 was a pain. On first trial, the installer was hang on loading ata_piix driver. The BIOS setting for SATA Port 0/1 Working Mode was Native.
On second trial, I set the hard drives setting on BIOS to None (Like the one I used on Windows 2003 installation). The installation went OK until reboot. The computer displayed "Error loading operating system". Then I realized that I haven't reenabled the hard disk and changed the boot sequence. Also I changed SATA Port 0/1 Working Mode to Legacy. After that everything was OK.
Of course if I set BIOS setting for SATA Port 0/1 Working Mode to Legacy before installation. The installation will be fine, but the hard drive will be detected as hda, the performance will be poor.

Friday, January 15, 2010

Remove Enterprise Manager from EBS Database

Shutdown and startup database in restrict mode.
Run this sql as sysdba: emca -deconfig dbcontrol db -repos drop

Tuesday, January 12, 2010

Cancel Invoice error with AP_INV_IS_CREDITED_INV

When canceling invoice, AP_INV_IS_CREDITED_INV error shown. There is a correction on the invoice. You have to fix the data directly on database. Use the following steps to fix the data:
1. Login as apps user to the database.
2. Identify the invoice_id of the invoice to be canceled using
select invoice_id from ap_invoices_all where invoice_num='your invoice number'
3. Verify that your invoice is a corrected invoice using
select invoice_id, line_number from ap_invoice_lines_all where invoice_id = corrected_inv_id
4. You should see your invoice_id on the result, if not then you are facing another problem.
5. Fix the data using this sql
update ap_invoice_lines_all set corrected_inv_id=null where invoice_id='your invoice id from step 2' and line_number='line number from step 3'
6. Don't forget to commit.
7. Cancel your invoice from application.

Friday, December 11, 2009

Be very careful when using tar

I often use tar to make cold database file backup since one big file is faster to copy via network. One time I accidentally entered wrong command on tar, I entered 'tar cvfj /u01/oracle/DEV/db/apps_st/data/* data.tar.bz2'. The tar ran fine until encountered error at the end with no tar file created. Then I realized that the tar command should be 'tar cvfj data.tar.bz2 /u01/oracle/DEV/db/apps_st/data/'.
When I tried to start the DEV database instance, it woudn't start. It said a_archive01 is corrupted (I don't remember the exact error). Luckily it was a DEV instance, I can easily clone again from production instace.
I haven't tried it for second time to make sure it was wrong tar command that made the corruption, but still it is better to be more careful.

Tuesday, December 1, 2009

Exception trying to access the repository. java.sql.SQLException: ORA-02291: integrity constraint (SYSMAN.MGMT_ARU_FAM_PRD_PRD_FK) violated

Problem: Trying to refresh from My Oracle Support on Grid Control 10.2.0.5 and receive Exception trying to access the repository. java.sql.SQLException: ORA-02291: integrity constraint (SYSMAN.MGMT_ARU_FAM_PRD_PRD_FK) violated - parent key not found.
Solution: Go to Deployment tab, select Provisioning > Administration. On Software Library Configuration section, select Purge to purge deleted entities.

Friday, October 30, 2009

Clone E-business suite and grid control problem

When discovering oracle applications on grid control 10.2.05, you encounter error "Wrong System Name" or "Waited for five minutes" and you see the context file mentioned on the log is not correct, then
1. Source your environment for EBusiness Suite instance.
2. Run sqlplus as apps user
SQL> EXEC FND_CONC_CLONE.SETUP_CLEAN;
COMMIT;
EXIT;
3. Run AutoConfig on all tiers, firstly on the DB tier and then the APPS tiers, to repopulate the required system tables.
4. Bounce Agent.
5. Retry to discover EBusiness Suite instance.

Wednesday, October 28, 2009

Grid Agent URL connection interrupted

When trying to open agent URL, something like https://host:3872/emd/main, you receive connection interrupted message on your browser. Go to your agent home/bin directory.
> ./emctl stop agent
> ./emctl secure agent
> ./emctl start agent