.ora-code.com

Links
Home
Oracle DBA Forum
Frequent Oracle Errors
TNS:could not resolve the connect identifier specified
Backtrace message unwound by exceptions
invalid identifier
PL/SQL compilation error
internal error
missing expression
table or view does not exist
end-of-file on communication channel
TNS:listener unknown in connect descriptor
insufficient privileges
PL/SQL: numeric or value error string
TNS:protocol adapter error
ORACLE not available
target host or object does not exist
invalid number
unable to allocate string bytes of shared memory
resource busy and acquire with NOWAIT specified
error occurred at recursive SQL level string
ORACLE initialization or shutdown in progress
archiver error. Connect internal only, until freed
snapshot too old
unable to extend temp segment by string in tablespace
Credential retrieval failed
missing or invalid option
invalid username/password; logon denied
unable to create INITIAL extent for segment
out of process memory when trying to allocate string bytes
shared memory realm does not exist
cannot insert NULL
TNS:unable to connect to destination
remote database not found'>ora-02019
exception encountered: core dump
inconsistent datatypes
no data found
TNS:operation timed out
PL/SQL: could not find program
existing state of packages has been discarded
maximum number of processes exceeded
error signaled in parallel query server
ORACLE instance terminated. Disconnection forced
TNS:packet writer failure
see ORA-12699
missing right parenthesis
name is already used by an existing object
cannot identify/lock data file
invalid file operation
quoted string not properly terminated
Regular Expression confusion

Regular Expression confusion

2005-04-20       - By William B Ferguson

Reply:     1     2     3     4     5     6     7     8  

Ron,

I tried that before in my application, and it strips out the '%'
(wildcard) operator that I need to allow for, as valid user input.


-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Bill Ferguson
U.S. Geological Survey - Minerals Information Team
PO Box 25046, MS-750
Denver, Colorado 80225
Voice (303)236-8747 ext. 321 Fax (303)236-4208




-- --Original Message-- --
From: Reidy, Ron [mailto:Ron.Reidy@(protected)]
Sent: Wednesday, April 20, 2005 2:19 PM
To: William B Ferguson; oracle-l@(protected)
Subject: RE: Regular Expression confusion

Can you say something like "upper(regex_replace(name, '[:punct;]' ..."?

-- ---- ---- ----
Ron Reidy
Lead DBA
Array BioPharma, Inc.
303.386.1480


-- --Original Message-- --
From: oracle-l-bounce@(protected)
[mailto:oracle-l-bounce@(protected)]On Behalf Of William B Ferguson
Sent: Wednesday, April 20, 2005 2:13 PM
To: oracle-l@(protected)
Subject: Regular Expression confusion


I'm getting confused on regular expressions (Oracle 10.1.0.4). I want to
strip all punctuation from a user supplied input string except for the '%'
wildcard character. To see if my formatting of the syntax was correct, I
wrote the following sql statement:

SQL> set escape off
SQL> select UPPER(regexp_replace(name,'[''''|"|;| |-|,|.]')) test_data
 2  from names
 3  where upper(regexp_replace(name,'[[:punct:][:space:]]'))
 4   like ('%JGO%');

TEST_DATA
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
A-JGOLDMININGCO
AJGOLDMINE
AJGOLDMININGCO
AJGOLDMININGCO
AJGOLDMININGCO
EJGOGGINSPROSPECT
JJGORDONQUARRY

7 rows selected.

Not quite what I wanted, as a hyphen still appears.

So, I tried escaping the hyphen:
SQL> select UPPER(regexp_replace(name,'[''''|"|;| |\-|,|.]')) test_data
 2  from names
 3  where upper(regexp_replace(name,'[[:punct:][:space:]]'))
 4   like ('%JGO%');

TEST_DATA
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
A-JGMC
AJGM
AJGMC
AJGMC
AGMC
EJGP
JGQ

7 rows selected.

Definitely not what I wanted! So, I figured I'd try adding an extra set of
brackets (like the second regexp_replace uses):

SQL> select UPPER(regexp_replace(name,'[[''''|"|;| |\-|,|.]]'))
SQL> test_data
 2  from names
 3  where upper(regexp_replace(name,'[[:punct:][:space:]]'))
 4   like ('%JGO%');

TEST_DATA
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
A-J GOLD MINING CO
A. J. GOLD MINE
A. J. GOLD MINING CO.
A.J. GOLD MINING CO.
AJ GOLD MINING CO.
E J GOGGINS PROSPECT
JJ GORDON QUARRY

7 rows selected.

That had the effect of negating what I wanted to accomplish in the first
place! I might as well have just selected name.

And if I changed the first regexp_replace to
UPPER(regexp_replace(name,'[''''|"|;| |'-'|,|.]')), Then I get an
ORA-01722 (See ORA-01722.ora-code.com) invalid number.

How do I modify my first regexp_replace to also strip out the hyphen while
allowing the '%' wildcard, unlike the :punct: class?


-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Bill Ferguson
U.S. Geological Survey - Minerals Information Team PO Box 25046, MS-750
Denver, Colorado 80225 Voice (303)236-8747 ext. 321 Fax (303)236-4208
--
http://www.freelists.org/webpage/oracle-l

This electronic message transmission is a PRIVATE communication which
contains information which may be confidential or privileged. The
information is intended to be for the use of the individual or entity
named above. If you are not the intended recipient, please be aware that
any disclosure, copying, distribution or use of the contents of this
information is prohibited. Please notify the sender  of the delivery error
by replying to this message, or notify us by telephone (877-633-2436, ext.
0), and then delete it from your system.
--
http://www.freelists.org/webpage/oracle-l