/usr/share/doc/libxbase-dev/html/xbc17.htm is in libxbase64-dev 3.1.2-0ubutu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | <!DOCTYPE HTML PUBLIC>
<HTML>
<TITLE>Xbase DBMS Chapter 17</TITLE>
<BODY BGCOLOR=#FFFFFF>
<H1><p align="center">Index Methods</p></H1>
<p align="center">Chapter Updated 2/12/99</p><hr>
This chapter lists the xbNdx and xbNtx index methods and provides
examples of how to use them.<br><br>
There are many methods in the xbNdx and xbNtx classes which are used for
maintaining and updating NDX and NTX files. Fortunately for the
application programmer, most of the complexities of dealing with the
NDX and NTX indices are automatically cared for by the Xbase library.<br><br>
xbNdx and xbNtx methods which are used by application programs are documented here.
With some exceptions (OpenIndex,CloseIndex and KeyExists) using the index
routines automatically positions and returns the associated record in
the DBF database.<br><br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Xbase xbNdx Index Method List</h3></CAPTION>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Method<TD>Description
<TR><TH ALIGN="LEFT">CheckIndxIntegrity<TD>Checks an index file for integrity
<TR><TH ALIGN="LEFT">CloseIndex<TD>Optional, closes an index. Closing
the DBF file will close any open indexes.
<TR><TH ALIGN="LEFT">CreateIndex<TD>Create an index
<TR><TH ALIGN="LEFT">FindKey<TD>Find a key in an index file
<TR><TH ALIGN="LEFT">GetFirstKey<TD>Get the first key in an index
<TR><TH ALIGN="LEFT">GetLastKey<TD>Get the last key in an index
<TR><TH ALIGN="LEFT">GetNextKey<TD>Get the next key in an index
<TR><TH ALIGN="LEFT">GetPrevKey<TD>Get the previous key in an index
<TR><TH ALIGN="LEFT">KeyExists<TD>Determine if a key exists w/o positioning DBF file
<TR><TH ALIGN="LEFT">OpenIndex<TD>Open an index
<TR><TH ALIGN="LEFT">ReIndex<TD>Rebuilds an index
</TABLE>in
<BR><BR>
<hr>
<h2>Method Definitions</h2>
<hr>
<h3>Method xbShort xbNdx::CheckIndexIntegrity( xbShort option )</h3>
<h3>Method xbShort xbNtx::CheckIndexIntegrity( xbShort option )</h3><br>
This method checks an open index for accuracy or file corruption.
If the option is non zero, the method will display informational messages.<br>
<br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>If there is no error
<TR><TH ALIGN="LEFT">XB_LOCK_FAILED<TD>Read lock not successfull
<TR><TH ALIGN="LEFT">XB_NOT_OPEN<TD>File not open
<TR><TH ALIGN="LEFT">XB_INVALID_RECORD<TD>Invalid record number
<TR><TH ALIGN="LEFT">XB_SEEK_ERROR<TD>Seek routine error
<TR><TH ALIGN="LEFT">XB_WRITE_ERROR<TD>Write routine error
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/checkndx.cpp">checkndx.cpp</A> for an example
of how to use this method.
<hr>
<h3>Method xbShort xbNdx::CloseIndex( VOID )</h3>
<h3>Method xbShort xbNtx::CloseIndex( VOID )</h3><br>
This method closes an open NDX index. NDX indexes are closed automatically
by the DBF::CloseDatabase routine, so this is an optional method.
Closed indices are not updated by the Xbase routines.<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>If there is no error
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample1.cpp">sample1.cpp</A> for an example
of how to use this method.
<hr>
<h3>Method xbShort xbNdx::CreateIndex( char * IndexName, char * KeyExpression,
xbShort Unique, xbShort OverLay )</h3>
<h3>Method xbShort xbNtx::CreateIndex( char * IndexName, char * KeyExpression,
xbShort Unique, xbShort OverLay )</h3><br>
This method creates an index. Indices are created as either a
character based index or a numeric based index, depending on the KeyExpression
value.<br><br>
<li><em>Indexname</em> - is the name of the physical index file name.
<li><em>KeyExpression</em> - is the key of the index.
<li><em>Unique</em> - XB_UNIQUE or XB_NOT_UNIQUE
<li><em>Overlay</em> - XB_OVERLAY or XB_DONTOVERLAY<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>If there is no error
<TR><TH ALIGN="LEFT">XB_NO_MEMORY<TD>Memory error
<TR><TH ALIGN="LEFT">XB_OPEN_ERROR<TD>Could not open index file
<TR><TH ALIGN="LEFT">XB_INVALID_KEY_EXPRESSION<TD>Bad index key expression
<TR><TH ALIGN="LEFT">XB_NOT_OPEN<TD>The database was not open
<TR><TH ALIGN="LEFT">XB_SEEK_ERROR<TD>Seek error encountered
<TR><TH ALIGN="LEFT">XB_READ_ERROR<TD>Read error encountered
</TABLE>
<br><br>
Index expressions can be a single field or multiple fields. Assuming a
database has fields LASTNAME and FIRSTNAME, valid index expressions
could be:<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Sample Index Expressions</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Expression<TD>Description
<TR><TH ALIGN="LEFT">"LASTNAME"<TD>Index on LASTNAME only.
<TR><TH ALIGN="LEFT">"LASTNAME+FIRSTNAME"<TD>Index on LASTNAME and FIRSTNAME
<TR><TH ALIGN="LEFT">"LASTNAME-FIRSTNAME"<TD>Index on LASTNAME and FIRSTNAME,
all spaces between the two fields removed.
<TR><TH ALIGN="LEFT">"LASTNAME-','FIRSTNAME"<TD>Index on LASTNAME and
FIRSTNAME, insert a comma between the two values, remove spaces between
the two fields.
</TABLE>
<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><H3>Allowable Index Expression Operators</H3>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Operator<TD>Key Type<TD>Description
<TR><TH ALIGN="LEFT">+<TD>Character<TD>Concatonate string fields
<TR><TH ALIGN="LEFT">-<TD>Character<TD>
Concatonate string fields, remove trailing spaces
<TR><TH ALIGN="LEFT">'literal'<TD>Character<TD>include literal value
<TR><TH ALIGN="LEFT">"literal"<TD>Character<TD>include literal value
<TR><TH ALIGN="LEFT">+<TD>Numeric<TD>Add two numeric fields togethor
<TR><TH ALIGN="LEFT">-<TD>Numeric<TD>Subtract one numeric field from another
<TR><TH ALIGN="LEFT">*<TD>Numeric<TD>Mulitply two numeric fields togethor
<TR><TH ALIGN="LEFT">/<TD>Numeric<TD>Divide one numeric field into another
<TR><TH ALIGN="LEFT">**<TD>Numeric<TD>Exponential
</TABLE>
<br><br>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample1.cpp">sample1.cpp</A> for an example
of how to use this method.
<hr>
<h3>Method xbShort xbNdx::FindKey( char * SearchValue )</h3>
<h3>Method xbShort xbNdx::FindKey( xbDouble SearchValue )</h3>
<h3>Method xbShort xbNtx::FindKey( char * SearchValue )</h3>
<h3>Method xbShort xbNtx::FindKey( xbDouble SearchValue )</h3><br>
This method searches the index for key <em>SearchValue</em>.
The routine positions in the index, then positions to the database record
for the key. If the key is not
found, the key value that is the next higher value is returned.<br><br>
For character keys, the SearchValue should be a null terminated string.
To find an exact match, use a key value which is as long as the key is,
padded on the right with spaces.<br><br>
For numeric keys, use a xbDouble value for a search value. This is because
all numeric field indices are saved as double values.<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_FOUND<TD>The key was found
<TR><TH ALIGN="LEFT">XB_NOT_FOUND<TD>The key was not found
<TR><TH ALIGN="LEFT">XB_NO_MEMORY<TD>Memory error
<TR><TH ALIGN="LEFT">XB_OPEN_ERROR<TD>Could not open index file
<TR><TH ALIGN="LEFT">XB_SEEK_ERROR<TD>Seek error encountered
<TR><TH ALIGN="LEFT">XB_READ_ERROR<TD>Read error encountered
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample5.cpp">sample5.cpp</A> for an example
of how to use this method.
<hr>
<h3>Method xbShort xbNdx::GetFirstKey( VOID )</h3>
<h3>Method xbShort xbNtx::GetFirstKey( VOID )</h3><br>
This method retrieves the record for the first key in the index.<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>If there is no error
<TR><TH ALIGN="LEFT">XB_NO_MEMORY<TD>Memory error
<TR><TH ALIGN="LEFT">XB_OPEN_ERROR<TD>Could not open index file
<TR><TH ALIGN="LEFT">XB_SEEK_ERROR<TD>Seek error encountered
<TR><TH ALIGN="LEFT">XB_READ_ERROR<TD>Read error encountered
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample5.cpp">sample5.cpp</A> for an example
of how to use this method.
<hr>
<h3>Method xbShort xbNdx::GetLastKey( VOID )</h3>
<h3>Method xbShort xbNtx::GetLastKey( VOID )</h3><br>
This method retrieves the record for the last key in the index.<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>If there is no error
<TR><TH ALIGN="LEFT">XB_NO_MEMORY<TD>Memory error
<TR><TH ALIGN="LEFT">XB_OPEN_ERROR<TD>Could not open index file
<TR><TH ALIGN="LEFT">XB_SEEK_ERROR<TD>Seek error encountered
<TR><TH ALIGN="LEFT">XB_READ_ERROR<TD>Read error encountered
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample5.cpp">sample5.cpp</A> for an example
of how to use this method.
<hr><h3>Method xbShort xbNdx::GetNextKey( VOID )</h3><br>
This method retrieves the record for the next key in the index. If the
index is not positioned, a call to GetFirstKey is autoamtically executed.<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>If there is no error
<TR><TH ALIGN="LEFT">XB_NO_MEMORY<TD>Memory error
<TR><TH ALIGN="LEFT">XB_OPEN_ERROR<TD>Could not open index file
<TR><TH ALIGN="LEFT">XB_SEEK_ERROR<TD>Seek error encountered
<TR><TH ALIGN="LEFT">XB_READ_ERROR<TD>Read error encountered
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample5.cpp">sample5.cpp</A> for an example
of how to use this method.
<hr><h3>Method xbShort xbNdx::GetPrevKey( VOID )</h3>
<hr><h3>Method xbShort xbNtx::GetPrevKey( VOID )</h3><br>
This method retrieves the record for the previous key in the index. If the
index is not positioned, a call to GetLastKey is autoamtically executed.<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>If there is no error
<TR><TH ALIGN="LEFT">XB_NO_MEMORY<TD>Memory error
<TR><TH ALIGN="LEFT">XB_OPEN_ERROR<TD>Could not open index file
<TR><TH ALIGN="LEFT">XB_SEEK_ERROR<TD>Seek error encountered
<TR><TH ALIGN="LEFT">XB_READ_ERROR<TD>Read error encountered
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample5.cpp">sample5.cpp</A> for an example
of how to use this method.
<hr>
<h3>Method xbShort xbNdx::KeyExists( char * SearchValue )</h3>
<h3>Method xbShort xbNdx::KeyExists( xbDouble SearchValue )</h3>
<h3>Method xbShort xbNtx::KeyExists( char * SearchValue )</h3>
<h3>Method xbShort xbNtx::KeyExists( xbDouble SearchValue )</h3><br>
This method searches the index for the key <em>SearchValue</em>. The routine does not
position the database record for the key. See the reference on FindKey for more
information regarding KeyValue.<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_FOUND<TD>The key was found
<TR><TH ALIGN="LEFT">XB_NOT_FOUND<TD>The key was not found
<TR><TH ALIGN="LEFT">XB_NO_MEMORY<TD>Memory error
<TR><TH ALIGN="LEFT">XB_OPEN_ERROR<TD>Could not open index file
<TR><TH ALIGN="LEFT">XB_SEEK_ERROR<TD>Seek error encountered
<TR><TH ALIGN="LEFT">XB_READ_ERROR<TD>Read error encountered
</TABLE>
<h4>Example Program:</h4>
<xmp>
if( xbNdx::KeyExists( "MyKeyValue" ))
cout << "\nKey was found";
else
cout << "\nKey was not found";
</xmp>
<hr>
<h3>Method xbShort xbNdx::OpenIndex( char * IndexName )</h3>
<h3>Method xbShort xbNtx::OpenIndex( char * IndexName )</h3><br>
This method opens index <em>IndexName</em> for a given DBF database. An index must be
opened before it will be automatically updated by the database update
routines.<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>If there is no error
<TR><TH ALIGN="LEFT">XB_NO_MEMORY<TD>Memory error
<TR><TH ALIGN="LEFT">XB_OPEN_ERROR<TD>Could not open index file
<TR><TH ALIGN="LEFT">XB_INVALID_KEY_EXPRESSION<TD>Bad key in index
<TR><TH ALIGN="LEFT">XB_NOT_OPEN<TD>The database was not open
<TR><TH ALIGN="LEFT">XB_SEEK_ERROR<TD>Seek error encountered
<TR><TH ALIGN="LEFT">XB_READ_ERROR<TD>Read error encountered
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample1.cpp">sample1.cpp</A> for an example
of how to use this method.
<hr>
<h3>Method xbShort xbNdx::ReIndex( VOID )</h3>
<h3>Method xbShort xbNtx::ReIndex( VOID )</h3><br>
This method rebuilds an index. It is used for optimizing an index, or recreating
a damaged index. If the index is severly damaged (ie; the first 512 bytes are
foobar) then the index must be recreated with the CreateIndex method before
using the ReIndex method.<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>If there is no error
<TR><TH ALIGN="LEFT">XB_OPEN_ERROR<TD>Could not open index file
<TR><TH ALIGN="LEFT">XB_WRITE_ERROR<TD>Error writing data
<TR><TH ALIGN="LEFT">XB_CLOSE_ERROR<TD>Error closing work file
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/reindex.cpp">reindex.cpp</A> for an example
of how to use this method.<br><br>
<hr>
<p><img src="xbase.jpg"><br><hr>
</BODY>
</HTML>
|