Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: long to varchar2
On Wed, 22 Sep 1999 16:44:47 -0700, Breno Gomes
<brenogomesNOmeSPAM_at_computer.org> wrote:
>I successfully performed migration from FoxPro 2.5 files to
>Oracle 8.0.4.0.0.
>
>Fox memo fields were converted to long. All data are plain
>text, with 500 characters or less, due 254 fox limits.
>
>In the new application it would better to use Varchar2
>(1000) instead Long. How could I read data from long and
>write to Varchar2 ?
You can use pl/sql
begin
for c in ( select * from <old_table_with_long> ) loop
insert into <new_table_with_varchar2(1000)>
( col1, col2, col3, col4 )
values
( c.old_col1, c.old_col2, c.old_col3, c.old_col4 );
end loop;
end;
/
eg.
SQL> desc foo
Name Null? Type ----------------------------------------- -------- ---------------------------- ID NUMBER L LONG SQL> desc bar Name Null? Type ----------------------------------------- -------- ---------------------------- ID NUMBER V VARCHAR2(1000)
SQL> select * from foo;
ID L
---------- ------------------------------------------------------------ 2 Another long value 1 A long value
SQL> select * from bar;
no rows selected
SQL> insert into bar select * from foo; insert into bar select * from foo
*
SQL> select * from bar;
no rows selected
SQL> begin
2 for c in ( select * from foo ) loop
3 insert into bar ( id, v ) 4 values ( c.id, c.l );
SQL> select * from bar;
ID V
---------- ------------------------------------------------------------ 2 Another long value 1 A long value
hope this helps.
chris.
>
>I appreciate your suggestions.
>
>Thanks in advance.
>
>brenogomes_at_ieee.org
>
>* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
>The fastest and easiest way to search and participate in Usenet - Free!
--
Christopher Beck
Oracle Corporation
clbeck_at_us.oracle.com
Reston, VA.
![]() |
![]() |