A guy named David Hunt gives a tip about this:
http://www.dba-oracle.com/t_select_long ... mn_sql.htm Select all
REM **********************************************************
REM Author: David Hunt
REM Date Created: July 18, 2007
REM Purpose: Creates function that returns contents of
REM PART_COMNT:COMNT_TXT. (a LONG field)
REM Warning: if the contents of COMNT_TXT exceed 32767 chrs, then
REM none of the data from that row's LONG RETURN;
REM an error message results.
REM **********************************************************
create or replace function Get_Comnt_txt
(RowID_of_Long in rowid)
return varchar2
is
Long_to_Varchar varchar(32767);
begin
select comnt_txt into Long_to_Varchar
from part_comnt
where rowid = rowid_of_long;
return long_to_varchar;
exception
when others then
return 'Error occurred on rowid: '||rowid_of_long;
end; /
select replace(get_Comnt_txt(rowid),chr(10),null)comnt_txt
from part_comnt;
COMNT_TXT
----------------------------------------------------------------
This is short text in a LONG column.
This is row 2; a <carriage return> is here ->This is row 2; a <carriage return> is here ->This is row 2; a <carriage return> is here ->
Select all
create table rv_test (a number, b long)
/
insert into rv_test values (1, 'asdfjasraghavkjasdfdsafqafl;kasdfnbdsamnbfdasraghavasdfl')
/
insert into rv_test values (2, 'asdfjasdf;lkjadsflkjdasf;lkjasdflkjdsafl;kasdfnbdsamnbfdasraghavasdflkjasdf')
/
insert into rv_test values (3, & #39;asdfjasdf;lasdfa192387sfdsflkjdasf;lkjasdfdsafq3lkjdsafl;kasdfnbdsamnbfdasra
ghavasdflraghav')
/
commit
-- ************************
create or replace type rv_test_type as object(a number, b clob);
/
create or replace type rv_test_table as table of rv_test_type;
/
create or replace function rv_test_search(x varchar2)
return rv_test_table pipelined is
r rv_test_type;
begin
for f in (select * from rv_test) loop
if (f.b like x) then
r:= rv_test_type(f.a,f.b);
pipe row(r);
end if;
end loop;
end;
/
select a from table(rv_test_search('%raghav%'));
Some important things About Long. (restrictions).
He Use Long Values ??Is Subject to Same
Restrictions:
The Table Cannot Contain More Than One Long Column.
You cannot CREATE AN OBJECT TYPE WITH A LONG Attribute.
Long Columns Cannot Appear in Integrity Constraints (Exceed for NULL AND NOT
NULL CONFRAINTS).
Long columns cannot be indexed.
The STORED FUNCTION CANNOT RETURN A LONG VALUE.
Within Single SQL Statement, All Long Columns, Updated Tables, and Locked
Tables Must Be Located on the Same Database.
Long Columns Cannot Appear in Certain Parts of SQL Statements:
Where Clauses, Group By Clauses, Order by Clauses, Or Connect by Clauses Or
With the distinct Operator in Select Statements
The Unique Operator of a Select Statement
The Column List of a CREATE Cluster Statement
The Cluster Clause of A Create Materialized View Statement
SQL FUNCTIONS (Such Substr or instr)
Expressions or Conditions
Select Lists of Queries Containing Group by Clauses
Select Lists Of Subcuries or Queries Combined By Set Operators
Select Lists of CREATE TABLE ... The Select Statements
Select Lists in Insert Statements
Triggers Can Use The Long Datatype in the Following Manner:
SQL Statement Within A Trigger Can Insert Data Into Long Column.
IF Data from A Long Column Can Be Converted to Constrained Datatype (Such
The Char and Varchar2), the Long Column Can Be Referenced In A SQL Statement
Within to Trigger.
Variables in Triggers Cannot Be Declared Using The Long Datatype.
: NEW AND: OLD CANNOT BE USED WITH LONG Columns.
However You Can Use The Oracle Call Interface Functions to retrieve A
Portion of a Value from the database.
Long still exists for Keep compatibility only. Whenever possible, use Clob fields, blob, etc ...