Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Data conversion question: LONG to VARCHAR
In article <384D9586.572BDB67_at_dallas.net>,
Steve Batzer <sbatzer_at_dallas.net> wrote:
> Hi all, I'm looking for a way to convert data stored as a LONG (turns
> out to be description text) into a VARCHAR. I was trying to find a
way
> to do a text search on the LONG, but haven't been successful. So, the
> next best thing is to convert the LONG to VARCHAR that I could search
> on.
>
> Any ideas about doing the conversion? Or, is there a way to do a text
> search on a LONG attribute?
>
> Thanks!
>
Steve, you can retrieve (fetch) long columns into varchar variables in
pl/sql providing the length of the long does not exceed 32K. For most
applications this will allow accessing all the data.
Here is some sample code that read the old reportwriter 1.1 tables and checked the contents a long column to see if it contained a to_date function (Y2K stuff).
set serveroutput on
declare
v_owner system.srw__query.owner%type ; v_appid system.srw__query.appid%type ; v_itemid system.srw__query.itemid%type ; v_query varchar2(32767) ; <== hold long v_short varchar2(2000) ; v_report_name system.srw__report.report_name%type ;--
open srwr ; fetch srwr into v_report_name ; close srwr ; v_query := replace(v_query,chr(10),chr(32)) ; v_query := replace(v_query,' ',chr(32)) ; v_query := replace(v_query,' ',chr(32)) ; v_query := replace(v_query,' ',chr(32)) ; v_short := substr(v_query,1,2000) ; insert into srw_todate values <== work table I created ( v_owner, v_report_name, v_appid, v_short) ; -- dbms_output.put_line('Owner = '||v_owner||' appid = '|| -- v_appid||' v_itemid = '||v_itemid ) ; -- dbms_output.put_line(v_short); end if ; end loop ; close srwq ; commit ; end ;
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Wed Dec 08 1999 - 08:23:06 CST
![]() |
![]() |