pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurent <laurent@presenceweb.com>
To: pgsql-interfaces@postgresql.org, "pgsql-general@postgresql.org" <pgsql-general@postgresql.org>
Subject: import large objects with libpq
Date: Fri, 02 Mar 2001 15:29:54 +0100
Message-ID: <3A9FAE62.1FE3184B@presenceweb.com> (raw)

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.











Message-ID: <3A9FAE62.1FE3184B@presenceweb.com>
Permalink:  ../3A9FAE62.1FE3184B@presenceweb.com/
Also on:    postgresql.org/message-id/3A9FAE62.1FE3184B@presenceweb.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: laurent@presenceweb.com, pgsql-general@postgresql.org
  Subject: Re: import large objects with libpq
  In-Reply-To: <3A9FAE62.1FE3184B@presenceweb.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox