Home » SQL & PL/SQL » SQL & PL/SQL » How to convert Long to Varchar2 ?
How to convert Long to Varchar2 ? [message #421646] Wed, 09 September 2009 10:34 Go to next message
tondapi
Messages: 99
Registered: August 2007
Location: usa
Member
Hi,

Can any one help me howto convert the LONG data type to Varchar2.

What function i want to use for this one...




thanks
Re: How to convert Long to Varchar2 ? [message #421648 is a reply to message #421646] Wed, 09 September 2009 10:37 Go to previous messageGo to next message
pablolee
Messages: 2835
Registered: May 2007
Location: Scotland
Senior Member
Since you are on a really old version, you'll need to use PL/SQL
Re: How to convert Long to Varchar2 ? [message #421654 is a reply to message #421648] Wed, 09 September 2009 10:51 Go to previous messageGo to next message
tondapi
Messages: 99
Registered: August 2007
Location: usa
Member
i am using 10g
Re: How to convert Long to Varchar2 ? [message #421666 is a reply to message #421646] Wed, 09 September 2009 11:41 Go to previous message
Michel Cadot
Messages: 64140
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Create a new table with varchar2:
SQL> create table t (id integer, val long) ;

Table created.

SQL> insert into t select rownum, 'A' from dual connect by level <= 10;

10 rows created.

SQL> create table t2 (id integer, val varchar2(100));

Table created.

SQL> insert into t2 select id, to_lob(val) from t;

10 rows created.

SQL> drop table t;

Table dropped.

SQL> rename  t2 to t;

Table renamed.

SQL> desc  t
 Name                             Null?    Type
 -------------------------------- -------- ----------------------
 ID                                        NUMBER(38)
 VAL                                       VARCHAR2(100 CHAR)

Regards
Michel
Previous Topic: Does Oracle optimize function calls in SELECT stmt?
Next Topic: How to Bypass "ORA-01722: invalid number"
Goto Forum:
  


Current Time: Fri Dec 09 08:09:46 CST 2016

Total time taken to generate the page: 0.12575 seconds