Click to See Complete Forum and Search --> : Converting numeric values..


Sathy
04-30-2007, 12:03 PM
Hi,

I am having 5 digit numeric field and I want to convert the number by incrementing one on each digit.

for ex:

12345 should be converted as 23456
56789 should be converted as 67890

I thought of adding 11111, but it fails when the field has '9'.

Is there any shortest way to do ?

PAVB
04-30-2007, 12:41 PM
1- Convert your numeric field into a string
2- Build a conversion table... 1234567890 / 2345678901
3- Process each element in your string field replacing chars as per conversion table
4- Convert your string field back to a number

Good Luck

PS: I don't even want to know why you need to do that

slimdave
04-30-2007, 05:54 PM
This?

to_number(translate(to_char(my_column,'0123456789','1234567890'))) ...

PAVB
05-01-2007, 08:21 AM
Good job David

Just a small syntax issue, try this:

to_number(translate(to_char(my_column),'0123456789','1234567890'))

slimdave
05-01-2007, 02:43 PM
Oops. Thanks.

Sathy
05-02-2007, 07:09 AM
Thanks a lot David and PAVB .... :)

Its working fine ...