Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old December 28th, 2004, 01:59 PM
liftapia liftapia is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 1 liftapia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation split column into 3 columns

I have a single address columns that is holding address2 and address3 as well with carriage returns. I need the address column split into 3 seperate columns. So data like the following:

address
----------------
Admin Tech Services

1234 Elm Avenue

Towne House

can display as:
address
--------
Admin Tech Services

address2
---------
1234 Elm Avenue

address3
--------
Towne House

Reply With Quote
  #2  
Old January 27th, 2005, 08:55 PM
wubandit99 wubandit99 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 30 wubandit99 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 6 m 31 sec
Reputation Power: 4
Assuming you know what your carriage returns are (chr(10) in example), this can be done with case statements like the following. If you know every address has 3 lines, you can skip the case and just use the lines in the "else" sections.

Code:
update tbl
	set address = 
		case 
			when instr(address, chr(10)) = 0 
			then
				address
			else
				substr(address, 1, instr(address, chr(10))-1)
		end,
	address2 = 
		case
			when instr(address, chr(10)) = 0
			then
				null
			when instr(address, chr(10), 1, 2) = 0
			then
				substr(address, instr(address, chr(10))+1)
			else
				substr(address, instr(address, chr(10))+1, (instr(address, chr(10), 1, 2)-instr(address, chr(10)))-1)
		end,
	address3 = 
		case
			when instr(address, chr(10), 1, 2) = 0
			  or instr(address, chr(10)) = 0
			then
				null
			else
				substr(address, instr(address, chr(10), 1, 2)+1)
		end

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > split column into 3 columns


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway