Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b2aade0

Browse files
committed
Improve libpgeasy API for multiple result sets, add example.
1 parent e7db8fa commit b2aade0

File tree

3 files changed

+154
-120
lines changed

3 files changed

+154
-120
lines changed

doc/src/sgml/libpgeasy.sgml

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/libpgeasy.sgml,v 2.8 2002/01/07 02:29:12 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/libpgeasy.sgml,v 2.9 2002/03/04 18:50:20 momjian Exp $
33
-->
44

55
<chapter id="pgeasy">
@@ -11,21 +11,20 @@ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/libpgeasy.sgml,v 2.8 2002/01/07 02:29
1111
<para>
1212
Written by Bruce Momjian
1313
(<email>pgman@candle.pha.pa.us</email>)
14-
and last updated 2000-03-30
14+
and last updated 2002-03-04
1515
</para>
1616
</note>
1717

1818
<para>
1919
<application>pgeasy</application> allows you to cleanly interface
2020
to the <application>libpq</application> library, more like a 4GL
2121
SQL interface. Refer to <xref linkend="libpq"> for more
22-
information about <application>libpq</application>
22+
information about <application>libpq</application>.
2323
</para>
2424

2525
<para>
26-
It consists of set of simplified C functions that encapsulate the
27-
functionality of <application>libpq</application>.
28-
The functions are:
26+
It consists of a set of simplified C functions that encapsulate the
27+
functionality of <application>libpq</application>. The functions are:
2928

3029
<itemizedlist>
3130
<listitem>
@@ -88,53 +87,50 @@ void set_result(PGresult *newres);
8887
</synopsis>
8988
</listitem>
9089

91-
<listitem>
92-
<synopsis>
93-
void unset_result(PGresult *oldres);
94-
</synopsis>
95-
</listitem>
9690
</itemizedlist>
9791
</para>
9892

9993
<para>
100-
Many functions return a structure or value, so you can do more work
94+
Many functions return a structure or value, so you can work
10195
with the result if required.
10296
</para>
10397

10498
<para>
105-
You basically connect to the database with <function>connectdb</function>,
106-
issue your query with <function>doquery</function>,
107-
fetch the results with <function>fetch</function>,
108-
and finish with <function>disconnectdb</function>.
99+
You basically connect to the database with
100+
<function>connectdb</function>, issue your query with
101+
<function>doquery</function>, fetch the results with
102+
<function>fetch</function>, and finish with
103+
<function>disconnectdb</function>.
109104
</para>
110105

111106
<para>
112107
For <literal>SELECT</literal> queries, <function>fetch</function>
113-
allows you to pass pointers as parameters, and on return the variables
114-
are filled with data from the binary cursor you opened. These binary
115-
cursors cannot be used if you are running the
116-
<application>pgeasy</application>
117-
client on a system with a different architecture than the database
118-
server. If you pass a NULL pointer parameter, the column is skipped.
119-
<function>fetchwithnulls</function> allows you to retrieve the NULL
120-
status of the field by passing an <literal>int*</literal>
121-
after each result pointer, which returns true or false if the field is null.
122-
You can always use <application>libpq</application> functions on the <structname>PGresult</structname> pointer returned
123-
by <function>doquery</function>.
124-
<function>reset_fetch</function> starts the fetch back at the beginning.
108+
allows you to pass pointers as parameters, and on return the
109+
variables are filled with data from the binary cursor you opened.
110+
These binary cursors cannot be used if you are running the
111+
<application>pgeasy</application> client on a system with a different
112+
architecture than the database server. If you pass a NULL pointer
113+
parameter, the column is skipped. <function>fetchwithnulls</function>
114+
allows you to retrieve the NULL status of the field by passing an
115+
<literal>int*</literal> after each result pointer, which returns true
116+
or false to indicate if the field is null. You can always use
117+
<application>libpq</application> functions on the
118+
<structname>PGresult</structname> pointer returned by
119+
<function>doquery</function>. <function>reset_fetch</function> starts
120+
the fetch back at the beginning.
125121
</para>
126122

127123
<para>
128-
<function>get_result</function>,
129-
<function>set_result</function>,
130-
and
131-
<function>unset_result</function>
132-
allow you to handle multiple result sets at the same time.
124+
<function>get_result</function> and <function>set_result</function>
125+
allow you to handle multiple open result sets. Use
126+
<function>get_result</function> to save a result into an application
127+
variable. You can then later use <function>set_result</function> to
128+
return to the previously save result.
133129
</para>
134130

135131
<para>
136-
There are several demonstration programs in the
137-
source directory.
132+
There are several demonstration programs in
133+
<filename>pgsql/src/interfaces/libpgeasy/examples</>.
138134
</para>
139135
</chapter>
140136

src/interfaces/libpgeasy/examples/Makefile

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,17 @@
44
# Makefile for pgeasy examples
55
#
66
# IDENTIFICATION
7-
# $Header: /cvsroot/pgsql/src/interfaces/libpgeasy/examples/Attic/Makefile,v 1.2 2000/05/18 14:24:37 momjian Exp $
7+
# $Header: /cvsroot/pgsql/src/interfaces/libpgeasy/examples/Attic/Makefile,v 1.3 2002/03/04 18:50:21 momjian Exp $
88
#
99
#-------------------------------------------------------------------------
1010

1111
CFLAGS=-I/usr/local/pgsql/include
12-
TARGET = pginsert pgwordcount pgnulltest
12+
TARGET = pginsert pgwordcount pgnulltest pgmultiresult
1313
LDFLAGS = -L/usr/local/pgsql/lib -lpgeasy
1414

1515
all : $(TARGET)
1616

17-
pginsert:
18-
gcc -o $@ $(CFLAGS) $@.c $(PGEASY) $(LDFLAGS)
19-
20-
pgwordcount:
21-
gcc -o $@ $(CFLAGS) $@.c $(PGEASY) $(LDFLAGS)
22-
23-
pgnulltest:
17+
%: %.c
2418
gcc -o $@ $(CFLAGS) $@.c $(PGEASY) $(LDFLAGS)
2519

2620
clean:

0 commit comments

Comments
 (0)