special character handling in translate query [message #244269] |
Tue, 12 June 2007 03:54  |
SWATI15.U
Messages: 6 Registered: June 2007 Location: DELHI
|
Junior Member |

|
|
i have a column which is varchar2,i store both numeric and char data in this now i am using translate and replace fuction to seperate the numeric and char value,but if i have a data emp_code,it gives error fir '_'.it will print empcode.how can i find out the same output.can anyone help.
|
|
|
|
Re: special character handling in translate query [message #244279 is a reply to message #244276] |
Tue, 12 June 2007 04:09   |
sanka_yanka
Messages: 184 Registered: October 2005 Location: Kolkata
|
Senior Member |

|
|
Use this query
select replace(trim(translate('xyzSS0124','abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',' 0123456789')),'_','') as only_number,
replace(trim(translate('xyzSS124','abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789','abcdefghijklmnopqrstuvxyzABCDEFGHI JKLMNOPQRSTUVWXYZ ')),'_','') as only_char
from dual
|
|
|
|
Re: special character handling in translate query [message #244322 is a reply to message #244279] |
Tue, 12 June 2007 05:52   |
SWATI15.U
Messages: 6 Registered: June 2007 Location: DELHI
|
Junior Member |

|
|
let me explain you my query,
select replace(translate(field_name,'_0123456789','00000000000'),'0')VALUE_NAME,
to_number(replace(translate(lower(field_name),'_abcdefghijklmnopqrstuvwxyz',rpad('z',27,'z')),'z'))VALUE_NO from table_name
but while using this query if filed name contain any special char it gives an error.e.g if field name is emp_code then it will give error if i'll remove '_' then it will work ok.how to solve it.
|
|
|
|
|