Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id AEEB79FC5E6 for ; Thu, 12 Apr 2007 01:34:37 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 48887-03-8 for ; Thu, 12 Apr 2007 01:34:29 -0300 (ADT) X-Greylist: delayed 01:15:51.478628 by SQLgrey-1.7.4 Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 69AD39FC650 for ; Thu, 12 Apr 2007 01:19:57 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from boston.agmednet.com (boston.agmednet.com [74.92.47.82]) by svr4.postgresql.org (Postfix) with ESMTP id A47495B1465 for ; Wed, 11 Apr 2007 13:40:16 +0000 (GMT) Received: from 74.92.47.81 ([74.92.47.81]) by agmednet-dc.boston.agmednet.local ([192.168.67.2]) with Microsoft Exchange Server HTTP-DAV ; Wed, 11 Apr 2007 13:30:06 +0000 Received: from mgoldner-desktop by boston.agmednet.com; 11 Apr 2007 09:40:13 -0400 Subject: Re: Bytea question From: Mike Goldner To: "pgsql-admin@postgresql.org" Cc: Chris Hoover In-Reply-To: <20070411132258.GF4896@alvh.no-ip.org> References: <1d219a6f0704110602n5b9fe58dy34e05008b9bff0be@mail.gmail.com> <20070411130904.GD4896@alvh.no-ip.org> <1d219a6f0704110617y31780a75q8f783893acb6ef07@mail.gmail.com> <20070411132258.GF4896@alvh.no-ip.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Organization: AG Mednet, Inc. Date: Wed, 11 Apr 2007 09:40:13 -0400 Message-Id: <1176298813.1169.11.camel@mgoldner-desktop> Mime-Version: 1.0 X-Mailer: Evolution 2.8.1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.637 tagged_above=0 required=5 tests=BAYES_50=0.001, FORGED_RCVD_HELO=0.135, RCVD_NUMERIC_HELO=1.5, UNPARSEABLE_RELAY=0.001 X-Spam-Level: * X-Archive-Number: 200704/113 X-Sequence-Number: 25177 It sounds like you want to parse the contents of the bytea column within a trigger/stored procedure. I haven't done this myself (I process the bytea data in java as an input stream after retrieving it from postgres), but you could probably use a FOR loop over the bytea column and then use some combination of the Binary String Functions (http://www.postgresql.org/docs/current/static/functions-binarystring.html)= to process the file data. Mike On Wed, 2007-04-11 at 09:22 -0400, Alvaro Herrera wrote: > Chris Hoover escribi=C3=B3: > > No, I need to store the entire file as received into the database. >=20 > Then you original question does not make any sense to me, because if you > pass the entire file content, why would Postgres *not* be able to read > it? >=20 >=20 > > On 4/11/07, Alvaro Herrera wrote: > > > > > >Chris Hoover escribi=C3=B3: > > >> Hopefully a quick question. > > >> > > >> If I store a file into a bytea field, is there anyway for postgres t= o > > >read > > >> the contents of the file? > > > > > >When you say "store a file", do you mean "store a filename"? > > > > > >> Here is my scenario: > > >> > > >> Receive text file > > >> insert file into bytea field > > >> insert trigger fires > > >> - read file contents > > >> - post contents into production tables > > >> > > >> Is this at all possible, or am I going to need to store the original > > >file > > >> and store/pass the file contents? >=20