Oracle CREATE OR REPLACE procedure
A procedure is created using the Oracle create or
replace procedure syntax below:
replace procedure <Name>
as (or is)
With Oracle CREATE OR REPLACE, the OR REPLACE clause allows
the compiler to replace a procedure if a procedure of the same name is
already in the database schema. This aspect of the Oracle CREATE
OR REPLACE procedure is handy during development as you
do not have to drop the procedure each time before recreating it.
With the Oracle CREATE OR REPLACE procedure the
procedure can be called any valid object name. As with any
database object, the Oracle CREATE OR REPLACE procedure is created in the user's schema
unless a schema name is provided. The example below creates the
Oracle procedure in the PUBS schema. The user of the
CREATE OR REPLACE procedure must have rights granted to create
objects in another schema.
replace procedure pubs.example_defaults
Oracle 10g Changes to REPLACE:
In Oracle Database 10g, the REPLACE function has been extended with
the regexp_replace function.
regexp_replace extends the functionality of the REPLACE function by
letting you search a string for a regular expression pattern. By
default, the function returns the supplied source_string variable with
every occurrence of the regular expression pattern replaced by the
supplied replace_string variable. The string returned is either VARCHAR2
or CLOB, and in the same character set as the source_string supplied.
Let's look at an example of regexp_replace (note: in this example we
added a column to the emp table to allow for emp_phone):
4 '(\1) \2-\3') "Test"
5 FROM emp;
In this eample we search for a pattern of numbers that looks like a
European phone number listing such as 111.222.3333 and convert it to a
normal USA format listing of (111) 222-3333.