summaryrefslogtreecommitdiffstats
path: root/doc/html/ntqsqlcursor.html
blob: aaa3ad329af03b43d7ac80aaa35ecfa7773e7727 (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
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
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/sql/qsqlcursor.cpp:122 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TQSqlCursor Class</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
 <a href="index.html">
<font color="#004faf">Home</font></a>
 | <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
 | <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
 | <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
 | <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
 | <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>TQSqlCursor Class Reference<br><small>[<a href="sql.html">sql module</a>]</small></h1>

<p>The TQSqlCursor class provides browsing and editing of SQL
tables and views.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qsqlcursor-h.html">ntqsqlcursor.h</a>&gt;</tt>
<p>Inherits <a href="ntqsqlrecord.html">TQSqlRecord</a> and <a href="ntqsqlquery.html">TQSqlQuery</a>.
<p>Inherited by <a href="ntqsqlselectcursor.html">TQSqlSelectCursor</a>.
<p><a href="qsqlcursor-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#TQSqlCursor"><b>TQSqlCursor</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;name = TQString::null, bool&nbsp;autopopulate = TRUE, TQSqlDatabase&nbsp;*&nbsp;db = 0 )</li>
<li class=fn><a href="#TQSqlCursor-2"><b>TQSqlCursor</b></a> ( const&nbsp;TQSqlCursor&nbsp;&amp;&nbsp;other )</li>
<li class=fn>TQSqlCursor &amp; <a href="#operator-eq"><b>operator=</b></a> ( const&nbsp;TQSqlCursor&nbsp;&amp;&nbsp;other )</li>
<li class=fn><a href="#~TQSqlCursor"><b>~TQSqlCursor</b></a> ()</li>
<li class=fn>enum <a href="#Mode-enum"><b>Mode</b></a> { ReadOnly = 0, Insert = 1, Update = 2, Delete = 4, Writable = 7 }</li>
<li class=fn>virtual TQSqlIndex <a href="#primaryIndex"><b>primaryIndex</b></a> ( bool&nbsp;setFromCursor = TRUE ) const</li>
<li class=fn>virtual TQSqlIndex <a href="#index"><b>index</b></a> ( const&nbsp;TQStringList&nbsp;&amp;&nbsp;fieldNames ) const</li>
<li class=fn>TQSqlIndex <a href="#index-2"><b>index</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;fieldName ) const</li>
<li class=fn>TQSqlIndex <a href="#index-3"><b>index</b></a> ( const&nbsp;char&nbsp;*&nbsp;fieldName ) const</li>
<li class=fn>virtual void <a href="#setPrimaryIndex"><b>setPrimaryIndex</b></a> ( const&nbsp;TQSqlIndex&nbsp;&amp;&nbsp;idx )</li>
<li class=fn>virtual void <a href="#append"><b>append</b></a> ( const&nbsp;TQSqlFieldInfo&nbsp;&amp;&nbsp;fieldInfo )</li>
<li class=fn>virtual void <a href="#insert"><b>insert</b></a> ( int&nbsp;pos, const&nbsp;TQSqlFieldInfo&nbsp;&amp;&nbsp;fieldInfo )</li>
<li class=fn>virtual void <a href="#remove"><b>remove</b></a> ( int&nbsp;pos )</li>
<li class=fn>virtual void <a href="#clear"><b>clear</b></a> ()</li>
<li class=fn>virtual void <a href="#setGenerated"><b>setGenerated</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;name, bool&nbsp;generated )</li>
<li class=fn>virtual void <a href="#setGenerated-2"><b>setGenerated</b></a> ( int&nbsp;i, bool&nbsp;generated )</li>
<li class=fn>virtual TQSqlRecord * <a href="#editBuffer"><b>editBuffer</b></a> ( bool&nbsp;copy = FALSE )</li>
<li class=fn>virtual TQSqlRecord * <a href="#primeInsert"><b>primeInsert</b></a> ()</li>
<li class=fn>virtual TQSqlRecord * <a href="#primeUpdate"><b>primeUpdate</b></a> ()</li>
<li class=fn>virtual TQSqlRecord * <a href="#primeDelete"><b>primeDelete</b></a> ()</li>
<li class=fn>virtual int <a href="#insert-2"><b>insert</b></a> ( bool&nbsp;invalidate = TRUE )</li>
<li class=fn>virtual int <a href="#update"><b>update</b></a> ( bool&nbsp;invalidate = TRUE )</li>
<li class=fn>virtual int <a href="#del"><b>del</b></a> ( bool&nbsp;invalidate = TRUE )</li>
<li class=fn>virtual void <a href="#setMode"><b>setMode</b></a> ( int&nbsp;mode )</li>
<li class=fn>int <a href="#mode"><b>mode</b></a> () const</li>
<li class=fn>virtual void <a href="#setCalculated"><b>setCalculated</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;name, bool&nbsp;calculated )</li>
<li class=fn>bool <a href="#isCalculated"><b>isCalculated</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;name ) const</li>
<li class=fn>virtual void <a href="#setTrimmed"><b>setTrimmed</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;name, bool&nbsp;trim )</li>
<li class=fn>bool <a href="#isTrimmed"><b>isTrimmed</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;name ) const</li>
<li class=fn>bool <a href="#isReadOnly"><b>isReadOnly</b></a> () const</li>
<li class=fn>bool <a href="#canInsert"><b>canInsert</b></a> () const</li>
<li class=fn>bool <a href="#canUpdate"><b>canUpdate</b></a> () const</li>
<li class=fn>bool <a href="#canDelete"><b>canDelete</b></a> () const</li>
<li class=fn>bool <a href="#select-2"><b>select</b></a> ()</li>
<li class=fn>bool <a href="#select-3"><b>select</b></a> ( const&nbsp;TQSqlIndex&nbsp;&amp;&nbsp;sort )</li>
<li class=fn>bool <a href="#select-4"><b>select</b></a> ( const&nbsp;TQSqlIndex&nbsp;&amp;&nbsp;filter, const&nbsp;TQSqlIndex&nbsp;&amp;&nbsp;sort )</li>
<li class=fn>virtual bool <a href="#select"><b>select</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;filter, const&nbsp;TQSqlIndex&nbsp;&amp;&nbsp;sort = TQSqlIndex ( ) )</li>
<li class=fn>virtual void <a href="#setSort"><b>setSort</b></a> ( const&nbsp;TQSqlIndex&nbsp;&amp;&nbsp;sort )</li>
<li class=fn>TQSqlIndex <a href="#sort"><b>sort</b></a> () const</li>
<li class=fn>virtual void <a href="#setFilter"><b>setFilter</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;filter )</li>
<li class=fn>TQString <a href="#filter"><b>filter</b></a> () const</li>
<li class=fn>virtual void <a href="#setName"><b>setName</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;name, bool&nbsp;autopopulate = TRUE )</li>
<li class=fn>TQString <a href="#name"><b>name</b></a> () const</li>
<li class=fn>bool <a href="#isNull"><b>isNull</b></a> ( int&nbsp;i ) const</li>
<li class=fn>bool <a href="#isNull-2"><b>isNull</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;name ) const</li>
</ul>
<h2>Protected Members</h2>
<ul>
<li class=fn>virtual TQVariant <a href="#calculateField"><b>calculateField</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;name )</li>
<li class=fn>virtual int <a href="#update-2"><b>update</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;filter, bool&nbsp;invalidate = TRUE )</li>
<li class=fn>virtual int <a href="#del-2"><b>del</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;filter, bool&nbsp;invalidate = TRUE )</li>
<li class=fn>virtual TQString <a href="#toString-3"><b>toString</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;prefix, TQSqlField&nbsp;*&nbsp;field, const&nbsp;TQString&nbsp;&amp;&nbsp;fieldSep ) const</li>
<li class=fn>virtual TQString <a href="#toString"><b>toString</b></a> ( TQSqlRecord&nbsp;*&nbsp;rec, const&nbsp;TQString&nbsp;&amp;&nbsp;prefix, const&nbsp;TQString&nbsp;&amp;&nbsp;fieldSep, const&nbsp;TQString&nbsp;&amp;&nbsp;sep ) const</li>
<li class=fn>virtual TQString <a href="#toString-4"><b>toString</b></a> ( const&nbsp;TQSqlIndex&nbsp;&amp;&nbsp;i, TQSqlRecord&nbsp;*&nbsp;rec, const&nbsp;TQString&nbsp;&amp;&nbsp;prefix, const&nbsp;TQString&nbsp;&amp;&nbsp;fieldSep, const&nbsp;TQString&nbsp;&amp;&nbsp;sep ) const</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>


The TQSqlCursor class provides browsing and editing of SQL
tables and views.
<p> 

<p> A TQSqlCursor is a database record (see <a href="ntqsqlrecord.html">TQSqlRecord</a>) that
corresponds to a table or view within an SQL database (see <a href="ntqsqldatabase.html">TQSqlDatabase</a>). There are two buffers in a cursor, one used for
browsing and one used for editing records. Each buffer contains a
list of fields which correspond to the fields in the table or
view.
<p> When positioned on a valid record, the browse buffer contains the
values of the current record's fields from the database. The edit
buffer is separate, and is used for editing existing records and
inserting new records.
<p> For browsing data, a cursor must first <a href="#select">select</a>() data from the
database. After a successful select() the cursor is active
(<a href="ntqsqlquery.html#isActive">isActive</a>() returns TRUE), but is initially not positioned on a
valid record (<a href="ntqsqlquery.html#isValid">isValid</a>() returns FALSE). To position the cursor on
a valid record, use one of the navigation functions, <a href="ntqsqlquery.html#next">next</a>(),
<a href="ntqsqlquery.html#prev">prev</a>(), <a href="ntqsqlquery.html#first">first</a>(), <a href="ntqsqlquery.html#last">last</a>(), or <a href="ntqsqlquery.html#seek">seek</a>(). Once positioned on a valid
record, data can be retrieved from the browse buffer using
<a href="ntqsqlquery.html#value">value</a>(). If a navigation function is not successful, it returns
FALSE, the cursor will no longer be positioned on a valid record
and the values returned by value() are undefined.
<p> For example:
<p> 

<pre>            TQSqlCursor cur( "staff" ); // Specify the table/view name
    <a name="x2178"></a>        cur.<a href="#select">select</a>(); // We'll retrieve every record
            while ( cur.<a href="ntqsqlquery.html#next">next</a>() ) {
    <a name="x2179"></a>            <a href="ntqapplication.html#qDebug">qDebug</a>( cur.<a href="ntqsqlquery.html#value">value</a>( "id" ).toString() + ": " +
                        cur.<a href="ntqsqlquery.html#value">value</a>( "surname" ).toString() + " " +
                        cur.<a href="ntqsqlquery.html#value">value</a>( "salary" ).toString() );
            }
</pre>
<p> In the above example, a cursor is created specifying a table or
view name in the database. Then, <a href="#select">select</a>() is called, which can be
optionally parameterised to filter and order the records
retrieved. Each record in the cursor is retrieved using <a href="ntqsqlquery.html#next">next</a>().
When next() returns FALSE, there are no more records to process,
and the loop terminates.
<p> For editing records (rows of data), a cursor contains a separate
edit buffer which is independent of the fields used when browsing.
The functions <a href="#insert">insert</a>(), <a href="#update">update</a>() and <a href="#del">del</a>() operate on the edit
buffer. This allows the cursor to be repositioned to other
records while simultaneously maintaining a separate buffer for
edits. You can get a pointer to the edit buffer using
<a href="#editBuffer">editBuffer</a>(). The <a href="#primeInsert">primeInsert</a>(), <a href="#primeUpdate">primeUpdate</a>() and <a href="#primeDelete">primeDelete</a>()
functions also return a pointer to the edit buffer and prepare it
for insert, update and delete respectively. Edit operations only
affect a single row at a time. Note that update() and del()
require that the table or view contain a <a href="#primaryIndex">primaryIndex</a>() to ensure
that edit operations affect a unique record within the database.
<p> For example:
<p> 

<pre>            TQSqlCursor cur( "prices" );
    <a name="x2200"></a>        cur.<a href="#select">select</a>( "id=202" );
            if ( cur.<a href="ntqsqlquery.html#next">next</a>() ) {
    <a name="x2199"></a>            <a href="ntqsqlrecord.html">TQSqlRecord</a> *buffer = cur.<a href="#primeUpdate">primeUpdate</a>();
    <a name="x2204"></a>            double price = buffer-&gt;<a href="ntqsqlrecord.html#value">value</a>( "price" ).toDouble();
                double newprice = price * 1.05;
    <a name="x2203"></a>            buffer-&gt;<a href="ntqsqlrecord.html#setValue">setValue</a>( "price", newprice );
    <a name="x2201"></a>            cur.<a href="#update">update</a>();
            }
</pre>
<p> To edit an existing database record, first move to the record you
wish to update. Call <a href="#primeUpdate">primeUpdate</a>() to get the pointer to the
cursor's edit buffer. Then use this pointer to modify the values
in the edit buffer. Finally, call <a href="#update">update</a>() to save the changes to
the database. The values in the edit buffer will be used to
locate the appropriate record when updating the database (see
<a href="#primaryIndex">primaryIndex</a>()).
<p> Similarly, when deleting an existing database record, first move
to the record you wish to delete. Then, call <a href="#primeDelete">primeDelete</a>() to get
the pointer to the edit buffer. Finally, call <a href="#del">del</a>() to delete the
record from the database. Again, the values in the edit buffer
will be used to locate and delete the appropriate record.
<p> To insert a new record, call <a href="#primeInsert">primeInsert</a>() to get the pointer to
the edit buffer. Use this pointer to populate the edit buffer
with new values and then <a href="#insert">insert</a>() the record into the database.
<p> After calling insert(), update() or del(), the cursor is no longer
positioned on a valid record and can no longer be navigated
(<a href="ntqsqlquery.html#isValid">isValid</a>() return FALSE). The reason for this is that any changes
made to the database will not be visible until <a href="#select">select</a>() is called
to refresh the cursor. You can change this behavior by passing
FALSE to insert(), <a href="#update">update</a>() or del() which will prevent the cursor
from becoming invalid. The edits will still not be visible when
navigating the cursor until select() is called.
<p> TQSqlCursor contains virtual methods which allow editing behavior
to be customized by subclasses. This allows custom cursors to be
created that encapsulate the editing behavior of a database table
for an entire application. For example, a cursor can be customized
to always auto-number primary index fields, or provide fields with
suitable default values, when inserting new records. TQSqlCursor
generates SQL statements which are sent to the database engine;
you can control which fields are included in these statements
using <a href="#setGenerated">setGenerated</a>().
<p> Note that TQSqlCursor does not inherit from <a href="ntqobject.html">TQObject</a>. This means
that you are responsible for destroying instances of this class
yourself. However if you create a TQSqlCursor and use it in a
<a href="ntqdatatable.html">TQDataTable</a>, <a href="ntqdatabrowser.html">TQDataBrowser</a> or a <a href="ntqdataview.html">TQDataView</a> these classes will
usually take ownership of the cursor and destroy it when they
don't need it anymore. The documentation for <a href="ntqdatatable.html">TQDataTable</a>,
<a href="ntqdatabrowser.html">TQDataBrowser</a> and <a href="ntqdataview.html">TQDataView</a> explicitly states which calls take
ownership of the cursor.
<p>See also <a href="database.html">Database Classes</a>.

<hr><h2>Member Type Documentation</h2>
<h3 class=fn><a name="Mode-enum"></a>TQSqlCursor::Mode</h3>

<p> This enum type describes how TQSqlCursor operates on records in the
database.
<ul>
<li><tt>TQSqlCursor::ReadOnly</tt> - the cursor can only SELECT records from the
database.
<li><tt>TQSqlCursor::Insert</tt> - the cursor can INSERT records into the database.
<li><tt>TQSqlCursor::Update</tt> - the cursor can UPDATE records in the database.
<li><tt>TQSqlCursor::Delete</tt> - the cursor can DELETE records from the database.
<li><tt>TQSqlCursor::Writable</tt> - the cursor can INSERT, UPDATE and DELETE records
in the database.
</ul>
<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="TQSqlCursor"></a>TQSqlCursor::TQSqlCursor ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;name = TQString::null, bool&nbsp;autopopulate = TRUE, <a href="ntqsqldatabase.html">TQSqlDatabase</a>&nbsp;*&nbsp;db = 0 )
</h3>
Constructs a cursor on database <em>db</em> using table or view <em>name</em>.
<p> If <em>autopopulate</em> is TRUE (the default), the <em>name</em> of the
cursor must correspond to an existing table or view name in the
database so that field information can be automatically created.
If the table or view does not exist, the cursor will not be
functional.
<p> The cursor is created with an initial mode of TQSqlCursor::Writable
(meaning that records can be inserted, updated or deleted using
the cursor). If the cursor does not have a unique primary index,
update and deletes cannot be performed.
<p> Note that <em>autopopulate</em> refers to populating the cursor with
meta-data, e.g. the names of the table's fields, not with
retrieving data. The <a href="#select">select</a>() function is used to populate the
cursor with data.
<p> <p>See also <a href="#setName">setName</a>() and <a href="#setMode">setMode</a>().

<h3 class=fn><a name="TQSqlCursor-2"></a>TQSqlCursor::TQSqlCursor ( const&nbsp;<a href="ntqsqlcursor.html">TQSqlCursor</a>&nbsp;&amp;&nbsp;other )
</h3>
Constructs a copy of <em>other</em>.

<h3 class=fn><a name="~TQSqlCursor"></a>TQSqlCursor::~TQSqlCursor ()
</h3>
Destroys the object and frees any allocated resources.

<h3 class=fn>void <a name="append"></a>TQSqlCursor::append ( const&nbsp;<a href="qsqlfieldinfo.html">TQSqlFieldInfo</a>&nbsp;&amp;&nbsp;fieldInfo )<tt> [virtual]</tt>
</h3>
Append a copy of field <em>fieldInfo</em> to the end of the cursor. Note
that all references to the cursor edit buffer become invalidated.

<h3 class=fn><a href="ntqvariant.html">TQVariant</a> <a name="calculateField"></a>TQSqlCursor::calculateField ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;name )<tt> [virtual protected]</tt>
</h3>
Protected virtual function which is called whenever a field needs
to be calculated. If calculated fields are being used, derived
classes must reimplement this function and return the appropriate
value for field <em>name</em>. The default implementation returns an
invalid <a href="ntqvariant.html">TQVariant</a>.
<p> <p>See also <a href="#setCalculated">setCalculated</a>().

<p>Examples: <a href="sql.html#x2259">sql/overview/subclass3/main.cpp</a> and <a href="sql.html#x2263">sql/overview/subclass4/main.cpp</a>.
<h3 class=fn>bool <a name="canDelete"></a>TQSqlCursor::canDelete () const
</h3>
Returns TRUE if the cursor will perform deletes; otherwise returns
FALSE.
<p> <p>See also <a href="#setMode">setMode</a>().

<h3 class=fn>bool <a name="canInsert"></a>TQSqlCursor::canInsert () const
</h3>
Returns TRUE if the cursor will perform inserts; otherwise returns
FALSE.
<p> <p>See also <a href="#setMode">setMode</a>().

<h3 class=fn>bool <a name="canUpdate"></a>TQSqlCursor::canUpdate () const
</h3>
Returns TRUE if the cursor will perform updates; otherwise returns
FALSE.
<p> <p>See also <a href="#setMode">setMode</a>().

<h3 class=fn>void <a name="clear"></a>TQSqlCursor::clear ()<tt> [virtual]</tt>
</h3>
Removes all fields from the cursor. Note that all references to
the cursor edit buffer become invalidated.

<p>Reimplemented from <a href="ntqsqlrecord.html#clear">TQSqlRecord</a>.
<h3 class=fn>int <a name="del"></a>TQSqlCursor::del ( bool&nbsp;invalidate = TRUE )<tt> [virtual]</tt>
</h3>
Deletes a record from the database using the cursor's primary
index and the contents of the cursor edit buffer. Returns the
number of records which were deleted.
For error information, use <a href="ntqsqlquery.html#lastError">lastError</a>().
<p> Only records which meet the filter criteria specified by the
cursor's primary index are deleted. If the cursor does not contain
a primary index, no delete is performed and 0 is returned. If <em>invalidate</em> is TRUE (the default), the current cursor can no longer
be navigated. A new <a href="#select">select</a>() call must be made before you can move
to a valid record. For example:
<p> 

<pre>            TQSqlCursor cur( "prices" );
    <a name="x2207"></a>        cur.<a href="#select">select</a>( "id=999" );
    <a name="x2208"></a>        if ( cur.<a href="ntqsqlquery.html#next">next</a>() ) {
    <a name="x2206"></a>            cur.<a href="#primeDelete">primeDelete</a>();
    <a name="x2205"></a>            cur.<a href="#del">del</a>();
            }
</pre>
<p> In the above example, a cursor is created on the 'prices' table
and positioned to the record to be deleted. First <a href="#primeDelete">primeDelete</a>() is
called to populate the edit buffer with the current cursor values,
e.g. with an id of 999, and then <a href="#del">del</a>() is called to actually
delete the record from the database. Remember: all edit operations
(<a href="#insert">insert</a>(), <a href="#update">update</a>() and delete()) operate on the contents of the
cursor edit buffer and not on the contents of the cursor itself.
<p> <p>See also <a href="#primeDelete">primeDelete</a>(), <a href="#setMode">setMode</a>(), and <a href="ntqsqlquery.html#lastError">lastError</a>().

<p>Example: <a href="sql.html#x2205">sql/overview/delete/main.cpp</a>.
<h3 class=fn>int <a name="del-2"></a>TQSqlCursor::del ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;filter, bool&nbsp;invalidate = TRUE )<tt> [virtual protected]</tt>
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Deletes the current cursor record from the database using the
filter <em>filter</em>. Only records which meet the filter criteria are
deleted. Returns the number of records which were deleted. If <em>invalidate</em> is TRUE (the default), the current cursor can no longer
be navigated. A new <a href="#select">select</a>() call must be made before you can move
to a valid record. For error information, use <a href="ntqsqlquery.html#lastError">lastError</a>().
<p> The <em>filter</em> is an SQL <tt>WHERE</tt> clause, e.g. <tt>id=500</tt>.
<p> <p>See also <a href="#setMode">setMode</a>() and <a href="ntqsqlquery.html#lastError">lastError</a>().

<h3 class=fn><a href="ntqsqlrecord.html">TQSqlRecord</a>&nbsp;* <a name="editBuffer"></a>TQSqlCursor::editBuffer ( bool&nbsp;copy = FALSE )<tt> [virtual]</tt>
</h3>
Returns the current internal edit buffer. If <em>copy</em> is TRUE (the
default is FALSE), the current cursor field values are first
copied into the edit buffer. The edit buffer is valid as long as
the cursor remains valid. The cursor retains ownership of the
returned pointer, so it must not be deleted or modified.
<p> <p>See also <a href="#primeInsert">primeInsert</a>(), <a href="#primeUpdate">primeUpdate</a>(), and <a href="#primeDelete">primeDelete</a>().

<h3 class=fn><a href="ntqstring.html">TQString</a> <a name="filter"></a>TQSqlCursor::filter () const
</h3>
Returns the current filter, or an empty string if there is no
current filter.

<h3 class=fn><a href="ntqsqlindex.html">TQSqlIndex</a> <a name="index"></a>TQSqlCursor::index ( const&nbsp;<a href="ntqstringlist.html">TQStringList</a>&nbsp;&amp;&nbsp;fieldNames ) const<tt> [virtual]</tt>
</h3>
Returns an index composed of <em>fieldNames</em>, all in ASCending
order. Note that all field names must exist in the cursor,
otherwise an empty index is returned.
<p> <p>See also <a href="ntqsqlindex.html">TQSqlIndex</a>.

<p>Examples: <a href="sql.html#x2188">sql/overview/extract/main.cpp</a>, <a href="sql.html#x2181">sql/overview/order1/main.cpp</a>, <a href="sql.html#x2184">sql/overview/order2/main.cpp</a>, and <a href="sql.html#x2241">sql/overview/table3/main.cpp</a>.
<h3 class=fn><a href="ntqsqlindex.html">TQSqlIndex</a> <a name="index-2"></a>TQSqlCursor::index ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;fieldName ) const
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns an index based on <em>fieldName</em>.

<h3 class=fn><a href="ntqsqlindex.html">TQSqlIndex</a> <a name="index-3"></a>TQSqlCursor::index ( const&nbsp;char&nbsp;*&nbsp;fieldName ) const
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns an index based on <em>fieldName</em>.

<h3 class=fn>void <a name="insert"></a>TQSqlCursor::insert ( int&nbsp;pos, const&nbsp;<a href="qsqlfieldinfo.html">TQSqlFieldInfo</a>&nbsp;&amp;&nbsp;fieldInfo )<tt> [virtual]</tt>
</h3>
Insert a copy of <em>fieldInfo</em> at position <em>pos</em>. If a field
already exists at <em>pos</em>, it is removed. Note that all references
to the cursor edit buffer become invalidated.

<p>Examples: <a href="sql.html#x2194">sql/overview/insert/main.cpp</a> and <a href="ntqsqlcursor.html#x2446">sql/overview/insert2/main.cpp</a>.
<h3 class=fn>int <a name="insert-2"></a>TQSqlCursor::insert ( bool&nbsp;invalidate = TRUE )<tt> [virtual]</tt>
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Inserts the current contents of the cursor's edit record buffer
into the database, if the cursor allows inserts. Returns the
number of rows affected by the insert. For error information, use
<a href="ntqsqlquery.html#lastError">lastError</a>().
<p> If <em>invalidate</em> is TRUE (the default), the cursor will no longer
be positioned on a valid record and can no longer be navigated. A
new <a href="#select">select</a>() call must be made before navigating to a valid
record.
<p> 

<pre>            TQSqlCursor cur( "prices" );
    <a name="x2447"></a>        <a href="ntqsqlrecord.html">TQSqlRecord</a> *buffer = cur.<a href="#primeInsert">primeInsert</a>();
    <a name="x2448"></a>        buffer-&gt;<a href="ntqsqlrecord.html#setValue">setValue</a>( "id",    53981 );
            buffer-&gt;<a href="ntqsqlrecord.html#setValue">setValue</a>( "name",  "Thingy" );
            buffer-&gt;<a href="ntqsqlrecord.html#setValue">setValue</a>( "price", 105.75 );
    <a name="x2446"></a>        cur.<a href="#insert">insert</a>();
</pre>
<p> In the above example, a cursor is created on the 'prices' table
and a pointer to the insert buffer is atquired using <a href="#primeInsert">primeInsert</a>().
Each field's value is set to the desired value and then <a href="#insert">insert</a>()
is called to insert the data into the database. Remember: all edit
operations (insert(), <a href="#update">update</a>() and delete()) operate on the
contents of the cursor edit buffer and not on the contents of the
cursor itself.
<p> <p>See also <a href="#setMode">setMode</a>() and <a href="ntqsqlquery.html#lastError">lastError</a>().

<h3 class=fn>bool <a name="isCalculated"></a>TQSqlCursor::isCalculated ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;name ) const
</h3>
Returns TRUE if the field <em>name</em> exists and is calculated;
otherwise returns FALSE.
<p> <p>See also <a href="#setCalculated">setCalculated</a>().

<h3 class=fn>bool <a name="isNull"></a>TQSqlCursor::isNull ( int&nbsp;i ) const
</h3>
Returns TRUE if the field <em>i</em> is NULL or if there is no field at
position <em>i</em>; otherwise returns FALSE.
<p> This is the same as calling <a href="ntqsqlrecord.html#isNull">TQSqlRecord::isNull</a>( <em>i</em> )

<h3 class=fn>bool <a name="isNull-2"></a>TQSqlCursor::isNull ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;name ) const
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns TRUE if the field called <em>name</em> is NULL or if there is no
field called <em>name</em>; otherwise returns FALSE.
<p> This is the same as calling <a href="ntqsqlrecord.html#isNull">TQSqlRecord::isNull</a>( <em>name</em> )

<h3 class=fn>bool <a name="isReadOnly"></a>TQSqlCursor::isReadOnly () const
</h3>
Returns TRUE if the cursor is read-only; otherwise returns FALSE.
The default is FALSE. Read-only cursors cannot be edited using
<a href="#insert">insert</a>(), <a href="#update">update</a>() or <a href="#del">del</a>().
<p> <p>See also <a href="#setMode">setMode</a>().

<h3 class=fn>bool <a name="isTrimmed"></a>TQSqlCursor::isTrimmed ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;name ) const
</h3>
Returns TRUE if the field <em>name</em> exists and is trimmed; otherwise
returns FALSE.
<p> When a trimmed field of type string or cstring is read from the
database any trailing (right-most) spaces are removed.
<p> <p>See also <a href="#setTrimmed">setTrimmed</a>().

<h3 class=fn>int <a name="mode"></a>TQSqlCursor::mode () const
</h3>
Returns the current cursor mode.
<p> <p>See also <a href="#setMode">setMode</a>().

<h3 class=fn><a href="ntqstring.html">TQString</a> <a name="name"></a>TQSqlCursor::name () const
</h3>
Returns the name of the cursor.

<h3 class=fn><a href="ntqsqlcursor.html">TQSqlCursor</a>&nbsp;&amp; <a name="operator-eq"></a>TQSqlCursor::operator= ( const&nbsp;<a href="ntqsqlcursor.html">TQSqlCursor</a>&nbsp;&amp;&nbsp;other )
</h3>
Sets the cursor equal to <em>other</em>.

<h3 class=fn><a href="ntqsqlindex.html">TQSqlIndex</a> <a name="primaryIndex"></a>TQSqlCursor::primaryIndex ( bool&nbsp;setFromCursor = TRUE ) const<tt> [virtual]</tt>
</h3>
Returns the primary index associated with the cursor as defined in
the database, or an empty index if there is no primary index. If
<em>setFromCursor</em> is TRUE (the default), the index fields are
populated with the corresponding values in the cursor's current
record.

<h3 class=fn><a href="ntqsqlrecord.html">TQSqlRecord</a>&nbsp;* <a name="primeDelete"></a>TQSqlCursor::primeDelete ()<tt> [virtual]</tt>
</h3>
This function primes the edit buffer's field values for delete and
returns the edit buffer. The default implementation copies the
field values from the current cursor record into the edit buffer
(therefore, this function is equivalent to calling <a href="#editBuffer">editBuffer</a>(
TRUE ) ). The cursor retains ownership of the returned pointer, so
it must not be deleted or modified.
<p> <p>See also <a href="#editBuffer">editBuffer</a>() and <a href="#del">del</a>().

<p>Example: <a href="sql.html#x2206">sql/overview/delete/main.cpp</a>.
<h3 class=fn><a href="ntqsqlrecord.html">TQSqlRecord</a>&nbsp;* <a name="primeInsert"></a>TQSqlCursor::primeInsert ()<tt> [virtual]</tt>
</h3>
This function primes the edit buffer's field values for insert and
returns the edit buffer. The default implementation clears all
field values in the edit buffer. The cursor retains ownership of
the returned pointer, so it must not be deleted or modified.
<p> <p>See also <a href="#editBuffer">editBuffer</a>() and <a href="#insert">insert</a>().

<p>Examples: <a href="sql.html#x2195">sql/overview/insert/main.cpp</a>, <a href="ntqsqlcursor.html#x2447">sql/overview/insert2/main.cpp</a>, <a href="sql.html#x2267">sql/overview/subclass5/main.cpp</a>, and <a href="sqltable-example.html#x2453">sql/sqltable/main.cpp</a>.
<h3 class=fn><a href="ntqsqlrecord.html">TQSqlRecord</a>&nbsp;* <a name="primeUpdate"></a>TQSqlCursor::primeUpdate ()<tt> [virtual]</tt>
</h3>
This function primes the edit buffer's field values for update and
returns the edit buffer. The default implementation copies the
field values from the current cursor record into the edit buffer
(therefore, this function is equivalent to calling <a href="#editBuffer">editBuffer</a>(
TRUE ) ). The cursor retains ownership of the returned pointer, so
it must not be deleted or modified.
<p> <p>See also <a href="#editBuffer">editBuffer</a>() and <a href="#update">update</a>().

<p>Examples: <a href="sql.html#x2236">sql/overview/custom1/main.cpp</a>, <a href="sql.html#x2223">sql/overview/form1/main.cpp</a>, and <a href="sql.html#x2199">sql/overview/update/main.cpp</a>.
<h3 class=fn>void <a name="remove"></a>TQSqlCursor::remove ( int&nbsp;pos )<tt> [virtual]</tt>
</h3>
Removes the field at <em>pos</em>. If <em>pos</em> does not exist, nothing
happens. Note that all references to the cursor edit buffer become
invalidated.

<p>Reimplemented from <a href="ntqsqlrecord.html#remove">TQSqlRecord</a>.
<h3 class=fn>bool <a name="select"></a>TQSqlCursor::select ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;filter, const&nbsp;<a href="ntqsqlindex.html">TQSqlIndex</a>&nbsp;&amp;&nbsp;sort = TQSqlIndex ( ) )<tt> [virtual]</tt>
</h3>
Selects all fields in the cursor from the database matching the
filter criteria <em>filter</em>. The data is returned in the order
specified by the index <em>sort</em>. Returns TRUE if the data was
successfully selected; otherwise returns FALSE.
<p> The <em>filter</em> is a string containing a SQL <tt>WHERE</tt> clause but
without the 'WHERE' keyword. The cursor is initially positioned at
an invalid row after this function is called. To move to a valid
row, use <a href="ntqsqlquery.html#seek">seek</a>(), <a href="ntqsqlquery.html#first">first</a>(), <a href="ntqsqlquery.html#last">last</a>(), <a href="ntqsqlquery.html#prev">prev</a>() or <a href="ntqsqlquery.html#next">next</a>().
<p> Example:
<pre>
    TQSqlCursor cur( "Employee" ); // Use the Employee table or view
    cur.<a href="#select">select</a>( "deptno=10" ); // select all records in department 10
    while( cur.<a href="ntqsqlquery.html#next">next</a>() ) {
        ... // process data
    }
    ...
    // select records in other departments, ordered by department number
    cur.<a href="#select">select</a>( "deptno&gt;10", cur.<a href="#index">index</a>( "deptno" ) );
    ...
    </pre>
 
<p> The filter will apply to any subsequent <a href="#select">select</a>() calls that do not
explicitly specify another filter. Similarly the sort will apply
to any subsequent select() calls that do not explicitly specify
another sort.
<p> <pre>
    TQSqlCursor cur( "Employee" );
    cur.<a href="#select">select</a>( "deptno=10" ); // select all records in department 10
    while( cur.<a href="ntqsqlquery.html#next">next</a>() ) {
        ... // process data
    }
    ...
    cur.<a href="#select">select</a>(); // re-selects all records in department 10
    ...
    </pre>
 
<p> 
<p>Examples: <a href="sql.html#x2207">sql/overview/delete/main.cpp</a>, <a href="sql.html#x2189">sql/overview/extract/main.cpp</a>, <a href="sql.html#x2182">sql/overview/order1/main.cpp</a>, <a href="sql.html#x2185">sql/overview/order2/main.cpp</a>, <a href="sql.html#x2178">sql/overview/retrieve2/main.cpp</a>, <a href="sql.html#x2242">sql/overview/table3/main.cpp</a>, and <a href="sql.html#x2200">sql/overview/update/main.cpp</a>.
<h3 class=fn>bool <a name="select-2"></a>TQSqlCursor::select ()
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Selects all fields in the cursor from the database. The rows are
returned in the order specified by the last call to <a href="#setSort">setSort</a>() or
the last call to <a href="#select">select</a>() that specified a sort, whichever is the
most recent. If there is no current sort, the order in which the
rows are returned is undefined. The records are filtered according
to the filter specified by the last call to <a href="#setFilter">setFilter</a>() or the
last call to select() that specified a filter, whichever is the
most recent. If there is no current filter, all records are
returned. The cursor is initially positioned at an invalid row. To
move to a valid row, use <a href="ntqsqlquery.html#seek">seek</a>(), <a href="ntqsqlquery.html#first">first</a>(), <a href="ntqsqlquery.html#last">last</a>(), <a href="ntqsqlquery.html#prev">prev</a>() or
<a href="ntqsqlquery.html#next">next</a>().
<p> <p>See also <a href="#setSort">setSort</a>() and <a href="#setFilter">setFilter</a>().

<h3 class=fn>bool <a name="select-3"></a>TQSqlCursor::select ( const&nbsp;<a href="ntqsqlindex.html">TQSqlIndex</a>&nbsp;&amp;&nbsp;sort )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Selects all fields in the cursor from the database. The data is
returned in the order specified by the index <em>sort</em>. The records
are filtered according to the filter specified by the last call to
<a href="#setFilter">setFilter</a>() or the last call to <a href="#select">select</a>() that specified a filter,
whichever is the most recent. The cursor is initially positioned
at an invalid row. To move to a valid row, use <a href="ntqsqlquery.html#seek">seek</a>(), <a href="ntqsqlquery.html#first">first</a>(),
<a href="ntqsqlquery.html#last">last</a>(), <a href="ntqsqlquery.html#prev">prev</a>() or <a href="ntqsqlquery.html#next">next</a>().

<h3 class=fn>bool <a name="select-4"></a>TQSqlCursor::select ( const&nbsp;<a href="ntqsqlindex.html">TQSqlIndex</a>&nbsp;&amp;&nbsp;filter, const&nbsp;<a href="ntqsqlindex.html">TQSqlIndex</a>&nbsp;&amp;&nbsp;sort )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Selects all fields in the cursor matching the filter index <em>filter</em>. The data is returned in the order specified by the index
<em>sort</em>. The <em>filter</em> index works by constructing a WHERE clause
using the names of the fields from the <em>filter</em> and their values
from the current cursor record. The cursor is initially positioned
at an invalid row. To move to a valid row, use <a href="ntqsqlquery.html#seek">seek</a>(), <a href="ntqsqlquery.html#first">first</a>(),
<a href="ntqsqlquery.html#last">last</a>(), <a href="ntqsqlquery.html#prev">prev</a>() or <a href="ntqsqlquery.html#next">next</a>(). This function is useful, for example,
for retrieving data based upon a table's primary index:
<p> <pre>
    TQSqlCursor cur( "Employee" );
    <a href="ntqsqlindex.html">TQSqlIndex</a> pk = cur.<a href="#primaryIndex">primaryIndex</a>();
    cur.<a href="ntqsqlrecord.html#setValue">setValue</a>( "id", 10 );
    cur.<a href="#select">select</a>( pk, pk ); // generates "SELECT ... FROM Employee WHERE id=10 ORDER BY id"
    ...
    </pre>
 
<p> In this example the <a href="ntqsqlindex.html">TQSqlIndex</a>, pk, is used for two different
purposes. When used as the filter (first) argument, the field
names it contains are used to construct the WHERE clause, each set
to the current cursor value, <tt>WHERE id=10</tt>, in this case. When
used as the sort (second) argument the field names it contains are
used for the ORDER BY clause, <tt>ORDER BY id</tt> in this example.

<h3 class=fn>void <a name="setCalculated"></a>TQSqlCursor::setCalculated ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;name, bool&nbsp;calculated )<tt> [virtual]</tt>
</h3>
Sets field <em>name</em> to <em>calculated</em>. If the field <em>name</em> does not
exist, nothing happens. The value of a calculated field is set by
the <a href="#calculateField">calculateField</a>() virtual function which you must reimplement
(or the field value will be an invalid <a href="ntqvariant.html">TQVariant</a>). Calculated
fields do not appear in generated SQL statements sent to the
database.
<p> <p>See also <a href="#calculateField">calculateField</a>() and <a href="ntqsqlrecord.html#setGenerated">TQSqlRecord::setGenerated</a>().

<h3 class=fn>void <a name="setFilter"></a>TQSqlCursor::setFilter ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;filter )<tt> [virtual]</tt>
</h3>
Sets the current filter to <em>filter</em>. Note that no new records are
selected. To select new records, use <a href="#select">select</a>(). The <em>filter</em> will
apply to any subsequent select() calls that do not explicitly
specify a filter.
<p> The filter is a SQL <tt>WHERE</tt> clause without the keyword 'WHERE',
e.g. <tt>name='Dave'</tt> which will be processed by the DBMS.

<h3 class=fn>void <a name="setGenerated"></a>TQSqlCursor::setGenerated ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;name, bool&nbsp;generated )<tt> [virtual]</tt>
</h3>
Sets the generated flag for the field <em>name</em> to <em>generated</em>. If
the field does not exist, nothing happens. Only fields that have
<em>generated</em> set to TRUE are included in the SQL that is
generated by <a href="#insert">insert</a>(), <a href="#update">update</a>() or <a href="#del">del</a>().
<p> <p>See also <a href="ntqsqlrecord.html#isGenerated">isGenerated</a>().

<p>Reimplemented from <a href="ntqsqlrecord.html#setGenerated">TQSqlRecord</a>.
<h3 class=fn>void <a name="setGenerated-2"></a>TQSqlCursor::setGenerated ( int&nbsp;i, bool&nbsp;generated )<tt> [virtual]</tt>
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Sets the generated flag for the field <em>i</em> to <em>generated</em>.
<p> <p>See also <a href="ntqsqlrecord.html#isGenerated">isGenerated</a>().

<p>Reimplemented from <a href="ntqsqlrecord.html#setGenerated-2">TQSqlRecord</a>.
<h3 class=fn>void <a name="setMode"></a>TQSqlCursor::setMode ( int&nbsp;mode )<tt> [virtual]</tt>
</h3>
Sets the cursor mode to <em>mode</em>. This value can be an OR'ed
combination of <a href="#Mode-enum">TQSqlCursor::Mode</a> values. The default mode for a
cursor is <a href="#Mode-enum">TQSqlCursor::Writable</a>.
<p> <pre>
    TQSqlCursor cur( "Employee" );
    cur.<a href="#setMode">setMode</a>( TQSqlCursor::<a href="#Mode-enum">Writable</a> ); // allow insert/update/delete
    ...
    cur.<a href="#setMode">setMode</a>( TQSqlCursor::<a href="#Mode-enum">Insert</a> | TQSqlCursor::<a href="#Mode-enum">Update</a> ); // allow inserts and updates only
    ...
    cur.<a href="#setMode">setMode</a>( TQSqlCursor::<a href="#Mode-enum">ReadOnly</a> ); // no inserts/updates/deletes allowed

    </pre>
 

<h3 class=fn>void <a name="setName"></a>TQSqlCursor::setName ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;name, bool&nbsp;autopopulate = TRUE )<tt> [virtual]</tt>
</h3>
Sets the name of the cursor to <em>name</em>. If <em>autopopulate</em> is TRUE
(the default), the <em>name</em> must correspond to a valid table or
view name in the database. Also, note that all references to the
cursor edit buffer become invalidated when fields are
auto-populated. See the TQSqlCursor constructor documentation for
more information.

<h3 class=fn>void <a name="setPrimaryIndex"></a>TQSqlCursor::setPrimaryIndex ( const&nbsp;<a href="ntqsqlindex.html">TQSqlIndex</a>&nbsp;&amp;&nbsp;idx )<tt> [virtual]</tt>
</h3>
Sets the primary index associated with the cursor to the index <em>idx</em>. Note that this index must contain a field or set of fields
which identify a unique record within the underlying database
table or view so that <a href="#update">update</a>() and <a href="#del">del</a>() will execute as expected.
<p> <p>See also <a href="#update">update</a>() and <a href="#del">del</a>().

<h3 class=fn>void <a name="setSort"></a>TQSqlCursor::setSort ( const&nbsp;<a href="ntqsqlindex.html">TQSqlIndex</a>&nbsp;&amp;&nbsp;sort )<tt> [virtual]</tt>
</h3>
Sets the current sort to <em>sort</em>. Note that no new records are
selected. To select new records, use <a href="#select">select</a>(). The <em>sort</em> will
apply to any subsequent select() calls that do not explicitly
specify a sort.

<h3 class=fn>void <a name="setTrimmed"></a>TQSqlCursor::setTrimmed ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;name, bool&nbsp;trim )<tt> [virtual]</tt>
</h3>
Sets field <em>name</em>'s trimmed status to <em>trim</em>. If the field <em>name</em> does not exist, nothing happens.
<p> When a trimmed field of type string or cstring is read from the
database any trailing (right-most) spaces are removed.
<p> <p>See also <a href="#isTrimmed">isTrimmed</a>() and <a href="ntqvariant.html">TQVariant</a>.

<h3 class=fn><a href="ntqsqlindex.html">TQSqlIndex</a> <a name="sort"></a>TQSqlCursor::sort () const
</h3>
Returns the current sort, or an empty index if there is no current
sort.

<h3 class=fn><a href="ntqstring.html">TQString</a> <a name="toString"></a>TQSqlCursor::toString ( <a href="ntqsqlrecord.html">TQSqlRecord</a>&nbsp;*&nbsp;rec, const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;prefix, const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;fieldSep, const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;sep ) const<tt> [virtual protected]</tt>
</h3>
Returns a formatted string composed of all the fields in <em>rec</em>.
Each field is composed of the <em>prefix</em> (e.g. table or view name),
".", the field name, the <em>fieldSep</em> and the field value. If the
<em>prefix</em> is empty then each field will begin with the field name.
The fields are then joined together separated by <em>sep</em>. Fields
where <a href="ntqsqlrecord.html#isGenerated">isGenerated</a>() returns FALSE are not included. This function
is useful for generating SQL statements.

<h3 class=fn><a href="ntqstring.html">TQString</a> <a name="toString-3"></a>TQSqlCursor::toString ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;prefix, <a href="ntqsqlfield.html">TQSqlField</a>&nbsp;*&nbsp;field, const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;fieldSep ) const<tt> [virtual protected]</tt>
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns a formatted string composed of the <em>prefix</em> (e.g. table
or view name), ".", the <em>field</em> name, the <em>fieldSep</em> and the
field value. If the <em>prefix</em> is empty then the string will begin
with the <em>field</em> name. This function is useful for generating SQL
statements.

<h3 class=fn><a href="ntqstring.html">TQString</a> <a name="toString-4"></a>TQSqlCursor::toString ( const&nbsp;<a href="ntqsqlindex.html">TQSqlIndex</a>&nbsp;&amp;&nbsp;i, <a href="ntqsqlrecord.html">TQSqlRecord</a>&nbsp;*&nbsp;rec, const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;prefix, const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;fieldSep, const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;sep ) const<tt> [virtual protected]</tt>
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns a formatted string composed of all the fields in the index
<em>i</em>. Each field is composed of the <em>prefix</em> (e.g. table or view
name), ".", the field name, the <em>fieldSep</em> and the field value.
If the <em>prefix</em> is empty then each field will begin with the field
name. The field values are taken from <em>rec</em>. The fields are then
joined together separated by <em>sep</em>. Fields where <a href="ntqsqlrecord.html#isGenerated">isGenerated</a>()
returns FALSE are ignored. This function is useful for generating
SQL statements.

<h3 class=fn>int <a name="update"></a>TQSqlCursor::update ( bool&nbsp;invalidate = TRUE )<tt> [virtual]</tt>
</h3>
Updates the database with the current contents of the edit buffer.
Returns the number of records which were updated.
For error information, use <a href="ntqsqlquery.html#lastError">lastError</a>().
<p> Only records which meet the filter criteria specified by the
cursor's primary index are updated. If the cursor does not contain
a primary index, no update is performed and 0 is returned.
<p> If <em>invalidate</em> is TRUE (the default), the current cursor can no
longer be navigated. A new <a href="#select">select</a>() call must be made before you
can move to a valid record. For example:
<p> 

<pre>            TQSqlCursor cur( "prices" );
    <a name="x2200"></a>        cur.<a href="#select">select</a>( "id=202" );
            if ( cur.<a href="ntqsqlquery.html#next">next</a>() ) {
    <a name="x2199"></a>            <a href="ntqsqlrecord.html">TQSqlRecord</a> *buffer = cur.<a href="#primeUpdate">primeUpdate</a>();
    <a name="x2204"></a>            double price = buffer-&gt;<a href="ntqsqlrecord.html#value">value</a>( "price" ).toDouble();
                double newprice = price * 1.05;
    <a name="x2203"></a>            buffer-&gt;<a href="ntqsqlrecord.html#setValue">setValue</a>( "price", newprice );
    <a name="x2201"></a>            cur.<a href="#update">update</a>();
            }
</pre>
<p> In the above example, a cursor is created on the 'prices' table
and is positioned on the record to be updated. Then a pointer to
the cursor's edit buffer is actquired using <a href="#primeUpdate">primeUpdate</a>(). A new
value is calculated and placed into the edit buffer with the
<a href="ntqsqlrecord.html#setValue">setValue</a>() call. Finally, an <a href="#update">update</a>() call is made on the cursor
which uses the tables's primary index to update the record in the
database with the contents of the cursor's edit buffer. Remember:
all edit operations (<a href="#insert">insert</a>(), update() and delete()) operate on
the contents of the cursor edit buffer and not on the contents of
the cursor itself.
<p> Note that if the primary index does not uniquely distinguish
records the database may be changed into an inconsistent state.
<p> <p>See also <a href="#setMode">setMode</a>() and <a href="ntqsqlquery.html#lastError">lastError</a>().

<p>Example: <a href="sql.html#x2201">sql/overview/update/main.cpp</a>.
<h3 class=fn>int <a name="update-2"></a>TQSqlCursor::update ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;filter, bool&nbsp;invalidate = TRUE )<tt> [virtual protected]</tt>
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Updates the database with the current contents of the cursor edit
buffer using the specified <em>filter</em>. Returns the number of
records which were updated.
For error information, use <a href="ntqsqlquery.html#lastError">lastError</a>().
<p> Only records which meet the filter criteria are updated, otherwise
all records in the table are updated.
<p> If <em>invalidate</em> is TRUE (the default), the cursor can no longer
be navigated. A new <a href="#select">select</a>() call must be made before you can move
to a valid record.
<p> <p>See also <a href="#primeUpdate">primeUpdate</a>(), <a href="#setMode">setMode</a>(), and <a href="ntqsqlquery.html#lastError">lastError</a>().

<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">TQt toolkit</a>.
Copyright &copy; 1995-2007
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>TQt 3.3.8</div>
</table></div></address></body>
</html>