Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Help with update, please

Re: Help with update, please

From: James Arvigo <Hooper_X_at_Spam_Rage.com>
Date: Wed, 12 Aug 1998 23:00:56 -0500
Message-ID: <35D264F8.4FBE4200@Spam_Rage.com>


Alexander,

I can't say if this is the FASTEST way to do this operation, but I've tested the following query on a database and it worked:

UPDATE users
SET userid = SUBSTR(userid, 1, INSTR(userid, '[') - 1) WHERE userid like '%[%';

Here's my SQL*Plus output when I tried to remove everything after the "1" from all user id's that had "za" and "1..." them:


SQL> select userid from users where userid like 'za%1';

USERID



zach1
zach1

SQL> update users
  2 set userid = SUBSTR(userid, 1, INSTR(userid, '1') - 1)   3 where userid like 'za%1';

2 rows updated

SQL> select userid from users where userid like 'za%1';

USERID



zach
zach

SQL> rollback;

Rollback complete.

SQL> select userid from users where userid like 'za%1';

USERID



zach1
zach1

Anyway... hope that helps.
--
James Arvigo


Alexander Bibighaus wrote:

I have a database table for which I have to update about 15000 of its records.
The problem occured because a program that loaded the table had a bug which was just now discovered. Anyway, here's my problem

I have to update the userid field of all records that match a certain criteria:

     matches "* \[*" escape "\" (space followed by [ ) I want to remove everything from that space before the bracket .. to the end.

For instance:
1 alexb [MBID 08/01/98]
2 janedoe
3 johndoe [MBID 08/01/9
4 longusername [M
5 williamjefferson [

Needs to be
1 alexb
2 janedoe
3 johndoe
4 longusername
5 williamjefferson

What is the best way to do this?
I can only think to select out all the data, dump it to a file, run a perl script,
load it into a temp table, and then update from that temp table.

But because I am dealing with about 15000 records, that is not so desirable :-( Received on Wed Aug 12 1998 - 23:00:56 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US