Monday, May 6, 2013

Oracle Application Express(APEX) Installation Step by Step


Environment: Oracle Windows 32bit,, Oracle database 11.2.0.1.0 EE, APEX 4.2.2.00.11, 4GB RAM
Steps:

1) Download the software
You can download APEX 4.2 from Oracle.com/downloads.  I downloaded  the “only english” zip file. You can download the documentation separately.

2) copy and extract the software
Now copy and extract the apex_4.2.zip file to your machine. I use “unzip” to unzip the zip file. This will create a folder named “apex”. I kept this folder on my machine in a permanent location, c:\apex.

3) check the tablespace requirements –
You need about 275MB of free space in the APEX tablespace (mine is called “APEX”) and 100MB of free space in the SYSTEM tablespace.
Note: Not a problem if you haven’t created one, this will get created once your APEX installation is complete and you start creating workspaces.

SQL executions:

Now login to DOS prompt or PUTTY and execute the sql’s wherever the APEX folder was unzipped:

C:\Users\vmummadi>cd C:\apex
C:\apex>dir – this will show all the contents under this folder.

SQL> connect / as sysdba
Connected.
SQL> @apexins SYSAUX SYSAUX TEMP /i/  

- Pass tbs names as it will put its data and indexes here, it also uses the temp tbs and ‘i’ -is the virtual directory where it stores all images.

This will run for a very long time (anywhere between 30-90mins) depends on server and environment, for me it took 104mins. And it will generate a spool file under the same directory (install2013-05-02_15-24-49.log). At the end you should see success message something like this-

PL/SQL procedure successfully completed.

timing for: Install Internal Applications
Elapsed: 01:23:02.39 

Thank you for installing Oracle Application Express.

Oracle Application Express is installed in the APEX_040200 schema.

The structure of the link to the Application Express administration services is as follows:
http://host:port/pls/apex/apex_admin (Oracle HTTP Server with mod_plsql)
http://host:port/apex/apex_admin     (Oracle XML DB HTTP listener with the embedded PL/SQL gateway)

The structure of the link to the Application Express development interface is as follows:
http://host:port/pls/apex (Oracle HTTP Server with mod_plsql)
http://host:port/apex     (Oracle XML DB HTTP listener with the embedded PL/SQL gateway)

JOB_QUEUE_PROCESSES: 1000
PL/SQL procedure successfully completed. 

Session altered. 

Performing Application Express component validation - please wait...

old   6:     if '^UPGRADE' = '1' then
new   6:     if '2' = '1' then
old   7:        dbms_registry.loaded('APEX','^version');
new   7:        dbms_registry.loaded('APEX','4.2.2.00.11');
old   8:     elsif '^UPGRADE' = '2' then
new   8:     elsif '2' = '2' then
old  10:             dbms_registry.upgraded('APEX','^version');
new  10:             dbms_registry.upgraded('APEX','4.2.2.00.11');
old  12:             dbms_registry.loaded('APEX','^version');
new  12:             dbms_registry.loaded('APEX','4.2.2.00.11');
Completing registration process. 17:11:01
Validating installation.  17:11:02
...Database user "SYS", database schema "APEX_040200", user# "92" 17:11:02
...Compiled 0 out of 3004 objects considered, 0 failed compilation 17:11:02
...266 packages
...258 package bodies
...452 tables
...11 functions
...16 procedures
...3 sequences
...457 triggers
...1320 indexes
...211 views
...0 libraries
...6 types
...0 type bodies
...0 operators
...0 index types
...Begin key object existence check 17:11:02
...Completed key object existence check 17:11:03
...Setting DBMS Registry 17:11:03
...Setting DBMS Registry Complete 17:11:03
...Exiting validate 17:11:03

PL/SQL procedure successfully completed.

timing for: Validate Installation
Elapsed: 00:00:02.88
old   1: alter session set current_schema = ^APPUN
new   1: alter session set current_schema = APEX_040200

Session altered.

timing for: Complete Installation
Elapsed: 01:46:11.17

PL/SQL procedure successfully completed.


GLOBAL_NAME
------------------------------
SYS

1 row selected.

 n  If you don’t see something similar to this or any error this script will exit out before completing the execution, and we need to fix the error.

SQL> connect / as sysdba
Connected.

- to check whether or not APEX is installed properly. The status should show VALID.

SQL> select status from dba_registry where comp_id='APEX'; 

STATUS
-------------------------------------------------------
VALID

Images script:  parameterit takes is one directory up. So this one directory level up-

SQL> connect / as sysdba
Connected.
SQL> @apxldimg c:
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
 Loading images directory: c:\/apex/images
Directory created.
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
Commit complete.
Directory dropped.
timing for: Load Images
Elapsed: 00:10:31.41
C:\apex>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Thu May 2 17:31:47 2013
Copyright (c) 1982, 2010, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> @apxconf
 PORT
----------
8080
Enter values below for the XDB HTTP listener port and the password for the Application Express ADMIN user.
Default values are in brackets [ ].
Press Enter to accept the default value.
Enter a value below for the password for the Application Express ADMIN user.
Enter a password for the ADMIN user     [] – <enter password here>
(remember this pwd as you will use this for login as admin)
Session altered.
...changing password for ADMIN
PL/SQL procedure successfully completed.
Enter a port for the XDB HTTP listener [      8080]
...changing HTTP Port
(leave it at 8080 if you don’t want to change the port number, if you want to change then change it to whatever you want, for LINUX there are rules to changes port numbers below 1024)
PL/SQL procedure successfully completed.

This completes the installation.

Now login to APEX admin:
localhost:8080/apex/apex_admin – this is the administrator page , local host since mine is local machine.
localhost:8080/apex/ - users access page
Now follow the instructions what it says from this page – Ex: change password, etc…

-Now you will be ablet o see lot of applications  like manage requests, manage instance, manage workspace, monitor activity.

Wednesday, May 1, 2013

TAB KEYS DO NOT WORK IN ORACLE WEBLOGIC FORMS SERVER

Problem:

In oracle weblogic forms server when we provide the username and hit the tab for password, it doesn't go to next level(password) instead it highlights the username section- this issue is after upgrading the JRE version to 1.7.17 from 1.6.


After entering username and then tabbing to password field fails. Instead the username is highlighted. Password field can be accessed using mouse.


Description:

Our Oracle forms version 11.1.1.6.

This is one of the known issues from Oracle, possibly this could be -
Java Script Actions Cause Form to Hang when Using JRE 1.7 [ID 1527994.1]

Solution:

But we fixed our issue after implementing step 2 from below steps:


1.  Install Java Release 7_u13 (ie. JRE 7 U13).   Another customer reported the issue reproduces on Java Release 7_u15 (ie. JRE 7 U15).

 -or-

2.  For Oracle Fusion Middleware 11g Release 1, wait for the release of patchset v. 11.1.1.7 . 

Otherwise, there is a one-off patch available for 11.1.1.6, but you need to consume the patchset when it becomes available :
 Patch:14277452 - APPS6: JRE7CERT: TAB KEYS DO NOT WORK IN LOV TO NAVIGATE TO FIND BUTTON (CTRL+L)

 -or-

3.  Upgrade to Oracle Fusion Middleware 11g Release 2 and install patchset 1 (v. 11.1.2.1.0).

 -or-

4.  Wait for the bugfix in the next Oracle Fusion Middleware Release 12.

Known issue from Oracle - Forms Login Screen Does Not Allow Tab To Next Field [ID 1526006.1]
This is also a bug reported by Oracle - Bug 15920248 : TAB KEY DOES NOT WORK ON LOGIN FORM

Thursday, April 4, 2013

GRID CONTROL AGENT OUT OF SYNC



                          Agent Out Of Sync
Error Messages you may see:
Did not receive valid response to ping "ERROR-Agent is blocked. Blocked reason is: Agent is out-of-sync with repository. This most likely means that the agent was reinstalled or recovered. Please contact an EM administrator to unblock the agent by performing an agent resync from the console. Please contact EM adminstrator to unblock the agent"
'OR'
Error: The Oracle Management Server(OMS) has blocked this agent because it has either been reinstalled or restored from a filesystem backup. Please click on the Agent Resynchronization button to resync the agent.
Reason:
The communication between OMS and agent does not work. This is in most cases because something has been changed to one of the components so the SSL certificate is not valid anymore. Therefore you have to resecure the agent.
Try these solutions in the following order:

*****************************************
* Resync Agent

From the Grid Control console, click on the Agent target.

Select "Agent Resynchronization" from the bottom menu.

*****************************************
* Run the following commands for Agent Clearstate.

set ORACLE_HOME=E:\oracle\agent11g
set PATH=%ORACLE_HOME%\bin;%PATH%

emctl status agent

emctl stop agent

emctl clearstate agent

emctl start agent

emctl upload agent

emctl status agent

******************************************
* Remove all of the following from the Agent Home (for UNIX/LINUX- rm *.* under each directory)

del /Q E:\oracle\Middleware\agent11g\sysman\emd\state\*
del /Q E:\oracle\Middleware\agent11g\sysman\emd\upload\*
del E:\oracle\Middleware\agent11g\sysman\emd\lastupld.xml
del E:\oracle\Middleware\agent11g\sysman\emd\agntstmp.txt
del E:\oracle\Middleware\agent11g\sysman\emd\protocol.ini
del E:\oracle\Middleware\agent11g\sysman\emd\blackouts.xml

set ORACLE_HOME=E:\oracle\agent11g
set PATH=%ORACLE_HOME%\bin;%PATH%

emctl stop agent
emctl start agent
emctl status agent

RMAN-03009: ORA-19504: ORA-27040 OSD-04002:


Error Creating a Control File Backup :

Starting Control File Autobackup at 28-MAR-13
released channel: c1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of Control File Autobackup command on c1 channel at 03/28/2013 23:34:12
ORA-19504: failed to create file "E:\ORABACK\VMPROD\BACKUP\BACKUPDATA\RMAN
BACKUP\SNAP_CTLFILE.CTL"
ORA-27040: file create error, unable to create file
OSD-04002: unable to open file
O/S-Error: (OS 3) The system cannot find the path specified.

Recovery Manager complete.

Workaround:

RMAN>show all; 

using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name VMPROD are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F';
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET PARALLELISM 1;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOA
D TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'E:\oraback\VMPROD\backup\backupdata\rman
backup\snap_ctlfile.ctl'; - during a manual RMAN run these parameters were saved to RMAN configuration
CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'E:\ORABACK\VMPROD\BACKUP\BACKUPDATA\RMAN
BACKUP\SNAP_CTLFILE.CTL'; --- during a manual RMAN run these parameters were saved to RMAN configuration

RMAN> CONFIGURE SNAPSHOT CONTROLFILE NAME CLEAR; -- restores to default RMAN parameter values

old RMAN configuration parameters:
CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'E:\oraback\VMPROD\backup\backupdata\rmanbackup\snap_ctlfile.ctl';
old RMAN configuration parameters:
CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'E:\ORABACK\VMPROD\BACKUP\BACKUPDATA\RMANBACKUP\SNAP_CTLFILE.CTL';
RMAN configuration parameters are successfully reset to default value

RMAN> show all;

RMAN configuration parameters for database with db_unique_name VMPROD are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F';
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET PARALLELISM 1;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOA
D TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'E:\ORACLE\ORA11GR2\DATABASE\SNCFVMPROD.O
RA'; # default

After clearing the above control file parameters from RMAN configuration, try running the RMAN backup job again.


TRIGGER BEFORE DROPPING AND REPLACING AN EXISTING SYNONYM


Before Drop:

CREATE OR REPLACE TRIGGER 'ABC'
BEFORE DROP
ON DATABASE
DECLARE
GRANTED_ROLE VARCHAR2(30);
X_GRANTED_ROLE VARCHAR2(100);
temp_cnt NUMBER  := 0 ;
BEGIN

select count(*)
INTO temp_cnt
from dba_users
where profile LIKE 'APPLICATION%' --- here anyone can drop except, users with Application profile                                    
and username = ora_dict_obj_owner ;  

if ( temp_cnt > 0 )
    THEN
    IF SYS.DICTIONARY_OBJ_TYPE = 'SYNONYM' THEN
        RAISE_APPLICATION_ERROR(-20998, 'Public Synonym Cannot be dropped. Contact DBA');
    END IF;
  END IF ;
  END;
/


Before Replace: (Can create a new synonym, but cannot replace an existing synonym)


1)
CREATE OR REPLACE TRIGGER 'XYZ'
  before create on database
declare
    temp_cnt NUMBER := 0 ;

  function syn_exists
    return boolean is
    v_dummy   varchar2 (1);
    raise_application_error varchar2(30);
  begin
    select null
    into   v_dummy
    from   dba_synonyms
    where      owner = 'PUBLIC'
           and synonym_name = ora_dict_obj_name;

    return true;
  exception
    when no_data_found then
      return false;
  end syn_exists;
begin

select count(*)
INTO temp_cnt
from dba_users
where profile LIKE 'APPLICATION%'  ---- for certain users in DB
and username = ora_dict_obj_owner ;  

if ( temp_cnt > 0 ) and ( ora_dict_obj_type = 'SYNONYM' ) and (syn_exists ) then
        raise_application_error ( -20000, 'Public Synonym ' || ora_dict_obj_name || ' aready exists. Cannot replace it. Contact DBA');
end if ;

end;
/

'OR'

2)
CREATE OR REPLACE TRIGGER '123'
  before create on database
DISABLE
declare
  function syn_exists
    return boolean is
    v_dummy   varchar2 (1);
    raise_application_error varchar2(30);
  begin
    select null
    into   v_dummy
    from   all_synonyms
    where      owner = ora_dict_obj_owner
           and synonym_name = ora_dict_obj_name;

    return true;
  exception
    when no_data_found then
      return false;
  end syn_exists;
begin
  if ora_dict_obj_type = 'SYNONYM' then
    if syn_exists then
      if not dbms_session.is_role_enabled ('DBA') then --- for all users in DB
        raise_application_error ( -20000, 'Synonym ' || ora_dict_obj_name || ' aready exists, attempt to replace contact DBA');
      end if;
    end if;
  end if;
end;
/

Monday, March 18, 2013

ASMCMD-08102: NO CONNECTION TO ASM; COMMAND REQUIRES ASM TO RUN


Platform         Microsoft Windows x64 (64-bit)
Product Version  11.2.0.2

DETAILED PROBLEM DESCRIPTION
+ASM instance is up/running and only accessible through EMGrid Control and cannot use 
sqlplus to connect to +ASM instance, but asmcmd fails with the following error:
 
ASMCMD-08102: no connection to ASM; command requires ASM to run
C:\Users\vmummadi>set oracle_home=C:\Oracle\Grid11gR2
C:\Users\vmummadi>SET ORACLE_SID=+ASM
C:\Users\vmummadi>asmcmd
Connected to an idle instance.
ASMCMD> lsdg
ASMCMD-08102: no connection to ASM; command requires ASM to run
 Enabled asmcmd tracing and the trace further shows:
C:\Users\vmummadi>set DBI_TRACE=1
C:\Users\vmummadi>set oracle_home=C:\Oracle\Grid11gR2
C:\Users\vmummadi>asmcmd
   DBI 1.602-ithread default trace level set to 0x0/1 (pid 7412) at DBI.pm line 273 via asmcmdshare.pm line 201
   -> DBI->connect(dbi:Oracle:, , ****, HASH(0x44ca968))
   -> DBI->install_driver(Oracle) for MSWin32 perl=5.010000 pid=7412 ruid=0 euid=0
      install_driver: DBD::Oracle version 1.20 loaded from C:/Oracle/Grid11gR2/perl/site/lib/DBD/Oracle.pm
            !! ERROR: '12560' 'ORA-12560: TNS:protocol adapter error (DBD ERROR: OCIServerAttach)' (err#0)
         DBI connect('','',...) failed: ORA-12560: TNS:protocol adapter error (DBDERROR: OCIServerAttach)
Connected to an idle instance.
ASMCMD>
check listener:
C:\Users\vmummadi>lsnrctl status
LSNRCTL for 64-bit Windows: Version 11.2.0.2.0 - Production on 07-MAR-2013 08:49:35
Copyright (c) 1991, 2010, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
---------------------------
Alias                     LISTENER
Version                   TNSLSNR for 64-bit Windows: Version 11.2.0.2.0 - Production
Start Date                22-FEB-2013 20:39:32
Uptime                    12 days 12 hr. 10 min. 4 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   C:\Oracle\Grid11gR2\network\admin\listener.ora
Listener Log File         C:\Oracle\diag\tnslsnr\ATLAS\listener\alert\log.xml
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc)))
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=<omitted here>)(PORT=1521)))
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=<omitted here>)(PORT=1521)))
Services Summary...
Service "+asm" has 1 instance(s).
 Instance "+asm", status READY, has 1 handler(s) for this service...
...
The command completed successfully
Errors:
The errors are misleading, including the ORA-12560 (TNS:protocol adapter error).

The clue to the underlying problem is coming from the ORA-1031 (insufficient privileges) 
during sqlplus "/ as sysasm"
C:\> set oracle_home=C:\Oracle\Grid11gR2
C:\> SET ORACLE_SID=+ASM
C:\> echo %ORACLE_SID%
+ASM
C:\> echo %ORACLE_HOME%
C:\Oracle\Grid11gR2
C:\> sqlplus "/ as sysasm"
SQL*Plus: Release 11.2.0.2.0 Production on Wed Mar 13 12:03:09 2013
Copyright (c) 1982, 2010, Oracle.  All rights reserved.
ERROR:
ORA-01031: insufficient privileges 

Also, check if "SQLNET.AUTHENTICATION_SERVICES = (NTS)" is already set in the server's 
sqlnet.ora file

Solutions:
User is not part of the ORA_DBA OS group:
C:\Users\vmummadi>echo %username%
vmummadi
C:\Users\vmummadi>NET LOCALGROUP ORA_DBA
Alias name     ORA_DBA
Comment        Oracle DBA Group
Members
-------------------------------------------------------------------------------
.... <-- other users listed here except 'vmummadi'

NT AUTHORITY\SYSTEM
The command completed successfully.

The problem is to do with harden security in 11g that affects non-dba OS users with 
connections to Oracle instances.
If the user is not a member of the ORA_DBA OS group, then it either needs to connect to 
the ASM instance using the ASM orapw file (either using his/her own account or using the 
Oracle SYS account and as sysasm privilege) or be added to the OS ORA_DBA group.
Other workarounds include :
  • Add the non-dba OS user to the ASM's orapw file and grant it 'SYSASM' privileges:
  • Follow this -   http://docs.oracle.com/cd/E11882_01/server.112/e25494/dba007.htm#ADMIN12478
  • Allow the non-dba user to connect to the ASM instance using the SYS Oracle user account
  • (for this, the non-dba user must know what is the password for SYS):

  • Example: sqlplus sys@<hostname or IP address of the host>:<port were the listener
  • lis tens>/+ASM as sysasm
  • Make the non-dba OS user a member of the ORA_DBA OS group so it can use bequeath connections
  • (ie, not using the listener) to the asm instance (ie, sqlplus "/ as sysasm")                Oracle Support -ID 1537484.1   Reference: Bug 16470328