Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Modify data from select before insert.
Lyndon,
Look up the substr command, as well as translate and replace. In your examples, your query would look like:
insert into table1
(col1)
select replace(substr(col1,1,3) || '-' || substr(col1,4,100),'A','B') from
tabl2;
Would add the dash and replace all 'A' with 'B'.
Hope this helps.
Tom Mercadante
Oracle Certified Professional
-----Original Message-----
From: Lyndon Tiu [mailto:ltiu_at_alumni.sfu.ca]
Sent: Thursday, August 19, 2004 3:04 PM
To: oracle-l_at_freelists.org
Subject: Modify data from select before insert.
Hello guys,
I could use a few tips here.
I have a sql statement:
insert into table1
(
col1
)
select col1 from tabl2;
Problem is, I need to modify the data in the column from table2 first before inserting to table1. Like add a dash, after the third character ... chnage all A's to B's sort of thing.
Can you guys give me a few hints and perhaps a few keywords I can use to search google for?
Thank you very much.
--
Lyndon Tiu
FAQ is at http://www.freelists.org/help/fom-serve/cache/1.htmlput 'unsubscribe' in the subject line.
-----------------------------------------------------------------
----------------------------------------------------------------
Please see the official ORACLE-L FAQ: http://www.orafaq.com
----------------------------------------------------------------
To unsubscribe send email to: oracle-l-request_at_freelists.org