Question

Asked on 2004-09-21 at 08:31:40ID: 25476525

Converting LONG to CLOB

by: smena400

Rating7.8Very Good

I have two tables with data type Long.
Since LONG data type can't be used for search I need to make a conversion  to CLOB.
What I woulld like to do is to have a dynamic sql  where I can specify table names, fields, and output table with fields.

For instance,
using two input tables:
CREATE TABLE table_input_1
(
  table_key_1  NUMBER,
  table_value_1 LONG
)

CREATE TABLE table_input_2
(
  table_key_2  NUMBER,
  table_value_2 LONG
)

I need a procedure or package
create or replace
convert_table_data_p(table_input_1  in varchar2, table_key_1   in varchar2,  table_value_1 in varchar2,
                                table_input_2  in varchar2, table_key_2   in varchar2,  table_value_2 in varchar2,
                                table_output   in varchar2, table_key_ou in varchar2,  table_value_o in varchar2)


This procedure should have dynamic sql that :
1. creates table
CREATE TABLE table_output
(
  table_key_ou  NUMBER,
  table_value_o  CLOB
)

2. inserts and converts data from both input tables into table_output
using cursor
SELECT table_key_1,  table_value_1, table_value_2
from table_input_1, table_input_2
where
table_key_1, = table_key_2(+);

INSERT INTO table_output values (table_key_1,  (table_value_1||table_value_2)



  1. How do you change your whole Oracle Databas…
    How do you change your whole Oracle Database datatype from LONG to CLOB? Upgrading Oracle 8i to Oracle 10g. I heard Long tyoe will not longer be used in later versions of Oracle. How do I change the whole database from Long to Clobor BLOB without having to create each table? If this is not possible would we have to convert every single t…
  2. converting long to clob
    I need to add a new column CLOB to the existing table that already has LONG data type and update this column with LONG data. update test set col_clob = to_lob(col_long) <---- doesn't work I know that I can use "TO_LOB" function with INSERT/SELECT, but I neewd to create new table such as ... CREA…
  3. replacing long with clob
    I found that some of our applications use LONG datatype. Reading number of articles and responses I found that LONG becomes obsolete and Oracle recommends using CLOB and BLOB. Can someone summarize and advise the best way for data conversion from LONG to CLOB where field should be used for: 1. search 2.display in forms (partial v…
  4. Is it possible to Convert a LONG-type column int…
    I have a table containing a column of type long, can I select it in SQL and convert it into Varchar2? TABLE Definnition: Create TAble TEST ( FIELD01 VARCHAR2(10), FIELD02 VARCHAR2(10), FIELD03 LONG ) I need to have FIELD03 as Varchar2 in a select statement!
  5. CLOB to VARCHAR2 Manipulation !!!
    I am copying data from one table to another. My requirement is to be able to get some text out of a CLOB field and load it into a VARCHAR2 field in another table. However, my VARCHAR2 field has a maximum length of 255 characters and so if the CLOB exceeds this value I need to create a new row and insert the next 255 characters. I need …

Solution

Sign up now to view this solution! It's quick, easy, and secure to subscribe. We will return you to this solution, unlocked, when you’re done.

About this Solution
View This Solution - Start Your 30 Day Free Trial
Zone
General
Tags
clob from select
Participating Experts
3
Solution Grade
B

Replies

 by: konektor

Posted on 2004-09-21 at 08:48:09ID: 28337242

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: smena

Posted on 2004-09-21 at 13:44:21ID: 28337243

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: BobMc

Posted on 2004-09-21 at 14:06:44ID: 28337244

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by:

Posted on 2004-09-22 at 07:26:12ID: 28337245

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

Stay Connected

Oracle Around the Web

The latest Oracle news, tips, and tricks

Oracle Unveils Netra SPARC T3 Servers

New Carrier-Grade Blade and Rackmount Servers Deliver Better Performance, Density and Power Efficiency for the Communications Industry ...

read more

Oracle fixes 21 flaws in Java SE, Java for Business

Oracle is fixing 21 flaws in its Java SE and Java for Business products in its February critical patch update issued this week ...

read more

Obama’s Silicon Valley “Tech Supper”

Why was he there? Who wasn’t invited and why? What did they talk about? Why was he really there? These are the questions being debated ...

read more

Featured Oracle Experts

slightwv

slightwv has answered more than 2,000 Oracle questions and oversees database management within the U.S. Government. Slightwv

sdstuber

A regular presenter at the Collaborate conference, Oracle developer sdstuber is a top expert in PL/SQL and Oracle 9, 10 and 11. sdstuber

Testimonials

What users are saying about our experts

"The Oracle gurus provide answers, solutions and valuable workarounds"

User: schwertner

"Wow! Excellent, valuable explanation. Hats off to you"

User: aseshu70

"Solution worked fantastic and performs excellent! Thanks heaps"

User: klausbrandlhuber

Top Experts

  1. slightwv

    2,000

    0 points yesterday

    Profile

BrowseBecome an Expert