Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: How do I copy LONG columns between tables?

Re: How do I copy LONG columns between tables?

From: Andrew Velichko <andrew_velichko_at_yahoo.com>
Date: Sun, 26 Nov 2000 17:55:52 -0500
Message-ID: <BygU5.71639$Z2.972211@nnrp1.uunet.ca>

Hi!

Here is the test case:
CREATE TABLE t1 ( id INTEGER, long_item long); CREATE TABLE t2 ( id INTEGER, long_item long); insert into t1 values (1,'asdf');

The following pl/sql block copies data:
declare
i number;
l long;
begin
select id, long_item into i, l from t1;
insert into t2 values (i,l);
end;
/

But, it's under Oralcle8i.

Hope this will help.

Andrew Velichko
Brainbench MVP for Oracle Developer 2000 http://www.brainbench.com


"Stefan Larsson" <d95stela+news_at_dtek.chalmers.se> wrote in message news:slrn91t2u2.cm9.d95stela+news_at_licia.dtek.chalmers.se...
> Fri, 24 Nov 2000 14:28:57 GMT, offroadbiker_at_hotmail.com (Darren M.) ->
> >Stefan,
> >
> >You can use varchar2 if the data in the long field will be less than 2000
> >characters. (On Oracle 8, you can go to 4000 char.)
>
> I wanted to use LONG as varchar2 without the limit on string length.
> I was kind of hoping that varchar2 and long would be equivalent except
> for performance... I was mistaken, it seems.
>
> >I have also done something like this in the past to copy long columns
> >between tables. I haven't written pl/sql for a while, so I've put
 comments
> >where I forget the syntax:
> >
> ... [pl/sql code]
>
> PL/SQL will still not let me declare or use LONG variables and columns
>
> I think
> INSERT INTO [table2]
> SELECT ... FROM [table1]
>
> is equivalent to your PL/SQL-code. Am I correct? Or are there differences
> between SQL inserts and PL/SQL inserts?
>
> I rewrote the tables like
> CREATE TABLE Elements(
> id_ INTEGER,
> pos_ INTEGER,
> elt_ VARCHAR2(2000)
> )
>
> and then I split the string into 2000 bytes chunks... a bit clumsy, I
> think. It would have been much cleaner to be able to use LONG columns.
>
> /stefan
Received on Sun Nov 26 2000 - 16:55:52 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US