Database Reference
In-Depth Information
for (;;)
{
n = lo_read(conn, lo_fd, buf, 1024);
if (n <= 0)
break;
r = write(fd, buf, n);
if (r < n)
{
fprintf(stderr, "write: failed to write object\n");
break;
}
}
lo_close(conn, lo_fd);
close(fd);
res = PQexec(conn, "END");
PQclear(res);
PQfinish(conn);
fprintf(stdout, "file '%s' successfully imported using
'lo_write' and then exported to '%s' using 'lo_read'\n",
FILE_TO_IMPORT, FILE_TO_EXPORT);
return lo_oid;
}
Usage of both approaches is clear from the fact that you can use
import/export when you have to access the complete ile/binary
data but read/write allows processing on selective parts of the
binary data stored as a large object.
For readers, here are the steps to build the code and content of the make ile for a
quick reference.
Use the make command to build the code in the following manner:
make imp_exp
make read_write
make clean
 
Search WWH ::




Custom Search