Database Reference
In-Depth Information
/* Execute the command BEGIN */
res = PQexec(conn, "BEGIN");
PQclear(res);
/* Import file to the database */
lo_oid = lo_import(conn, FILE_TO_IMPORT);
if (lo_oid < 0)
{
fprintf(stderr, "%s\n", PQerrorMessage(conn));
PQfinish(conn);
return -1;
}
res = PQexec(conn, "END");
PQclear(res);
res = PQexec(conn, "BEGIN");
PQclear(res);
if (lo_export(conn, lo_oid, FILE_TO_EXPORT) < 0)
{
fprintf(stderr, "%s\n", PQerrorMessage(conn));
PQfinish(conn);
return -1;
}
res = PQexec(conn, "END");
PQclear(res);
PQfinish(conn);
fprintf(stdout, "file '%s' successful imported using 'lo_import'
and then exported to '%s' using 'imp_export'\n", FILE_TO_IMPORT,
FILE_TO_EXPORT);
return lo_oid;
}
lo_open
The lo_open function is used to open a large object for reading or writing.
The syntax for the lo_open function is as follows:
int lo_open(PGconn *conn, Oid lobjId, int mode);
 
Search WWH ::




Custom Search