1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
8
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
10
HREF="mailto:pgsql-docs@postgresql.org"><LINK
12
TITLE="PostgreSQL 9.1beta1 Documentation"
13
HREF="index.html"><LINK
15
TITLE="ECPG - Embedded SQL in C"
16
HREF="ecpg.html"><LINK
18
TITLE="Library Functions"
19
HREF="ecpg-library.html"><LINK
21
TITLE="C++ Applications"
22
HREF="ecpg-cpp.html"><LINK
25
HREF="stylesheet.css"><META
26
HTTP-EQUIV="Content-Type"
27
CONTENT="text/html; charset=ISO-8859-1"><META
29
CONTENT="2011-04-27T21:20:33"></HEAD
35
SUMMARY="Header navigation table"
47
>PostgreSQL 9.1beta1 Documentation</A
56
TITLE="Library Functions"
57
HREF="ecpg-library.html"
66
TITLE="ECPG - Embedded SQL in C"
86
TITLE="ECPG - Embedded SQL in C"
95
TITLE="C++ Applications"
111
>33.12. Large Objects</A
114
> Large objects are not directly supported by ECPG, but ECPG
115
application can manipulate large objects through the libpq large
116
object functions, obtaining the necessary <TT
120
object by calling the <CODE
122
>ECPGget_PGconn()</CODE
124
function. (However, use of
127
>ECPGget_PGconn()</CODE
128
> function and touching
132
> objects directly should be done very carefully
133
and ideally not mixed with other ECPG database access calls.)
136
> For more details about the <CODE
138
>ECPGget_PGconn()</CODE
141
HREF="ecpg-library.html"
143
>. For information about the large
144
object function interface, see <A
145
HREF="largeobjects.html"
150
> Large object functions have to be called in a transaction block, so
151
when autocommit is off, <TT
155
be isssued explicitly.
159
HREF="ecpg-lo.html#ECPG-LO-EXAMPLE"
161
> shows an example program that
162
illustrates how to create, write, and read a large object in an
168
NAME="ECPG-LO-EXAMPLE"
172
>Example 33-2. ECPG Program Accessing Large Objects</B
175
CLASS="PROGRAMLISTING"
176
>#include <stdio.h>
177
#include <stdlib.h>
178
#include <libpq-fe.h>
179
#include <libpq/libpq-fs.h>
181
EXEC SQL WHENEVER SQLERROR STOP;
194
memset(buf, 1, buflen);
196
EXEC SQL CONNECT TO testdb AS con1;
198
conn = ECPGget_PGconn("con1");
199
printf("conn = %p\n", conn);
202
loid = lo_create(conn, 0);
204
printf("lo_create() failed: %s", PQerrorMessage(conn));
206
printf("loid = %d\n", loid);
209
fd = lo_open(conn, loid, INV_READ|INV_WRITE);
211
printf("lo_open() failed: %s", PQerrorMessage(conn));
213
printf("fd = %d\n", fd);
215
rc = lo_write(conn, fd, buf, buflen);
217
printf("lo_write() failed\n");
219
rc = lo_close(conn, fd);
221
printf("lo_close() failed: %s", PQerrorMessage(conn));
224
fd = lo_open(conn, loid, INV_READ);
226
printf("lo_open() failed: %s", PQerrorMessage(conn));
228
printf("fd = %d\n", fd);
230
rc = lo_read(conn, fd, buf2, buflen);
232
printf("lo_read() failed\n");
234
rc = lo_close(conn, fd);
236
printf("lo_close() failed: %s", PQerrorMessage(conn));
239
rc = memcmp(buf, buf2, buflen);
240
printf("memcmp() = %d\n", rc);
243
rc = lo_unlink(conn, loid);
245
printf("lo_unlink() failed: %s", PQerrorMessage(conn));
248
EXEC SQL DISCONNECT ALL;
258
SUMMARY="Footer navigation table"
269
HREF="ecpg-library.html"
297
>Library Functions</TD
b'\\ No newline at end of file'