Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Stripping Punctuation
Message
De
07/09/2001 04:40:11
 
 
À
06/09/2001 11:39:34
Robert Byrd
National Association of Homebuilders
Washington, District de Colombia, États-Unis
Information générale
Forum:
Oracle
Catégorie:
PL/SQL
Divers
Thread ID:
00553183
Message ID:
00553635
Vues:
12
If I understand correctly you want to use TRANSLATE.


i.e.
update mytable set testcol=translate(testcol,' ,.;:!?',' ')
Here's an example:
create table test (testcol varchar2(40));
Insert into test values('This is a test! OK? ');
Insert into test values('This, is a test; Whassup? ');
COMMIT;

SQL> select translate(testcol,' ,.;:!?',' ') from test;

TRANSLATE(TESTCOL,',.;:!?','')
----------------------------------------
This is a test OK
This is a test Whassup
There is one little trick that you might not notice by reading this;
There MUST be a space before you list all the punctuation and between
the ,' ' parts (the second argument) Otherwise the function will return nothing.


i.e.
translate(column,' ,.;:!?',' ') 
                  _         _   (where _= space!!!)
You can of course apply this to any table, column.

You can then script it with something like:
set heading off
set echo off
spool c:\tmp.lst
--script an update for each column
select 'UPDATE "'||table_name||'" SET "'
||column_name||'"=translate("'||column_name||'",'||
''''||' ,.;:!?'||''''||','||''''||' '||''''||');'
 from user_tab_columns where data_type='VARCHAR2';
--run the script
--EXECUTE DBMS_OUTPUT.PUT_LINE('COMMIT');
@c:\tmp.lst
COMMIT;
NOTES:
-Not the most effiecient update (each column one at a time) but it will work
-Need to commit at the end.
-Will need a big rollback or uncomment my line --EXECUTE to commit after each update
-Not reccomended on PK columns or FK columns

HTH
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform