Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Convert LONG to VARCHAR2

RE: Convert LONG to VARCHAR2

From: Mercadante, Thomas F <NDATFM_at_labor.state.ny.us>
Date: Fri, 03 Aug 2001 17:14:28 -0700
Message-ID: <F001.0035F277.20010803060133@fatcity.com>

Rick,

One way of doing this is:

Add a new column to the table with a type of Varchar2. Write a PL/SQL routine to convert the long to a varchar2. You can do this simply by assigning the long data type to a varchar2 variable:

create table tomtest(col1 long, col2 varchar2(100));

  1 declare
  2 cursor c1 is select col1,col2 from tomtest;   3 l_vc varchar2(100);
  4 begin
  5 for c1_rec in c1 loop

  6        l_vc := c1_rec.col1;
  7        update tomtest
  8           set col2 = l_vc;

  9 end loop;
 10* end;

Obviously, you need a better 'where clause' in your PL/SQL. :)

Another way is to create a new table, and migrate the data using PL/SQL like above.

Hope this helps.

Tom Mercadante
Oracle Certified Professional

-----Original Message-----
Sent: Friday, August 03, 2001 8:06 AM
To: Multiple recipients of list ORACLE-L

Thanks for the reply but if that is all you have to offer please keep it to yourself.

-----Original Message-----
Sent: Thursday, August 02, 2001 5:14 PM
To: Multiple recipients of list ORACLE-L

By loosing a gig or two of information.

> -----Original Message-----
> From: Cale, Rick T (Richard) [mailto:RICHARD.T.CALE_at_saic.com]
> Sent: Thursday, August 02, 2001 3:04 PM
> To: Multiple recipients of list ORACLE-L
> Subject: Convert LONG to VARCHAR2
>
>
> Hi All,
>
> I know it has been discussed before but can anyone tell me
> how to convert a
> LONG datatype to VARCHAR2?
>
> Thanks
> Rick
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> --
> Author: Cale, Rick T (Richard)
> INET: RICHARD.T.CALE_at_saic.com
>
> Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
> San Diego, California -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from). You may
> also send the HELP command for other information (like subscribing).
>

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Gogala, Mladen
  INET: MGogala_at_oxhp.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Cale, Rick T (Richard)
  INET: RICHARD.T.CALE_at_saic.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Mercadante, Thomas F
  INET: NDATFM_at_labor.state.ny.us

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Fri Aug 03 2001 - 19:14:28 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US