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

Home -> Community -> Usenet -> c.d.o.server -> Re: Inserting into a Long Datatype

Re: Inserting into a Long Datatype

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Thu, 16 Jul 1998 22:16:16 GMT
Message-ID: <35b47ba1.29141793@192.86.155.100>


A copy of this was sent to Howard Chen <hchen_at_uswebla.com> (if that email address didn't require changing) On Thu, 16 Jul 1998 13:42:29 -0700, you wrote:

>I am trying to insert text into a Long datatype, but I get this error.
>
>ORA-01704: string literal too long
>
>Upon initial inspection, it appears that I need to buffer in the data.
>What functions or packages should I use to insert data into a Long
>datatype? Examples would be greatly appreciated. Thanks in advance.

what language are you using to get stuff in? you need to use bind variables for larger strings instead of character string constants.

One method in SQL plus and other tools that can run plsql that works upto 32k is as such:

drop table demo;
create table demo ( x long );

declare

    myvar long default '

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
(lots of stuff here)......
';
begin

   insert into demo values ( myvar );
   dbms_output.put_line( length( myvar ) ); end;

The pl/sql variable can be initialized to upto 32k of static text. It can then be inserted into the table (it is a bind variable, not a constant at that point).

For example, I just ran it and it showed me:

Table dropped.

Table created.

24726

PL/SQL procedure successfully completed.

So, that put a 24,726 character string into the table...  

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA  

http://govt.us.oracle.com/ -- downloadable utilities  



Opinions are mine and do not necessarily reflect those of Oracle Corporation  

Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Thu Jul 16 1998 - 17:16:16 CDT

Original text of this message

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