Solved

Need help on Oracle sql

Posted on 2014-10-11
3
485 Views
Last Modified: 2014-10-14
Hi ,

I have table called my_Comments , which has an column called comments which is CLOB. I  have to change the CLOB column to VARCHAR2 , Iam following the below approach to keep the column position , Below is the error Iam getting. Any help is really appreciated.

The table is stored in USER_TAB tablespace and the CLOB is stored in USER_LOB tablespace.  As of now the column comments data is stored in USER_LOB tablespace.  After changing it to VARCHAR2 , I need to move it from USER_LOB to USER_TAB tablespace.


Table Structure:

MY_COMMENTS  -- Stored in USER_TAB tablespace.
 
ID NUMBER,
TITLE VARCHAR2(4000 CHAR),
COMMENTS CLOB --> Stored in USER_LOB tablespace.
CREATED_BY NUMBER




alter table my_comments add c2 varchar2(4000);
update my_comments set c2 = DBMS_LOB.SUBSTR(comments,1,4000);
update my_comments set comments = null;
commit;
alter table my_comments modify COMMENTS LONG;
alter table t modify c clob;
update t set c = c2;
alter table t drop column c2;
commit;


Error starting at line 9 in command:
alter table my_comments modify COMMENTS LONG
Error report:
SQL Error: ORA-22859: invalid modification of columns
22859. 00000 -  "invalid modification of columns"
*Cause:    An attempt was made to modify an object, REF, VARRAY, nested
           table, or LOB column type.
*Action:   Create a new column of the desired type and copy the current
           column data to the new type using the appropriate type
           constructor.


Any help is really appreciated.
0
Comment
Question by:sam_2012
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 21

Expert Comment

by:Amitkumar Panchal
ID: 40375859
As far as I know LONG has been depricated since 8i and not recommended by oracle.

Why dont you use select..as.. and create a new table with varchar2 and then recreate every constraints, indexes and other DB objects associated with the older one. I know its difficult on when we have huge data as well as many tables. But its worth to give it a try.

Another one just add new column of varchar2, copy clob data to new column and drop the clob. But this one will change the column position which you dont want to do.
0
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 40376108
Error seem self-explanatory:  you cannot modify the CLOB column.

I think we have covered the alternative ways to do this in your previous questions that are pretty much the same question as this.

You can keep trying ways to get around it but I feel the answer will always be the same.

Just like the last questions:  dbms_redefinition is probably the way to go with the requirements you have.
0
 

Author Comment

by:sam_2012
ID: 40381373
thanks . I have used DBMS_REDEFINITION for changing the column .
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
Via a live example, show how to take different types of Oracle backups using RMAN.
This video shows how to recover a database from a user managed backup

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question