Received: from bjke.com (firewall-user@ganymede.bjke.com [144.210.8.38]) by hub.org (8.9.2/8.9.1) with ESMTP id NAA09795 for ; Fri, 19 Feb 1999 13:30:54 -0500 (EST) (envelope-from djackson@cpsgroup.com) Received: by bjke.com; id MAA14860; Fri, 19 Feb 1999 12:30:52 -0600 (CST) Received: from cpsmail.cpsgroup.com(144.210.12.11) by gauntlet.bjke.com via smap (4.1) id xmaa14612; Fri, 19 Feb 99 12:30:41 -0600 Received: by cpsmail with Internet Mail Service (5.0.1458.49) id ; Fri, 19 Feb 1999 12:33:22 -0600 Message-ID: From: "Jackson, DeJuan" To: Frank Barknecht , pgsql-sql Subject: RE: [SQL] Insert a long text Date: Fri, 19 Feb 1999 12:33:19 -0600 X-Priority: 3 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.0.1458.49) Content-Type: text/plain > -----Original Message----- > Anatoly K. Lasareff hat gesagt: // Anatoly K. Lasareff wrote: > > > >>>>> "BB" == Brian Baquiran writes: > > > > >> I want to insert a long text (up to 10.000 words) into a table > > >> (for example, table1) into a field (field1) which is a 'text' > > >> field. I have tried the followings: INSERT INTO table1 VALUES (' > > >> long text'...) UPDATE table1 SET field1='long text' and is not > > >> working. I'm using servlets and Apache server, on Linux. > > > > BB> What data type are you using for the text field? As far as I > > BB> know, the 'text' datatype can only take 8K. > > > > BB> I don't know what the maximum size for varchar is. > > > > 8K is maximum length of whole record. In your case you must > use 'large > > objects' as datatype for big text. > > How does one do this, preferably with perl and DBI? > > What is the best way to handle big (>= 8k) text fields? It > would be nice if > postgres could have an easy interface for larger text sizes > or a set of > example functions to deal with such chunks. > > A connected question of mine is: > I have played with the data types text and varchar to store > some text from a > webbrowser with a perl-DBI cgi script. > The table has one INT field called "id" and one text field > where I tested > the types: text, varchar, varchar(2000) and varchar(7000). > Inserting text only works if the text is a lot smaller than > 8k - only about > 20 lines of text get inserted without beeing cropped. > How can I assert that the whole text gets inserted and how can I get a > message/error if the text did not fit or has been shortend? > Has anybody an > example script or perl code snippet with text fields roughly > 2000-4000 bytes > long? > This problem annoys me for some weeks now so I think I am an idiot and > Postgres proves it... > > Any help would be great and maybe let me sleep better ;) If you need to search the text possible solutions: 1) store the text in chunks in the database. in other words instead of just using CREATE TABLE my_text(message_id INT, data TEXT) try CREATE TABLE my_text(message_id INT, chunk_id INT, data TEXT); then figure out what your insert limit is and break each TEXT block into chunks of that size. 2) use a full-text-index algorithm (great for searches, but a space hog). not mutually exclusive from option 1 above, but there are implementations that could make option 1 unnecessary if you know that you'll never have a text block greater than a certain size. Look in the contrib directory of the distribution for a working sample/example. If you don't care about searching: 3) use large objects There are also examples of this in the contrib directory. This option could be combined with option 2 to implement searching, but I wouldn't want to have to change the implementations to support it. Hope this helps, -DEJ