Solved

How do you convert LONG to CLOB?

Posted on 2001-06-13
3
248 Views
Last Modified: 2010-04-17
How can you convert a LONG value to CLOB using PL/SQL?
0
Comment
Question by:Garnet99
[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
 

Accepted Solution

by:
djmartin earned 4 total points
ID: 6194324
Try the following.

Complete the following steps to copy data from a LONG column to a LOB column:

1. Create a new table with the same definition as the table that contains the LONG column, but use a LOB datatype in place of the LONG datatype.

For example, suppose you have a table with the following definition:

CREATE TABLE long_tab (
    id NUMBER,
    long_col LONG);

Create a new table using the following SQL statement:

CREATE TABLE lob_tab (
    id NUMBER,
    clob_col CLOB);

--------------------------------------------------------------------------------
Note:
When you create the new table, make sure you preserve the table's schema, including integrity constraints, triggers, grants, and indexes. The TO_LOB function only copies data; it does not preserve the table's schema.  
--------------------------------------------------------------------------------

Issue an INSERT statement using the TO_LOB function to insert the data from the table with the LONG datatype into the table with the LOB datatype.

For example, issue the following SQL statement:

INSERT INTO lob_tab
    SELECT id,
    TO_LOB(long_col)
    FROM long_tab;

When you are certain that the copy was successful, drop the table with the LONG column.

For example, issue the following SQL statement to drop the LONG_TAB table:

DROP TABLE long_tab;

Create a synonym for the new table using the name of the table with LONG data. The synonym ensures that your database and applications continue to function properly.

For example, issue the following SQL statement:

CREATE SYNONYM long_tab FOR lob_tab;

Once the copy is complete, any applications that use the table must be modified to use the LOB data.

David
0
 
LVL 54

Expert Comment

by:nico5038
ID: 7466805

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
 - Answered by: djmartin  
Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

Nic;o)
0
 

Expert Comment

by:modulo
ID: 7505204
Finalized as proposed

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Progress
Introduction to Processes

691 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