Thursday, August 8, 2013

Changing Control File location on Database and Re-Creating Control Files


Changing the location of Control File:

SQL> ALTER SYSTEM SET control_files='E:\oracle\oradata\VINAYDEV\CONTROL02.CTL','
E:\ORADATA\VINAYDEV\CONTROL01.CTL' SCOPE=SPFILE;

System altered.

SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

move the physical file on OS-(differenet OS examples):
windows- cut , paste and rename the file accordingly.
SQL> HOST MOVE E:\oracle\oradata\VINAYDEV\CONTROL02.CTL E:\ORADATA\VINAYDEV\CONTROL01.CTL
$ mv E:\oracle\oradata\VINAYDEV\CONTROL02.CTLE:\ORADATA\VINAYDEV\CONTROL01.CTL

SQL> startup
ORACLE instance started.

Total System Global Area 3423965184 bytes
Fixed Size                  2257984 bytes
Variable Size            1862273984 bytes
Database Buffers         1543503872 bytes
Redo Buffers               15929344 bytes
Database mounted.
Database opened.

SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ WRITE

Re-Creating Control Files:

Since this file is heart of a Oracle Database, and unfortunately if anything goes wrong below are the steps to re-create the control files-

CREATE CONTROLFILE REUSE DATABASE "vinaydev" NORESETLOGS NOARCHIVELOG
    MAXLOGFILES 32
    MAXLOGMEMBERS 2
    MAXDATAFILES 32
    MAXINSTANCES 1
    MAXLOGHISTORY 449
LOGFILE
  GROUP 1 'E:\oracle\oradata\VINAYDEV\REDO01.LOG'  SIZE 50M,
  GROUP 2 'E:\oracle\oradata\VINAYDEV\REDO02.LOG'  SIZE 50M,
  GROUP 3 'E:\oracle\oradata\VINAYDEV\REDO03.LOG'  SIZE 50M
# STANDBY LOGFILE
DATAFILE
  'E:\oracle\oradata\VINAYDEV\SYSAUX01.DBF',
  'E:\oracle\oradata\VINAYDEV\SYSTEM01.DBF',
  'E:\oracle\oradata\VINAYDEV\UNDOTBS01.DBF',
  'E:\oracle\oradata\VINAYDEV\USERS01.DBF'
CHARACTER SET WE8MSWIN1252;

SQL>SELECT VALUE FROM V$PARAMETER WHERE NAME = 'control_files';
- will show the updated paths.

Friday, July 26, 2013

Reset OC4J Password

Retset  OC4J instance password
1.      Log into the Application Sever
2.      CD E:\oracle\ora10gASR3\j2ee\instance_name\config
3.      Edit system-jazn-data.xml with text editor

Locate OC4Jadmin and update credentials line

  <name>oc4jadmin</name>
  <display-name>OC4J Administrator</display-name>
  <guid>625FCC40BD5811DDBFD58391AB1EFB4C</guid>
  <description>OC4J Administrator</description>                                                                           
<credentials>{903}twsacWylQXKUDa42787BEBCEEcAnFuWy2NmHarVEBHM=</credentials>

With new password

</credentials>!new_password_321</credentials>

- The exclamation point ensures that the password will be encrypted in the configuration file.

  1. Save your changes and exit the system-jazn-data.xml file

5.       Restart the instance
$ORACLE_HOME/opmn/bin/opmnctl shutdown
$ORACLE_HOME/opmn/bin/opmnctl startall

OR

Restart the instance separately  

$ORACLE_HOME/opmn/bin/opmnctl restartproc process-type=home
$ORACLE_HOME/opmn/bin/opmnctl restartproc process-type=oc4j_soa
$ORACLE_HOME/opmn/bin/opmnctl restartproc process-type=HTTP_Server

Wednesday, July 17, 2013

Full DB Export Failing With EXP-00008: ORA-01031 and ORA-06512: EXP-00085:

Error while Full DB Export:

. exporting post-schema procedural objects and actions
EXP-00008: ORACLE error 1031 encountered
ORA-01031: insufficient privileges
ORA-06512: at "SYS.DBMS_SCHED_MAIN_EXPORT", line 2296
ORA-06512: at "SYS.DBMS_SCHED_JOB_EXPORT", line 52
ORA-06512: at line 1
EXP-00085: The previous problem occurred when calling SYS.DBMS_SCHED_JOB_EXPORT.grant_exp for object 358534
EXP-00008: ORACLE error 1031 encountered
ORA-01031: insufficient privileges
ORA-06512: at "SYS.DBMS_SCHED_MAIN_EXPORT", line 2296
ORA-06512: at "SYS.DBMS_SCHED_JOB_EXPORT", line 52
ORA-06512: at line 1EXP-00085: The previous problem occurred when calling SYS.DBMS_SCHED_JOB_EXPORT.grant_exp for object 358535
EXP-00008: ORACLE error 1031 encountered
ORA-01031: insufficient privilegesORA-06512: at "SYS.DBMS_SCHED_MAIN_EXPORT", line 2296
ORA-06512: at "SYS.DBMS_SCHED_JOB_EXPORT", line 52
ORA-06512: at line 1EXP-00085: The previous problem occurred when calling SYS.DBMS_SCHED_JOB_EXPORT.grant_exp for object 358533.
. exporting user history table


Cause:
OCM jobs ORACLE_OCM Job MGMT_CONFIG_JOB scheduled to be running at the same time, hence export is failing. The scheduled jobs are interrupting the export completion. Oracle was able to identify this from their internal document(not available to outside users).

Solution:
SQL> select object_name, object_type, status from dba_objects where object_id in (358534,358535,358533);

-- see if this returns any rows or not. For me it did not return any values, this means that the objects with IDs 358534, 358535, 358533 do not exist in DBA_OBJECTS 

Check the owner of the jobs with statement:
connect / as sysdba
select owner, job_name, state, next_run_date, last_start_date, last_run_duration from dba_scheduler_jobs;

Than disable the jobs with following commands:

exec dbms_scheduler.disable ('<owner>.MGMT_STATS_CONFIG_JOB');
exec dbms_scheduler.disable ('<owner>.MGMT_CONFIG_JOB');


Or:

Make sure that export job and OCM jobs are not running at the same time.


OCM Jobs:
OCM jobs are default jobs that were introduced starting in Oracle11i. You can disable them and purpose of OCM is to proactively monitor Oracle environment and sending to My Oracle Support(metalink).

Monday, May 6, 2013

Error While Creating a New Oracle APEX Workspace


Error provisioning sandbox.

ORA-00001:uniqueconstraint (APEX_040200.WWV_FLOW_PROV_COMPANY_NAME) violated

Fix:
            select COMPANY_NAME from APEX_040200.WWV_FLOW_PROVISION_COMPANY ;
            select SHORT_NAME from  APEX_040200.WWV_FLOW_COMPANIES;
            delete from apex_040200.WWV_FLOW_PROVISION_COMPANY where company_name='SANDBOX';

commit;
-- this resolves the issue

Oracle APEX Errors


Issues we may encounter post installation of Oracle Application Express:


In my previous post we have seen how to install Oracle Application Express, and below are the errors that I've encountered after installation-


First time login to admin page - localhost:8080/apex/apex_admin throws error  like -

A user name and password are being requested by http://localhost:8080. The site says: “XDB”


Fix:


1) Try restarting listener and see if the issue is resolved or not.

2) Unlock xdb user and change password if necessary (default pwd is xdb)
       And try accessing the admin page.

3) If you still see the same error
Check if user ANONYMOUS is locked. If yes, unlock him and change the password if required.
SQL> alter user ANONYMOUS account unlock;

just in case, is to check whether or not APEX is installed properly. The status should show VALID.                                                                    
SQL> select comp_name, version, status  from dba_registry  where comp_name='Oracle Application Express';
  COMP_NAME
---------------------------------------------------------
VERSION                        STATUS
------------------------------ --------------------------
Oracle Application Express
4.2.2.00.11                    VALID
User altered.

SQL> alter user ANONYMOUS identified by ANONYMOUS;
User altered.

We can also run a sql “epgstat.sql” to see what exactly is going on with XDB user, and take necessary steps.
Script location is-
Windows-  C:\app\vmummadi\product\11.2.0\dbhome_1\RDBMS\ADMIN
Unix- $ORACLE_HOME/RDBMS/ADMIN

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;
/