Solved

ORACLE - split string and populate column to exclude 0's

Posted on 2007-03-21
4
393 Views
Last Modified: 2013-12-19
Hello.

I need a few pointers in the best way to achieve the following....

Im using ORACLE 10G database.

I have a table with a column of type VARCHAR2(30 BYTE)

The data within that column is for example like...... 0000200001007D

currently I have it so that the string is split so that it populates for example 3 separate columns using the SUBSTRB command.

EG 0000200001007D - would become

00002
00001
007D

where the first 5 bits would be in one column and then the next 5 bits in the next etc etc.....

HOWEVER!  I wish to be able to have it so that I can spilt the string and then populate it within 1 new column and have it without the zeros

for example

0000200001007D...... to be split out to become......... 217D

What would be the best way to achieve this??

It is stored so that the every 5 bits display a certain part so I just need to be able to split it all out into one column and have it so that it identifies the zeros and does not include them in the split.

Any help / ideas guys??

cheers and thanks in advance - Jim
0
Comment
Question by:jim_bob_jim
  • 2
  • 2
4 Comments
 
LVL 12

Expert Comment

by:jwahl
Comment Utility
maybe this?

select REPLACE('0000200001007D', '0') FROM dual;

REPL
----
217D
0
 

Author Comment

by:jim_bob_jim
Comment Utility
yes that is the end result but I need to be able to have it so that I can select it by entering the column name and not the actual string itself.  so it replaces all the string in that column.
0
 
LVL 12

Accepted Solution

by:
jwahl earned 500 total points
Comment Utility
so insert column name and table:

SELECT REPLACE(your_column_name, '0')  FROM your_table;
0
 

Author Comment

by:jim_bob_jim
Comment Utility
thanks
0

Featured Post

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.

Join & Write a Comment

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

771 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now