File: libpgeasy.html

package info (click to toggle)
pgeasy 1%3A3.0.4-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,996 kB
  • ctags: 48
  • sloc: sh: 7,058; ansic: 574; makefile: 22
file content (255 lines) | stat: -rw-r--r-- 3,965 bytes parent folder | download | duplicates (2)
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<HTML
><HEAD
><TITLE
>libpgeasy - Simplified C Library</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.64
"><LINK
REV="MADE"
HREF="mailto:pgsql-docs@postgresql.org"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="stylesheet.css"><META
NAME="creation"
CONTENT="2002-11-26T22:36:16"></HEAD
><BODY
CLASS="CHAPTER"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="CHAPTER"
><H1
><A
NAME="pgeasy"
>Chapter 1. <SPAN
CLASS="APPLICATION"
>libpgeasy</SPAN
> - Simplified C Library</A
></H1
>  

  <DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
>   

   <P
><B
>Author: </B
>    Written by Bruce Momjian
    (<TT
CLASS="EMAIL"
>&#60;<A
HREF="mailto:pgman@candle.pha.pa.us"
>pgman@candle.pha.pa.us</A
>&#62;</TT
>)
    and last updated 2002-03-04
   </P
>
  </BLOCKQUOTE
></DIV
>

  <P
>   <SPAN
CLASS="APPLICATION"
>pgeasy</SPAN
> allows you to cleanly interface
   to the <SPAN
CLASS="APPLICATION"
>libpq</SPAN
> library, more like a 4GL
   SQL interface.  Refer to libpq for more
   information about <SPAN
CLASS="APPLICATION"
>libpq</SPAN
>.
  </P
>

  <P
>   It consists of a set of simplified C functions that encapsulate the
   functionality of <SPAN
CLASS="APPLICATION"
>libpq</SPAN
>. The functions are:

   <P
></P
></P><UL
><LI
><PRE
CLASS="SYNOPSIS"
>PGresult   *doquery(char *query);</PRE
>
    </LI
><LI
><PRE
CLASS="SYNOPSIS"
>PGconn     *connectdb(char *options);</PRE
>
    </LI
><LI
><PRE
CLASS="SYNOPSIS"
>void        disconnectdb();</PRE
>
    </LI
><LI
><PRE
CLASS="SYNOPSIS"
>int         fetch(void *param,...);</PRE
>
    </LI
><LI
><PRE
CLASS="SYNOPSIS"
>int         fetchwithnulls(void *param,...);</PRE
>
    </LI
><LI
><PRE
CLASS="SYNOPSIS"
>void        reset_fetch();</PRE
>
    </LI
><LI
><PRE
CLASS="SYNOPSIS"
>void        on_error_continue();</PRE
>
    </LI
><LI
><PRE
CLASS="SYNOPSIS"
>void        on_error_stop();</PRE
>
    </LI
><LI
><PRE
CLASS="SYNOPSIS"
>PGresult   *get_result();</PRE
>
    </LI
><LI
><PRE
CLASS="SYNOPSIS"
>void        set_result(PGresult *newres);</PRE
>
    </LI
></UL
><P>
  </P
>

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

  <P
>   You basically connect to the database with
   <TT
CLASS="FUNCTION"
>connectdb</TT
>, issue your query with
   <TT
CLASS="FUNCTION"
>doquery</TT
>, fetch the results with
   <TT
CLASS="FUNCTION"
>fetch</TT
>, and finish with
   <TT
CLASS="FUNCTION"
>disconnectdb</TT
>.
  </P
>

  <P
>   For <TT
CLASS="LITERAL"
>SELECT</TT
> queries, <TT
CLASS="FUNCTION"
>fetch</TT
>
   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 cannot be used if you are running the
   <SPAN
CLASS="APPLICATION"
>pgeasy</SPAN
> client on a system with a different
   architecture than the database server. If you pass a NULL pointer
   parameter, the column is skipped. <TT
CLASS="FUNCTION"
>fetchwithnulls</TT
>
   allows you to retrieve the NULL status of the field by passing an
   <TT
CLASS="LITERAL"
>int*</TT
> after each result pointer, which returns true
   or false to indicate if the field is null. You can always use
   <SPAN
CLASS="APPLICATION"
>libpq</SPAN
> functions on the
   <TT
CLASS="STRUCTNAME"
>PGresult</TT
> pointer returned by
   <TT
CLASS="FUNCTION"
>doquery</TT
>. <TT
CLASS="FUNCTION"
>reset_fetch</TT
> starts
   the fetch back at the beginning.
  </P
>

  <P
>   <TT
CLASS="FUNCTION"
>get_result</TT
> and <TT
CLASS="FUNCTION"
>set_result</TT
>
   allow you to handle multiple open result sets. Use
   <TT
CLASS="FUNCTION"
>get_result</TT
> to save a result into an application
   variable. You can then later use <TT
CLASS="FUNCTION"
>set_result</TT
> to
   return to the previously save result.
  </P
>

  <P
>   There are several demonstration programs in
   <TT
CLASS="FILENAME"
>/examples</TT
>.
  </P
>
 </DIV
></BODY
></HTML
>