Split column data [message #606500] |
Fri, 24 January 2014 23:51 |
|
vs_net
Messages: 1 Registered: January 2014
|
Junior Member |
|
|
Hi,
I have a requirement where i need to split the value of a table col varchar2(100) into 4 different fields. I would need to use a view (along with a function) to query the field and then put the values in the 4 columns. The only catch here is that none of the words should be split up i.e incase there is a word at the end of the column it should go in the next column as such. Basically i am looking for word wrapping. Can someone please let me know how to go about this
Eg:-
Suppose i have a col. of length 30 and need to split the value in 3 columns
123456789012345678901234567890
Hi I need to do a word wrap of
Expected result (pl. note that 'word' has moved to col3 since it is btn position 19-23)
col1 = Hi I need
Col2 = to do a
col3 = word wrap o
[EDITED by LF: applied [pre] tags to preserve formatting]
[Updated on: Sat, 24 May 2014 03:30] by Moderator Report message to a moderator
|
|
|
|
|
|
Re: Split column data [message #614624 is a reply to message #606500] |
Fri, 23 May 2014 22:55 |
|
Barbara Boehmer
Messages: 9088 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
If you are just looking for word wrapping, then SQL*Plus can do that for you, as shown below.
SCOTT@orcl12c> create table test_tab (test_col varchar2(30))
2 /
Table created.
SCOTT@orcl12c> insert into test_tab (test_col) values
2 ('Hi I need to do a word wrap of')
3 /
1 row created.
SCOTT@orcl12c> select * from test_tab
2 /
TEST_COL
------------------------------
Hi I need to do a word wrap of
1 row selected.
SCOTT@orcl12c> column test_col format a12 word_wrapped
SCOTT@orcl12c> select * from test_tab
2 /
TEST_COL
------------
Hi I need to
do a word
wrap of
1 row selected.
|
|
|