X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 98EEC3A3BFF for ; Tue, 23 Nov 2004 07:19:35 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 40176-02 for ; Tue, 23 Nov 2004 07:19:04 +0000 (GMT) Received: from mail.nsasia.co.th (mail.nsasia.co.th [203.146.6.34]) by svr1.postgresql.org (Postfix) with ESMTP id 870AE3A2BB0 for ; Tue, 23 Nov 2004 07:19:04 +0000 (GMT) Received: from [192.168.200.40] (helo=jupiter.nsasia.co.th) by astaro.nsasia.co.th with esmtp (Exim 4.43) id 1CWUx5-00018E-4J for pgsql-sql@postgresql.org; Tue, 23 Nov 2004 14:19:03 +0700 Received: from Thailand-MTA by jupiter.nsasia.co.th with Novell_GroupWise; Tue, 23 Nov 2004 14:18:48 +0700 Message-Id: X-Mailer: Novell GroupWise Internet Agent 6.5.2 Date: Tue, 23 Nov 2004 14:18:00 +0700 From: "Premsun Choltanwanich" To: , , Subject: Re: Image Insert Postgresql DB Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/243 X-Sequence-Number: 19562 I face this same problem when I try to insert image by lo_import to database with my client files. I already change the way to bytea data type but it's not work. The error return like type mismatch when I try to insert it from Binary variable. Why I cannot insert it? If anybody found some solution please reply on this topic for me too. Thank You. >>> Kenneth Gonsalves 23/11/2004 12:18:44 pm >>> On Tuesday 23 November 2004 09:51 am, sreejith s wrote: > Query to insert > ---------------- > INSERT INTO Imagetable VALUES (lo_import('C:\\image\\peach.jpg')); have you succeeded in inserting an image into the database from a file on the server using the above query? AFAIK you need a bytea datatype, and also the image data has to be properly escaped (\\) before pg will accept it. I assume you are using a scripting language with a dbapi. Your steps would be: 1. read the image file into a variable 2. escape the image data 3. insert this into the database in a bytea field if you follow this procedure it is irrelevant as to where the source file is - client or server regards kg ---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives? http://archives.postgresql.org