Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB   


 

 

 


 

 

 
 


Oracle data type Converion tips

Oracle Tips by Burleson Consulting

Oracle provides conversion functions that will easily convert values of one datatype to another. While Oracle will perform implicit conversions of datatypes for you, this can lead to performance problems in your applications and to compatibility problems in future versions of Oracle.

Also see the Oracle convert function.

The following Oracle conversion functions can be used to convert Oracle data:

to_char()

The to_char() Oracle conversion function is probably the most commonly used conversion function. The conversion function converts both numerical data and date data to datatype varchar2.

The simplest way of using to_char() to convert Oracle date information is as follows:

to_char ('02/14/97')

This converts the Oracle date into a character string in the default date format (numerical month, numerical day, and a two-digit year, separated by slashes). However, the most common use of to_char() is to convert Oracle dates to type varchar2 in a specific format, as shown in this example,

to_char ('14-FEB-97', 'DD-MON-YYYY')

which returns the following string:

14-FEB-1997

Using to_char() to convert numerical data is very similar to using the function with dates. One common use of this Oracle conversion function is to simply convert data from a numerical datatype to type varchar2. For example,

to_char (25000)

returns

25000

When converting numerical Oracle data, to_char() can also take a second argument; a format model for the output of the function. For example,

to_char (25000, '$99,999.99')

returns

$25,000.00

Chapter 3 lists the elements that can be used in format models for numerical and date data.

to_date()

The to_date() Oracle conversion function is used to convert character data to the date datatype. Like to_char(), this Oracle conversion function can be called with a single parameter, much like

to_date ('02-MAY-97')

which returns a value of type date. to_date() may also be called with a second parameter, which instructs the function to convert the specified string from the specified format into a standard date. For example,

to_date ('02 May 1997', 'DD MONTH YYYY')

returns

02-MAY-97

Valid elements of the format model are discussed in Chapter 3. The examples provided here have all used the default Oracle date format.

to_number()

The to_number() Oracle conversion function converts data of type char or varchar2 to type number. This Oracle conversoin function can accept a single parameter. For example,

to_number ('25000')

returns

25000

The Oracle conversion function can also accept a format model as the second parameter, like the to_char() and to_date() functions. For example,

to_number ('25000', '$99,999.99')

returns

$25,000.00

Valid elements of the format model are discussed in Chapter 3.

             
This is an excerpt from the book "High Performance Oracle Database Automation" by Jonathan Ingram and Donald K. Burleson, Series Editor.

 

For more info on Oracle convert See these related links:

Oracle Convert Date to Number

Oracle Convert to Number

Oracle Conversion Functions - to_char() to_date() to_number() function

Oracle 10g Convert Clause Restrictions Usage Notes

 


 

   

 

  
 

 
 
 
 
Oracle performance tuning software
 
 

 

 
 
 
Oracle performance Tuning 10g reference poster
 
 
 
Oracle training in Linux commands
 
Oracle training Excel
 
Oracle training & performance tuning books
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright ? 1996 -  2012 

All rights reserved.

Oracle ? is the registered trademark of Oracle Corporation.