Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

ORACLE - split string and populate Q

Posted on 2007-03-23
6
3,109 Views
Last Modified: 2013-12-19
ORACLE 10G

I have a table with a string in the format for example.......      '00001000090003D

I have a view that has been created from that table to show split the string up like this

col2    col2      col3 col4
00001 00009  003  D

How would I incorporate into my view to get it so that I can populate a 5th col (col5) with the contents from col2, col3, col4 and have the data separated by a . or -

thanks

Jimbo
0
Comment
Question by:jim_bob_jim
6 Comments
 
LVL 7

Expert Comment

by:Docteur_Z
ID: 18781262
select col1||'-'||col2||'-'||col3||'-'||col4 "col5" from yourtable
in your view

or if you want it "inline" :
update yourtable set col5=col1||'-'||col2||'-'||col3||'-'||col4
if each field is caracters.
0
 

Author Comment

by:jim_bob_jim
ID: 18781442
within my table col1 is '00001000090003D'

my view has that column split up into 4 different columns using the SUBSTR command

I need to be able to within my view select a 5th coloumn and have in that column the data from col1, col3, col4 all separated by a '.' or '-' Im not interested with col2

I had already tried your method but I think it is failing cause it needs to select from the columns within the view

any thoughts
0
 
LVL 2

Accepted Solution

by:
Tayger earned 500 total points
ID: 18783991
Should work that way (dont know the exact substr-pos):

Create or replace view xyz
select subsr(0,4) col1,
           substr (4,8) col2,
           substr (8,12) col3,
           substr (12,16) col4,
           subsr(0,4) ||'-'|| substr (8,12)  ||'-'|| substr (12,16)          -- col5 (= col1, col3, col4)
from orig_table

you need to reselect the data from the orig table for the column you want it.
Greetings
Tayger



0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 2

Expert Comment

by:Tayger
ID: 18784003
sorry, mistake in substr ('whole_string'),pos, length)....

Docteur Z's way should work as well, easier way... You can concatenate several columns of the same record and displaying it next to single column values.
Tayger
0
 
LVL 6

Expert Comment

by:morphman
ID: 18784753
Alternatively, create a view-on-a-aview

create view myview2 as
select a.*, col1 || '.' || col3 || '.' || col4 as col5 from myview;
0
 
LVL 2

Expert Comment

by:Tayger
ID: 18784898
Hello again

IMHO, just putting a view on a view is not really recommandable for shwoing a additional column.
If the showed possible are not the solution you are looking for you maybe put a view display example how you would like to have it(?).
Tayger
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Performance issue with case statement in oracle 11G 7 80
oracle collections 2 20
date show only hh:mm 2 25
Help with Oracle IF statment 5 25
Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question