Solved

How do you convert LONG to CLOB?

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

A short article about problems I had with the new location API and permissions in Marshmallow
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

785 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