import large objects with libpq
От | Laurent |
---|---|
Тема | import large objects with libpq |
Дата | |
Msg-id | 3A9FAE62.1FE3184B@presenceweb.com обсуждение исходный текст |
Список | pgsql-interfaces |
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.
В списке pgsql-interfaces по дате отправления: