File: recrdset.tex

package info (click to toggle)
wxwidgets2.8 2.8.10.1-3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 239,052 kB
  • ctags: 289,550
  • sloc: cpp: 1,838,857; xml: 396,717; python: 282,506; ansic: 126,171; makefile: 51,406; sh: 14,581; asm: 299; sql: 258; lex: 194; perl: 139; yacc: 128; pascal: 95; php: 39; lisp: 38; tcl: 24; haskell: 20; java: 18; cs: 18; erlang: 17; ruby: 16; ada: 9; ml: 9; csh: 9
file content (606 lines) | stat: -rw-r--r-- 17,213 bytes parent folder | download | duplicates (7)
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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
\section{\class{wxRecordSet}}\label{wxrecordset}

Each wxRecordSet represents an ODBC database query. You can make multiple queries
at a time by using multiple wxRecordSets with a wxDatabase or you can make
your queries in sequential order using the same wxRecordSet.

Note: this class is considered obsolete, replaced by the Remstar 
wxDB/wxDbTable classes

\wxheading{Derived from}

\helpref{wxObject}{wxobject}

\wxheading{Include files}

<wx/odbc.h>

\wxheading{See also}

\helpref{wxRecordSet overview}{wxrecordsetoverview}, \helpref{wxDatabase overview}{wxdatabaseoverview}

\latexignore{\rtfignore{\wxheading{Members}}}

\membersection{wxRecordSet::wxRecordSet}

\func{}{wxRecordSet}{\param{wxDatabase *}{db}, \param{int}{ type = wxOPEN\_TYPE\_DYNASET},
 \param{int}{ opt = wxOPTION\_DEFAULT}}

Constructor. {\it db} is a pointer to the wxDatabase instance you wish to use the
wxRecordSet with. Currently there are two possible values of {\it type}:

\begin{itemize}\itemsep=0pt
\item wxOPEN\_TYPE\_DYNASET: Loads only one record at a time into memory. The other
data of the result set will be loaded dynamically when
moving the cursor. This is the default type.
\item wxOPEN\_TYPE\_SNAPSHOT: Loads all records of a result set at once. This will
need much more memory, but will result in
faster access to the ODBC data.
\end{itemize}

The {\it option} parameter is not used yet.

The constructor appends the wxRecordSet object to the parent database's list of
wxRecordSet objects, for later destruction when the wxDatabase is destroyed.

\membersection{wxRecordSet::\destruct{wxRecordSet}}

\func{}{\destruct{wxRecordSet}}{\void}

Destructor. All data except that stored in user-defined variables will be lost.
It also unlinks the wxRecordSet object from the parent database's list of
wxRecordSet objects.
 
\membersection{wxRecordSet::AddNew}

\func{void}{AddNew}{\void}

Not implemented.

\membersection{wxRecordSet::BeginQuery}

\func{bool}{BeginQuery}{\param{int}{ openType}, \param{const wxString\& }{sql = NULL}, \param{int}{ options = wxOPTION\_DEFAULT}}

Not implemented.

\membersection{wxRecordSet::BindVar}

\func{void *}{BindVar}{\param{int}{ col}, \param{void *}{buf}, \param{long}{ size}}

Binds a user-defined variable to the column col. Whenever the current field's
data changes, it will be copied into buf (maximum {\it size} bytes).

\func{void *}{BindVar}{\param{const wxString\& }{col}, \param{void *}{buf}, \param{long}{ size}}

The same as above, but uses the column name as the identifier.

\membersection{wxRecordSet::CanAppend}

\func{bool}{CanAppend}{\void}

Not implemented.

\membersection{wxRecordSet::Cancel}

\func{void}{Cancel}{\void}

Not implemented.

\membersection{wxRecordSet::CanRestart}

\func{bool}{CanRestart}{\void}

Not implemented.

\membersection{wxRecordSet::CanScroll}

\func{bool}{CanScroll}{\void}

Not implemented.

\membersection{wxRecordSet::CanTransact}

\func{bool}{CanTransact}{\void}

Not implemented.

\membersection{wxRecordSet::CanUpdate}

\func{bool}{CanUpdate}{\void}

Not implemented.

\membersection{wxRecordSet::ConstructDefaultSQL}

\func{bool}{ConstructDefaultSQL}{\void}

Not implemented.

\membersection{wxRecordSet::Delete}

\func{bool}{Delete}{\void}

Deletes the current record. Not implemented.

\membersection{wxRecordSet::Edit}

\func{void}{Edit}{\void}

Not implemented.

\membersection{wxRecordSet::EndQuery}

\func{bool}{EndQuery}{\void}

Not implemented.

\membersection{wxRecordSet::ExecuteSQL}\label{wxrecordsetexecutesql}

\func{bool}{ExecuteSQL}{\param{const wxString\& }{sql}}

Directly executes a SQL statement. The data will be presented as a normal
result set. Note that the recordset must have been created as a snapshot, not
dynaset. Dynasets will be implemented in the near future.

Examples of common SQL statements are given in \helpref{A selection of SQL commands}{sqlcommands}.

\membersection{wxRecordSet::FillVars}

\func{void}{FillVars}{\param{int}{ recnum}}

Fills in the user-defined variables of the columns. You can set these
variables with wxQueryCol::BindVar. This function will be automatically
called after every successful database operation.

\membersection{wxRecordSet::GetColName}

\func{wxString}{GetColName}{\param{int}{ col}}

Returns the name of the column at position {\it col}. Returns NULL if {\it col} does not
exist.

\membersection{wxRecordSet::GetColType}

\func{short}{GetColType}{\param{int}{ col}}

Returns the data type of the column at position {\it col}. Returns SQL\_TYPE\_NULL
if {\it col} does not exist.

\func{short}{GetColType}{\param{const wxString\& }{ name}}

The same as above, but uses the column name as the identifier.

See \helpref{ODBC SQL data types}{sqltypes} for a list
of possible data types.

\membersection{wxRecordSet::GetColumns}

\func{bool}{GetColumns}{\param{const wxString\& }{table = NULL}}

Returns the columns of the table with the specified name. If no name is
given the class member {\it tablename} will be used. If both names are NULL
nothing will happen. The data will be presented as a normal result set, organized
as follows:

\begin{twocollist}\itemsep=0pt
\twocolitem{0 (VARCHAR)}{TABLE\_QUALIFIER}
\twocolitem{1 (VARCHAR)}{TABLE\_OWNER}
\twocolitem{2 (VARCHAR)}{TABLE\_NAME}
\twocolitem{3 (VARCHAR)}{COLUMN\_NAME}
\twocolitem{4 (SMALLINT)}{DATA\_TYPE}
\twocolitem{5 (VARCHAR)}{TYPE\_NAME}
\twocolitem{6 (INTEGER)}{PRECISION}
\twocolitem{7 (INTEGER)}{LENGTH}
\twocolitem{8 (SMALLINT)}{SCALE}
\twocolitem{9 (SMALLINT)}{RADIX}
\twocolitem{10 (SMALLINT)}{NULLABLE}
\twocolitem{11 (VARCHAR)}{REMARKS}
\end{twocollist}

\membersection{wxRecordSet::GetCurrentRecord}

\func{long}{GetCurrentRecord}{\void}

Not implemented.

\membersection{wxRecordSet::GetDatabase}

\func{wxDatabase *}{GetDatabase}{\void}

Returns the wxDatabase object bound to a wxRecordSet.

\membersection{wxRecordSet::GetDataSources}\label{wxrecordsetgetdatasources}

\func{bool}{GetDataSources}{\void}

Gets the currently-defined data sources via the ODBC manager. The data will be presented
as a normal result set. See the documentation for the ODBC function SQLDataSources for how the data
is organized.

Example:
  
\begin{verbatim}
  wxDatabase Database;

  wxRecordSet *Record = new wxRecordSet(&Database);

  if (!Record->GetDataSources()) {
    char buf[300];
    sprintf(buf, "%s %s\n", Database.GetErrorClass(), Database.GetErrorMessage());
    frame->output->SetValue(buf);
  }
  else {
    do {
      frame->DataSource->Append((char*)Record->GetFieldDataPtr(0, SQL_CHAR));
    } while (Record->MoveNext());
  }
\end{verbatim}

\membersection{wxRecordSet::GetDefaultConnect}

\func{wxString}{GetDefaultConnect}{\void}

Not implemented.

\membersection{wxRecordSet::GetDefaultSQL}

\func{wxString}{GetDefaultSQL}{\void}

Not implemented.

\membersection{wxRecordSet::GetErrorCode}

\func{wxRETCODE}{GetErrorCode}{\void}

Returns the error code of the last ODBC action. This will be one of:

\begin{twocollist}\itemsep=0pt
\twocolitem{SQL\_ERROR}{General error.}
\twocolitem{SQL\_INVALID\_HANDLE}{An invalid handle was passed to an ODBC function.}
\twocolitem{SQL\_NEED\_DATA}{ODBC expected some data.}
\twocolitem{SQL\_NO\_DATA\_FOUND}{No data was found by this ODBC call.}
\twocolitem{SQL\_SUCCESS}{The call was successful.}
\twocolitem{SQL\_SUCCESS\_WITH\_INFO}{The call was successful, but further information can be
obtained from the ODBC manager.}
\end{twocollist}

\membersection{wxRecordSet::GetFieldData}\label{wxrecordsetgetfielddata}

\func{bool}{GetFieldData}{\param{int}{ col}, \param{int}{ dataType}, \param{void *}{dataPtr}}

Copies the current data of the column at position {\it col} into the buffer
\rtfsp{\it dataPtr}. To be sure to get the right type of data, the user has to pass the
correct data type. The function returns false if {\it col} does not
exist or the wrong data type was given.

\func{bool}{GetFieldData}{\param{const wxString\& }{name}, \param{int}{ dataType}, \param{void *}{dataPtr}}

The same as above, but uses the column name as the identifier.

See \helpref{ODBC SQL data types}{sqltypes} for a list
of possible data types.

\membersection{wxRecordSet::GetFieldDataPtr}\label{wxrecordsetgetfielddataptr}

\func{void *}{GetFieldDataPtr}{\param{int}{ col}, \param{int}{ dataType}}

Returns the current data pointer of the column at position {\it col}.
To be sure to get the right type of data, the user has to pass the
data type. Returns NULL if {\it col} does not exist or if {\it dataType} is
incorrect.

\func{void *}{GetFieldDataPtr}{\param{const wxString\& }{name}, \param{int}{ dataType}}

The same as above, but uses the column name as the identifier.

See \helpref{ODBC SQL data types}{sqltypes} for a list
of possible data types.

\membersection{wxRecordSet::GetFilter}

\func{wxString}{GetFilter}{\void}

Returns the current filter.

\membersection{wxRecordSet::GetForeignKeys}

\func{bool}{GetPrimaryKeys}{\param{const wxString\& }{ptable = NULL}, \param{const wxString\& }{ftable
= NULL}}

Returns a list of foreign keys in the specified table (columns in the
specified table that refer to primary keys in other tables), or
a list of foreign keys in other tables that refer to the primary key in
the specified table.

If {\it ptable} contains a table name, this function returns a result
set containing the primary key of the specified table.

If {\it ftable} contains a table name, this functions returns a result set
of containing all of the foreign keys in the specified table and the
primary keys (in other tables) to which they refer.

If both {\it ptable} and {\it ftable} contain table names, this
function returns the foreign keys in the table specified in {\it
ftable} that refer to the primary key of the table specified in {\it
ptable}. This should be one key at most.

GetForeignKeys returns results as a standard result set. If the foreign
keys associated with a primary key are requested, the result set is
ordered by FKTABLE\_QUALIFIER, FKTABLE\_OWNER, FKTABLE\_NAME, and KEY\_SEQ.
If the primary keys associated with a foreign key are requested, the
result set is ordered by PKTABLE\_QUALIFIER, PKTABLE\_OWNER, PKTABLE\_NAME,
and KEY\_SEQ. The following table lists the columns in the result set. 

\begin{twocollist}\itemsep=0pt
\twocolitem{0 (VARCHAR)}{PKTABLE\_QUALIFIER}
\twocolitem{1 (VARCHAR)}{PKTABLE\_OWNER}
\twocolitem{2 (VARCHAR)}{PKTABLE\_NAME}
\twocolitem{3 (VARCHAR)}{PKCOLUMN\_NAME}
\twocolitem{4 (VARCHAR)}{FKTABLE\_QUALIFIER}
\twocolitem{5 (VARCHAR)}{FKTABLE\_OWNER}
\twocolitem{6 (VARCHAR)}{FKTABLE\_NAME}
\twocolitem{7 (VARCHAR)}{FKCOLUMN\_NAME}
\twocolitem{8 (SMALLINT)}{KEY\_SEQ}
\twocolitem{9 (SMALLINT)}{UPDATE\_RULE}
\twocolitem{10 (SMALLINT)}{DELETE\_RULE}
\twocolitem{11 (VARCHAR)}{FK\_NAME}
\twocolitem{12 (VARCHAR)}{PK\_NAME}
\end{twocollist}

\membersection{wxRecordSet::GetNumberCols}

\func{long}{GetNumberCols}{\void}

Returns the number of columns in the result set.
  
\membersection{wxRecordSet::GetNumberFields}

\func{int}{GetNumberFields}{\void}

Not implemented.

\membersection{wxRecordSet::GetNumberParams}

\func{int}{GetNumberParams}{\void}

Not implemented.

\membersection{wxRecordSet::GetNumberRecords}

\func{long}{GetNumberRecords}{\void}

Returns the number of records in the result set.
  
\membersection{wxRecordSet::GetPrimaryKeys}

\func{bool}{GetPrimaryKeys}{\param{const wxString\& }{table = NULL}}

Returns the column names that comprise the primary key of the table with the specified name. If no name is
given the class member {\it tablename} will be used. If both names are NULL
nothing will happen. The data will be presented as a normal result set, organized
as follows:

\begin{twocollist}\itemsep=0pt
\twocolitem{0 (VARCHAR)}{TABLE\_QUALIFIER}
\twocolitem{1 (VARCHAR)}{TABLE\_OWNER}
\twocolitem{2 (VARCHAR)}{TABLE\_NAME}
\twocolitem{3 (VARCHAR)}{COLUMN\_NAME}
\twocolitem{4 (SMALLINT)}{KEY\_SEQ}
\twocolitem{5 (VARCHAR)}{PK\_NAME}
\end{twocollist}

\membersection{wxRecordSet::GetOptions}

\func{int}{GetOptions}{\void}

Returns the options of the wxRecordSet. Options are not supported yet.

\membersection{wxRecordSet::GetResultSet}

\func{bool}{GetResultSet}{\void}

Copies the data presented by ODBC into wxRecordSet. Depending on the
wxRecordSet type all or only one record(s) will be copied.
Usually this function will be called automatically after each successful
database operation.
  
\membersection{wxRecordSet::GetSortString}

\func{wxString}{GetSortString}{\void}

Not implemented.
  
\membersection{wxRecordSet::GetSQL}

\func{wxString}{GetSQL}{\void}

Not implemented.

\membersection{wxRecordSet::GetTableName}

\func{wxString}{GetTableName}{\void}

Returns the name of the current table.
  
\membersection{wxRecordSet::GetTables}

\func{bool}{GetTables}{\void}

Gets the tables of a database. The data will be presented as a normal result
set, organized as follows:

\begin{twocollist}\itemsep=0pt
\twocolitem{0 (VARCHAR)}{TABLE\_QUALIFIER}
\twocolitem{1 (VARCHAR)}{TABLE\_OWNER}
\twocolitem{2 (VARCHAR)}{TABLE\_NAME}
\twocolitem{3 (VARCHAR)}{TABLE\_TYPE (TABLE, VIEW, SYSTEM TABLE, GLOBAL TEMPORARY, LOCAL TEMPORARY,
ALIAS, SYNONYM, or database-specific type)}
\twocolitem{4 (VARCHAR)}{REMARKS}
\end{twocollist}

\membersection{wxRecordSet::GetType}

\func{int}{GetType}{\void}

Returns the type of the wxRecordSet: wxOPEN\_TYPE\_DYNASET or
wxOPEN\_TYPE\_SNAPSHOT. See the wxRecordSet description for details.

\membersection{wxRecordSet::GoTo}

\func{bool}{GoTo}{\param{long}{ n}}

Moves the cursor to the record with the number n, where  the first record
has the number 0.
  
\membersection{wxRecordSet::IsBOF}

\func{bool}{IsBOF}{\void}

Returns true if the user tried to move the cursor before the first record
in the set.

\membersection{wxRecordSet::IsFieldDirty}

\func{bool}{IsFieldDirty}{\param{int}{ field}}

Returns true if the given field has been changed but not saved yet.

\func{bool}{IsFieldDirty}{\param{const wxString\& }{name}}

Same as above, but uses the column name as the identifier.

\membersection{wxRecordSet::IsFieldNull}

\func{bool}{IsFieldNull}{\param{int}{ field}}

Returns true if the given field has no data.

\func{bool}{IsFieldNull}{\param{const wxString\& }{ name}}

Same as above, but uses the column name as the identifier.

\membersection{wxRecordSet::IsColNullable}

\func{bool}{IsColNullable}{\param{int}{ col}}

Returns true if the given column may contain no data.

\func{bool}{IsColNullable}{\param{const wxString\& }{name}}

Same as above, but uses the column name as the identifier.

\membersection{wxRecordSet::IsEOF}

\func{bool}{IsEOF}{\void}

Returns true if the user tried to move the cursor behind the last record
in the set.

\membersection{wxRecordSet::IsDeleted}

\func{bool}{IsDeleted}{\void}

Not implemented.
  
\membersection{wxRecordSet::IsOpen}

\func{bool}{IsOpen}{\void}

Returns true if the parent database is open.

\membersection{wxRecordSet::Move}

\func{bool}{Move}{\param{long}{ rows}}

Moves the cursor a given number of rows. Negative values are allowed.
  
\membersection{wxRecordSet::MoveFirst}

\func{bool}{MoveFirst}{\void}

Moves the cursor to the first record.
  
\membersection{wxRecordSet::MoveLast}

\func{bool}{MoveLast}{\void}

Moves the cursor to the last record.
  
\membersection{wxRecordSet::MoveNext}\label{wxrecordsetmovenext}

\func{bool}{MoveNext}{\void}

Moves the cursor to the next record.
  
\membersection{wxRecordSet::MovePrev}\label{wxrecordsetmoveprev}

\func{bool}{MovePrev}{\void}

Moves the cursor to the previous record.
  
\membersection{wxRecordSet::Query}

\func{bool}{Query}{\param{const wxString\& }{columns}, \param{const wxString\& }{table}, \param{const wxString\& }{filter = NULL}}

Start a query. An SQL string of the following type will automatically be
generated and executed: ``SELECT columns FROM table WHERE filter".

\membersection{wxRecordSet::RecordCountFinal}

\func{bool}{RecordCountFinal}{\void}

Not implemented.
  
\membersection{wxRecordSet::Requery}

\func{bool}{Requery}{\void}

Re-executes the last query. Not implemented.

\membersection{wxRecordSet::SetFieldDirty}

\func{void}{SetFieldDirty}{\param{int}{ field}, \param{bool}{ dirty = true}}

Sets the dirty tag of the field field. Not implemented.

\func{void}{SetFieldDirty}{\param{const wxString\& }{name}, \param{bool}{ dirty = true}}

Same as above, but uses the column name as the identifier.

\membersection{wxRecordSet::SetDefaultSQL}

\func{void}{SetDefaultSQL}{\param{const wxString\& }{s}}

Not implemented.

\membersection{wxRecordSet::SetFieldNull}

\func{void}{SetFieldNull}{\param{void *}{p}, \param{bool }{isNull = true}}

Not implemented.

\membersection{wxRecordSet::SetOptions}

\func{void}{SetOptions}{\param{int}{ opt}}

Sets the options of the wxRecordSet. Not implemented.
  
\membersection{wxRecordSet::SetTableName}

\func{void}{SetTableName}{\param{const wxString\& }{tablename}}

Specify the name of the table you want to use.
  
\membersection{wxRecordSet::SetType}

\func{void}{SetType}{\param{int}{ type}}

Sets the type of the wxRecordSet. See the wxRecordSet class description for details.

\membersection{wxRecordSet::Update}

\func{bool}{Update}{\void}

Writes back the current record. Not implemented.