Ilovedatabase’s Blog

Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?

Posts Tagged ‘function’

Oracle/PLSQL: Cast Function

Posted by ilovedatabase on 26 Feb 2009

In Oracle/PLSQL, the cast function converts one datatype to another.

The syntax for the cast function is:

cast ( { expr | ( subquery ) | MULTISET ( subquery ) } AS type_name )

The following casts are allowed:

TO FROM
char, varchar2 number datetime / interval raw rowid, urowid nchar, nvarchar2
char, varchar2 X X X X X
number X X
datetime / interval X X
raw X X
rowid, urowid X X
nchar, nvarchar2 X X X X X

Applies To:

  • Oracle 9i, Oracle 10g, Oracle 11g

For example:

select cast( ’22-Aug-2003′ AS varchar2(30) )
from dual;

This would convert the date (ie: 22-Aug-2003) into a varchar2(30) value.

Source Link

Posted in ORACLE | Tagged: , , , | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.