summaryrefslogtreecommitdiff
path: root/doc/src/sgml/libpgeasy.sgml
blob: 7a177c0dce3e9a196305f79041d75706018fe57f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/libpgeasy.sgml,v 2.6 2001/09/10 21:58:46 petere Exp $
-->

 <chapter id="pgeasy-chapter">
  <title id="pgeasy"><application>libpgeasy</application> - Simplified C Library</title>

  <note>
   <title>Author</title>

   <para>
    Written by Bruce Momjian
    (<email>pgman@candle.pha.pa.us</email>)
    and last updated 2000-03-30
   </para>
  </note>

  <para>
   <productname>pgeasy</productname> allows you to cleanly interface
   to the <productname>libpq</productname> library,
   more like a 4GL SQL interface.
  </para>

  <para>
   It consists of set of simplified C functions that encapsulate the
   functionality of <application>libpq</application>.
   The functions are:

   <itemizedlist>
    <listitem>
<synopsis>
PGresult   *doquery(char *query);
</synopsis>
    </listitem>

    <listitem>
<synopsis>
PGconn     *connectdb(char *options);
</synopsis>
    </listitem>

    <listitem>
<synopsis>
void        disconnectdb();
</synopsis>
    </listitem>

    <listitem>
<synopsis>
int         fetch(void *param,...);
</synopsis>
    </listitem>

    <listitem>
<synopsis>
int         fetchwithnulls(void *param,...);
</synopsis>
    </listitem>

    <listitem>
<synopsis>
void        reset_fetch();
</synopsis>
    </listitem>

    <listitem>
<synopsis>
void        on_error_continue();
</synopsis>
    </listitem>

    <listitem>
<synopsis>
void        on_error_stop();
</synopsis>
    </listitem>

    <listitem>
<synopsis>
PGresult   *get_result();
</synopsis>
    </listitem>

    <listitem>
<synopsis>
void        set_result(PGresult *newres);
</synopsis>
    </listitem>

    <listitem>
<synopsis>
void        unset_result(PGresult *oldres);
</synopsis>
    </listitem>
   </itemizedlist>
  </para>

  <para>
   Many functions return a structure or value, so you can do more work
   with the result if required.
  </para>

  <para>
   You basically connect to the database with <function>connectdb</function>,
   issue your query with <function>doquery</function>,
   fetch the results with <function>fetch</function>,
   and finish with <function>disconnectdb</function>.
  </para>

  <para>
   For <literal>SELECT</literal> queries, <function>fetch</function>
   allows you to pass pointers as parameters, and on return the variables
   are filled with data from the binary cursor you opened.  These binary
   cursors can not be used if you are running the
   <productname>pgeasy</productname>
   client on a system with a different architecture than the database
   server.  If you pass a NULL pointer parameter, the column is skipped.
   <function>fetchwithnulls</function> allows you to retrieve the NULL
   status of the field by passing an <literal>int*</literal>
   after each result pointer, which returns true or false if the field is null.
   You can always use <application>libpq</application> functions on the <structname>PGresult</structname> pointer returned
   by <function>doquery</function>.
   <function>reset_fetch</function> starts the fetch back at the beginning.
  </para>

  <para>
   <function>get_result</function>,
   <function>set_result</function>,
   and
   <function>unset_result</function>
   allow you to handle multiple result sets at the same time.
  </para>

  <para>
   There are a variety of demonstration programs in the
   source directory.
  </para>
 </chapter>

<!-- Keep this comment at the end of the file
Local variables:
mode:sgml
sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"./reference.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:("/usr/lib/sgml/catalog")
sgml-local-ecat-files:nil
End:
-->