Home » SQL & PL/SQL » SQL & PL/SQL » Need help converting column datatype and maintaining data
Need help converting column datatype and maintaining data [message #1962] Thu, 13 June 2002 06:22 Go to next message
Orakin
Messages: 3
Registered: June 2002
Junior Member
I have a table and one of it's columns are "long" and I want to convert it to "varchar2" and maintain the data.

Help.

I've tried SELECT - INSERT INTO but got an error stating the illegal use of the LONG field.

Can someone give me an idea...I'm new to ORACLE.

Orakin
Re: Need help converting column datatype and maintaining data [message #1963 is a reply to message #1962] Thu, 13 June 2002 06:41 Go to previous message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
The following anonymous PL/SQL block copies a 
LONG column from table LONGTABLE into a VARCHAR2 column from table VARCHARTABLE, with the assumption 
that LONGTABLE.LONGCOLUMN does not exceed 4000 bytes
in length: 

declare 
string varchar2(4000); 
character char(1); 
begin 
select longcolumn, pk into string, character from longtable; 
insert into varchartable values (string, character); 
end; 

Notice that, even though a varchar2 
datatype declaration in PL/SQL can take a 
maximum length value of up to 32767, the actual VARCHAR2 datatype in the database can only 
accomodate up to 4000 bytes(in 8). 

If this is not helping you...please let me know
Previous Topic: what is wrong with this - urgent plzzzzzzzzzzzzzzzzzzzzzzzzzz
Next Topic: Max lines in Package
Goto Forum:
  


Current Time: Thu Apr 18 22:01:11 CDT 2024