Received: from presence1.observatoiredesmarques.fr (presence1.observatoiredesmarques.fr [212.73.199.68]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f22ETUx19310; Fri, 2 Mar 2001 09:29:30 -0500 (EST) (envelope-from laurent@presenceweb.com) Received: from presenceweb.com (gatei.observatoiredesmarques.fr [213.56.32.22]) by presence1.observatoiredesmarques.fr (8.9.1/_ODM_070798) with ESMTP id OAA15034; Fri, 2 Mar 2001 14:28:46 GMT Message-ID: <3A9FAE62.1FE3184B@presenceweb.com> Date: Fri, 02 Mar 2001 15:29:54 +0100 From: Laurent X-Mailer: Mozilla 4.7 [fr] (Win98; I) X-Accept-Language: fr,en MIME-Version: 1.0 To: pgsql-interfaces@postgresql.org, "pgsql-general@postgresql.org" Subject: import large objects with libpq Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200103/84 X-Sequence-Number: 5547 I need to store a blob in a database. I use libpq - C Library I read theses urls http://www.postgresql.org/devel-corner/docs/postgres/lo-interfaces.html http://www.postgresql.org/devel-corner/docs/postgres/lo-sample.html I understand that there are two possibilities The first possibility is - creat blob with lo_creat - open it with lo_open - read my file with any C function and write data to the blob with lo_write - then close the blob with lo_close The second seems more easier - import the file to blob with lo_import After connection, I try to use lobjOid = lo_import(conn, "myfile.doc") ; but this command fails and returns "lo_import: could not open inv object oid 561441" I don't know what can i resolve this pb. So I try the other possibility. I copied importFile function from lo-sample.html. Then I call it with lobjOid = importFile(conn, in_filename); The creation of the bloc is successfull with lobjId = lo_creat(conn, INV_READ | INV_WRITE); but the open of the bloc fails with lobj_fd = lo_open(conn, lobjId, INV_WRITE); I get the message : lo_lseek: invalid large obj descriptor (0) I'm a bite disappointed, I beg you help. I 'm looking forward to hearing you.