File: group__SQL.html

package info (click to toggle)
qof 0.5.0-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,376 kB
  • ctags: 2,995
  • sloc: ansic: 14,210; sh: 7,273; makefile: 204; yacc: 184; lex: 123
file content (291 lines) | stat: -rw-r--r-- 13,848 bytes parent folder | download
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>QOF: SQL Interface to Query</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.6-20040222 -->
<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div>
<h1>SQL Interface to Query<br>
<small>
[<a class="el" href="group__Query.html">Query: Querying for Objects</a>]</small>
</h1>
<p>
<table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Typedefs</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="anchor" name="ga0" doxytag="SQL::QofSqlQuery" ></a>
typedef _QofSqlQuery&nbsp;</td><td class="memItemRight" valign=bottom><b>QofSqlQuery</b></td></tr>

<tr><td colspan=2><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>QofSqlQuery *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="group__SQL.html#ga1">qof_sql_query_new</a> (void)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top><a class="anchor" name="ga2" doxytag="SQL::qof_sql_query_destroy" ></a>
void&nbsp;</td><td class="memItemRight" valign=bottom><b>qof_sql_query_destroy</b> (QofSqlQuery *)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="group__SQL.html#ga3">qof_sql_query_set_book</a> (QofSqlQuery *q, <a class="el" href="struct__QofBook.html">QofBook</a> *book)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>GList *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="group__SQL.html#ga4">qof_sql_query_run</a> (QofSqlQuery *query, const char *str)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="group__SQL.html#ga5">qof_sql_query_parse</a> (QofSqlQuery *query, const char *str)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="group__Query.html#ga0">QofQuery</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="group__SQL.html#ga6">qof_sql_query_get_query</a> (QofSqlQuery *)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>GList *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="group__SQL.html#ga7">qof_sql_query_rerun</a> (QofSqlQuery *query)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="group__SQL.html#ga8">qof_sql_query_set_kvp</a> (QofSqlQuery *, <a class="el" href="group__KVP.html#ga0">KvpFrame</a> *)</td></tr>

</table>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="ga6" doxytag="qofsql.h::qof_sql_query_get_query" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> <a class="el" href="group__Query.html#ga0">QofQuery</a>* qof_sql_query_get_query </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">QofSqlQuery *&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Return the QofQuery form of the previously parsed query.     </td>
  </tr>
</table>
<a class="anchor" name="ga1" doxytag="qofsql.h::qof_sql_query_new" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> QofSqlQuery* qof_sql_query_new </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">void&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Create a new SQL-syntax query machine.     </td>
  </tr>
</table>
<a class="anchor" name="ga5" doxytag="qofsql.h::qof_sql_query_parse" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> void qof_sql_query_parse </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">QofSqlQuery *&nbsp;</td>
          <td class="mdname" nowrap> <em>query</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>const char *&nbsp;</td>
          <td class="mdname" nowrap> <em>str</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Same as above, but just parse/pre-process the query; do not actually run it over the dataset. The QofBook does not need to be set before calling this function.     </td>
  </tr>
</table>
<a class="anchor" name="ga7" doxytag="qofsql.h::qof_sql_query_rerun" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> GList* qof_sql_query_rerun </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">QofSqlQuery *&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>query</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Run the previously parsed query. The QofBook must be set before this function can be called. Note, teh QofBook can be changed between each successive call to this routine. This routine can be called after either <a class="el" href="group__SQL.html#ga11">qof_sql_query_parse()</a> or <a class="el" href="group__SQL.html#ga12">qof_sql_query_run()</a> because both will set up the parse.     </td>
  </tr>
</table>
<a class="anchor" name="ga4" doxytag="qofsql.h::qof_sql_query_run" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> GList* qof_sql_query_run </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">QofSqlQuery *&nbsp;</td>
          <td class="mdname" nowrap> <em>query</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>const char *&nbsp;</td>
          <td class="mdname" nowrap> <em>str</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Perform the query, return the results. The book must be set in order to be able to perform a query.<p>
The returned list is a list of ... See below ... The returned list will have been sorted using the indicated sort order, (by default ascending order) and trimed to the max_results length. Do NOT free the resulting list. This list is managed internally by QofSqlQuery.<p>
The types of SQL queries that are allowed at this point are very limited. In general, only the following types of queries are supported: SELECT * FROM SomeObj WHERE (param_a &lt; 10.0) AND (param_b = "asdf") SORT BY param_c DESC; The returned list is a list of all of the instances of 'SomeObj' that mathc the query. The 'SORT' term is optional. The 'WHERE' term is optional; but if you don't include 'WHERE', you will get a list of all of the object instances. The Boolean operations 'AND' and 'OR' together with parenthesis can be used to construct arbitrarily nested predicates.<p>
If the param is a KVP frame, then we use a special markup to indicate frame values. The markup should look like /some/kvp/path:value. Thus, for example, SELECT * FROM SomeObj WHERE (param_a &lt; '/some/kvp:10.0') will search for the object where param_a is a KVP frame, and this KVP frame contains a path '/some/kvp' and the value stored at that path is floating-point and that float value is less than 10.0.<p>
The following are types of queries are NOT supported: SELECT a,b,c FROM ... I am thinking of implementing the above as a list of KVP's whose keys would be a,b,c and values would be the results of the search.<p>
Also unsupported are joins: SELECT * FROM ObjA,ObjB WHERE (ObjA.thingy = ObjB.Stuff); The problem with the above is that the search requires a nested search loop, aka a 'join', which is not currently supported in the underlying QofQuery code.<p>
Also unsupported: UPDATE and INSERT.     </td>
  </tr>
</table>
<a class="anchor" name="ga3" doxytag="qofsql.h::qof_sql_query_set_book" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> void qof_sql_query_set_book </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">QofSqlQuery *&nbsp;</td>
          <td class="mdname" nowrap> <em>q</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="struct__QofBook.html">QofBook</a> *&nbsp;</td>
          <td class="mdname" nowrap> <em>book</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Set the book to be searched (you can search multiple books) If no books are set, no results will be returned (since there is nothing to search over).     </td>
  </tr>
</table>
<a class="anchor" name="ga8" doxytag="qofsql.h::qof_sql_query_set_kvp" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> void qof_sql_query_set_kvp </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">QofSqlQuery *&nbsp;</td>
          <td class="mdname" nowrap>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="group__KVP.html#ga0">KvpFrame</a> *&nbsp;</td>
          <td class="mdname" nowrap></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Set the kvp frame to be used for formulating 'indirect' predicates.<p>
Although joins are not supported (see above), there is one special hack that one can use to pass data indirectly into the predicates. This is by using a KVP key name to reference the value to be used for a predicate. Thus, for example, SELECT * FROM SomeObj WHERE (param_a = KVP:/some/key/path); will look up the value stored at '/some/key/path', and use that value to form the actual predicate. So, for example, if the value stored at '/some/key/path' was 2, then the actual query run will be SELECT * FROM SomeObj WHERE (param_a = 2); The lookup occurs at the time that the query is formulated.<p>
The query does *not* take over ownership of the kvp frame, nor does it copy it. Thus, the kvp frame must exist when the query is formulated, and it is the responsibility of the caller to free it when no longer needed.<p>
Note that because this feature is a kind of a hack put in place due to the lack of support for joins, it will probably go away (be deprecated) if/when joins are implemented.     </td>
  </tr>
</table>
<hr size="1"><address style="align: right;"><small>Generated on Sun May 23 15:41:48 2004 for QOF by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 > </a>1.3.6-20040222 </small></address>
</body>
</html>