Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 57254662b08bab0259d9d4ac98ef679c > files > 44

lib64xbase2-devel-2.0.0-7mdv2008.1.x86_64.rpm

<!DOCTYPE xbHtml PUBLIC>
<xbHtml>
<TITLE>Xbase DBMS Chapter 12</TITLE>
<BODY BGCOLOR=#FFFFFF>
<H1><p align="center">Database Methods</p></H1>
<p align="center">Chapter Updated 1/30/99</p><hr>
<br>
This chapter lists the database methods and provides links to examples of how 
to use them.<br><br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Xbase Database Method List</h3></CAPTION>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Method<TD>Description
<TR><TH ALIGN="LEFT">xbShort rc AppendRecord()<TD>Append a new record to the end of an open database
<TR><TH ALIGN="LEFT">void AutoLockOn()<TD>Turns on automatic record locking (see locking chapter)
<TR><TH ALIGN="LEFT">void AutoLockOff()<TD>Turns off automatic record locking (see locking chapter)
<TR><TH ALIGN="LEFT">void BlankRecord()<TD>Fill the current record buffer with blanks
<TR><TH ALIGN="LEFT">xbLong csum CalcCheckSum()<TD>Calculate checksum on a data record
<TR><TH ALIGN="LEFT">xbShort rc CloseDatabase()<TD>Close an open database
<TR><TH ALIGN="LEFT">xbShort rc CopyDbfStructure(<br> char * NewFileName,<br>
   xbShort OverlaySwitch )<TD>Copies the structure of a xbDbf file to a new file
<TR><TH ALIGN="LEFT">xbShort rc CreateDatabase(<br>char * FileName,
  XbSchema *s, xbShort OverlaySwitch )<TD>Close an open database
<TR><TH ALIGN="LEFT">xbULong CurrentRecNo()<TD>Returns the current record number
<TR><TH ALIGN="LEFT">xbShort rc DeleteAllRecords()<TD>Mark all records for deletion
<TR><TH ALIGN="LEFT">xbShort rc DeleteRecord()<TD>Mark a record for deletion
<TR><TH ALIGN="LEFT">xbShort rc DumpHeader(xbShort option)<TD>Display information about a .DBF file header
<TR><TH ALIGN="LEFT">xbShort rc DumpRecord(<br>xbULong RecNo)<TD>Dump a record for a database 
<TR><TH ALIGN="LEFT">xbLong cnt FieldCount()<TD>Returns number of fields in database
<TR><TH ALIGN="LEFT">xbLong recno GetCurRecNo()<TD>Returns current record number
<TR><TH ALIGN="LEFT">xbShort rc GetFirstRecord()<TD>Get the first record in the database
<TR><TH ALIGN="LEFT">xbShort rc GetLastRecord()<TD>Get the last record in the database
<TR><TH ALIGN="LEFT">xbShort rc GetNextRecord()<TD>Get the next record in the database
<TR><TH ALIGN="LEFT">xbShort rc GetPrevRecord()<TD>Get the previous record in the database
<TR><TH ALIGN="LEFT">xbShort rc GetRecord(xbLong RecNo)<TD>Get a record by record number from an open database
<TR><TH ALIGN="LEFT">char * buf GetRecordBuf()<TD>Returns a pointer to the record buffer
<TR><TH ALIGN="LEFT">xbLong RecCnt NoOfRecords()<TD>Returns the number of records in an open database
<TR><TH ALIGN="LEFT">xbShort rc OpenDatabase(char * FileName)<TD>Open an existing database
<TR><TH ALIGN="LEFT">xbShort rc PackDatabase(<br>xbShort WaitOption)<TD>Compress file and remove deleted records
<TR><TH ALIGN="LEFT">xbShort rc PutRecord(xbULong RecNo)<TD>Put a record in an open database  
<TR><TH ALIGN="LEFT">xbShort rc RebuildAllIndices()<TD>Rebuilds all open indices
<TR><TH ALIGN="LEFT">xbShort dflag RecordDeleted()<TD>Determine if a record has been deleted
<TR><TH ALIGN="LEFT">xbShort version SetVersion(xbShort Ver)<TD>Set version to xbase III+ or IV style xbDbf files
<TR><TH ALIGN="LEFT">xbShort rc UndeleteAllRecords()<TD>Unmark all deleted records 
<TR><TH ALIGN="LEFT">xbShort rc UndeleteRecord()<TD>Unmark a deleted record
<TR><TH ALIGN="LEFT">xbShort rc Zap(xbShort WaitOption)<TD>Deletes all records from a database
</TABLE>
<BR><BR><hr>
<h2>Method Definitions</h2>
<hr>
<h3>Method xbShort xbDbf::AppendRecord( void )</h3><br>
This method appends the contents of the database record buffer to the end of
the .DBF file and updates the date and number of records in the header of the
datafile.<br><br>
This method also updates any open indexes associated with the database.<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_LOCK_FAILED<TD>Write lock not successful
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>If there is no error
<TR><TH ALIGN="LEFT">XB_WRITE_ERROR<TD>Unsuccessful write operation
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample2.cpp">sample2.cpp</A> for an example 
of how to use this method.
<hr>
<h3>Method xbShort xbDbf::BlankRecord( void )</h3><br>
This method overlays the database record buffer with space (0x20)
CHARacters.  This method is useful for initializing the record buffer.<br>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample2.cpp">sample2.cpp</A> for an example of 
how to use this method.
<hr>

<h3>Method xbLong xbDbf::CalcCheckSum( void )</h3><br>
This method calculates the checksum of a database record.
<hr>

<h3>Method xbShort xbDbf::CloseDatabase( void )</h3><br>
This method closes an Xbase (.DBF) file
which was previously opened by CreateDatabase or OpenDatabase
and frees any previously allocated memory which is no LONGer needed.<br><br>
This method automatically closes any open indexes associated with the
database before closing the database.<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_NOT_OPEN<TD>If there is no error
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample2.cpp">sample2.cpp</A> for an example 
of how to use this method.
<hr>


<h3>Method xbShort xbDbf::CopyDbfStructure( char *NewFileName, xbShort OverLay )</h3><br>
This method copies the structure of an Xbase (.DBF) file to file <em>NewFileName</em>.
If there are memo fields, they are included.
<br><br>
The <em>OverLay</em> switch is
used to determine what to do if a xbDbf file with the same name
already exists.  If <em>OverLay</em> is set to XB_OVERLAY and the file exists, 
the file is overwritten, otherwise an error is returned.<br><br>
<em>Overlay Switch</em> is:<br>
<li>XB_OVERLAY = Overlay file if it exists<br>
<li>XB_DONTOVERLAY = Return with error if file exists<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_FILE_EXISTS<TD>If a file exists and OverLay switch = FALSE
<TR><TH ALIGN="LEFT">XB_OPEN_ERROR<TD>Couldn't open the file
<TR><TH ALIGN="LEFT">XB_NO_MEMORY<TD>Memory allocation error
<TR><TH ALIGN="LEFT">XB_WRITE_ERROR<TD>Couldn't write to disk
<TR><TH ALIGN="LEFT">XB_SEEK_ERROR<TD>Seek routine error
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/copydbf.cpp">copydbf.cpp</A> for an example 
of how to use this method.
<hr>


<h3>Method:   xbShort xbDbf::CreateDatabase( char *FileName, 
  xbSchema *s, xbShort OverLay )</h3><br>
This method creates an Xbase (.DBF) file with the name
of FileName and builds the header record with the format as
defined in the <em>xbSchema</em> parameter.  The <em>OverLay</em> switch is
used to determine what to do if a xbDbf file with the same name
already exists.  If <em>OverLay</em> is set to XB_OVERLAY and the file exists, 
the file is overwritten, otherwise an error is returned.<br><br>
<em>Overlay Switch</em> is:<br>
<li>XB_OVERLAY = Overlay file if it exists<br>
<li>XB_DONTOVERLAY = Return with error if file exists<br><br>
<em>xbSchema</em> has the following format:<br>
<xmp>
xbSchema MyRecordSchema[] = 
{
   { FieldName,  Type, FieldLength, NoOfDecimals },
   { FieldName2, Type, FieldLength, NoOfDecimals },
      ...
   { "",0,0,0 }
};
</xmp>
Where:<br>
<li><em>FieldName</em> is the name of the data field.<br>
<li><em>Type</em><br><br>
<h4>Version 1.7.4 and greater:</h4>
XB_CHAR_FLD or C<br>
XB_DATE_FLD or D<br>
XB_LOGICAL_FLD or L<br>
XB_MEMO_FLD or M<br>
XB_FLOAT_FLD or F<br>
XB_NUMERIC_FLD or N<br><br>
<li><em>FieldLength</em> is the length of the field.<br>
<li><em>NoOfDecimals</em> is the number of decimals for NUMERIC fields.<br>
<br>
The record buffer is automatically set to spaces when this method is called.
<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_FILE_EXISTS<TD>If a file exists and OverLay switch = FALSE
<TR><TH ALIGN="LEFT">XB_OPEN_ERROR<TD>Couldn't open the file
<TR><TH ALIGN="LEFT">XB_NO_MEMORY<TD>Memory allocation error
<TR><TH ALIGN="LEFT">XB_WRITE_ERROR<TD>Couldn't write to disk
</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 xbULong xbDbf::CurrentRecNo( void )</h3><br>
This method returns the current record number.<br><br>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/dumprecs.cpp">dumprecs.cpp</A> for an example 
of how to use this method.

<hr>
<h3>Method xbShort xbDbf::DeleteAllRecords( void )</h3><br>
This method marks all unmarked records in the database for deletion.<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>No error encountered
<TR><TH ALIGN="LEFT">XB_INVALID_RECORD<TD>Could not mark record
<TR><TH ALIGN="LEFT">XB_NOT_OPEN<TD>If the file is not open
<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/deletall.cpp">deletall.cpp</A> for an example 
of how to use this method.

<hr>
<h3>Method xbShort xbDbf::DeleteRecord( void )</h3><br>
This method marks the current record for deletion in the database.<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>No error encountered
<TR><TH ALIGN="LEFT">XB_INVALID_RECORD<TD>Could not mark record
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample4.cpp">sample4.cpp</A> for an example 
of how to use this method.

<hr>
<h3>Method xbShort xbDbf::DumpHeader( xbShort Option )</h3><br>
This method displays information about a .DBF file header to stdout.  
This method is only available if the DEBUG option is turned on in the
<em>options.h</em> file<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Options</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Option<TD>Action
<TR><TH ALIGN="LEFT">1<TD>Print Header Only
<TR><TH ALIGN="LEFT">2<TD>Field Data Only
<TR><TH ALIGN="LEFT">3<TD>Header and Field Data 
</TABLE>
<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_INVALID_OPTION<TD>Option must be 1,2 or 3
<TR><TH ALIGN="LEFT">XB_NOT_OPEN<TD>File is not open
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>No error encountered
</TABLE>
<br>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/dumphdr.cpp">dumphdr.cpp</A> for an 
example of how to use this method.

<hr>
<h3>Method xbShort xbDbf::DumpRecord( xbULong RecNo )</h3><br>
This method dumps record RecNo for the database to stdout.<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>No error encountered
<TR><TH ALIGN="LEFT">XB_INVALID_RECORD<TD>Invalid record for RecNo parameter
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/dumprecs.cpp">dumprecs.cpp</A> for an 
example of how to use this method.
<hr>
<h3>Method xbLong xbDbf::FieldCount( void )</h3><br>
This method returns the number of fields defined in the database.
<br><br>
<hr>
<h3>Method xbLong xbDbf::GetCurRecNo( void )</h3><br>
This method returns the current record number of the record in the record buffer.
<br><br>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample3.cpp">sample3.cpp</A> for an 
example of how to use this method.
<hr>
<h3>Method xbShort xbDbf::GetFirstRecord( void )</h3><br>
This method loads the first record of the file into the record buffer.<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_INVALID_RECORD<TD>Invalid record number
<TR><TH ALIGN="LEFT">XB_LOCK_FAILED<TD>Unsuccessful lock operation
<TR><TH ALIGN="LEFT">XB_NOT_OPEN<TD>If the file is not open
<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/sample3.cpp">sample3.cpp</A> for an 
example of how to use this method.
<hr>
<h3>Method xbShort xbDbf::GetLastRecord( void )</h3><br>

This method loads the last record of the file into the record buffer.<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_LOCK_FAILED<TD>Read lock not successful
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>If there is no error
<TR><TH ALIGN="LEFT">XB_EOF<TD>At end of file
<TR><TH ALIGN="LEFT">XB_NOT_OPEN<TD>If the file is 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/sample3.cpp">sample3.cpp</A> for an example 
of how to use this method.
<hr>
<h3>Method xbShort xbDbf::GetNextRecord( void )</h3><br>

This method loads the next record of the file into the record buffer.<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_LOCK_FAILED<TD>Read lock not successful
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>If there is no error
<TR><TH ALIGN="LEFT">XB_EOF<TD>At end of file
<TR><TH ALIGN="LEFT">XB_NOT_OPEN<TD>If the file is 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>
</TABLE>

<h4>Example Program:</h4>

See program <A HREF="/XbaseSamples/sample3.cpp">sample3.cpp</A> for an 
example of how to use this method.
<hr>
<h3>Method xbShort xbDbf::GetPrevRecord( void )</h3><br>

This method loads the previous record of the file into the record buffer.<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_LOCK_FAILED<TD>Read lock not successful
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>If there is no error
<TR><TH ALIGN="LEFT">XB_BOF<TD>At beginning of file
<TR><TH ALIGN="LEFT">XB_NOT_OPEN<TD>If the file is 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/sample3.cpp">sample3.cpp</A> for an 
example of how to use this method.
<hr>
<h3>Method xbShort xbDbf::GetRecord( xbLong RecNo )</h3><br>
This method retrieves record RecNo from the database into the record buffer.
<br><br>
This method will call the PutRec method and flush all updates to disk if
necessary before moving to the specified record.  If PutRecord is not
successful, this method will return the return code from PutRecord.<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_LOCK_FAILED<TD>Read lock not successful
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>If there is no error
<TR><TH ALIGN="LEFT">XB_NOT_OPEN<TD>If the file is 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/sample3.cpp">sample3.cpp</A> for an 
example of how to use this method.
<hr>
<h3>Method char * xbDbf::GetRecordBuf( void )</h3><br>
This method returns a pointer to the record buffer.
<br><br>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample3.cpp">sample3.cpp</A> for an 
example of how to use this method.
<hr>
<h3>Method xbLong xbDbf::NoOfRecords( void )</h3><br>
This method returns the number of records in the file.<br><br>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample3.cpp">sample3.cpp</A> for an 
example of how to use this method.
<hr>
<h3>Method xbShort xbDbf::OpenDatabase( char * FileName )</h3><br>
This method opens an Xbase (.DBF) file with the name
of FileName.  <em>FileName</em> must a valid filename which can include
drives identifier, directory, filename and extension. <br><br>
The OpenDatabase method does not position to any any particular
data record.  After opening a database, use GetRecord, GetFirstRecord
or GetLastRecord to position to a particular data record and load
a data record into the record buffer.<br><br>
The record buffer is automatically set to spaces when this method is called.
<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>Couldn't open the file
<TR><TH ALIGN="LEFT">XB_NO_MEMORY<TD>Memory allocation error
<TR><TH ALIGN="LEFT">XB_NOT_XBASE<TD>Not an xbXBase type file
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample2.cpp">sample2.cpp</A> for an 
example of how to use this method.
<hr>
<h3>Method xbShort xbDbf::PackDatabase( xbShort WaitOption )</h3><br>
This method removes all records marked for deletion from an Xbase (.DBF) file
and reindexes any open index files.  This method also reorganizes any memo
fields stored in a .DBT memo file.
<br><br>
<em>WaitOption</em> is one of:<br><br>
<li>F_SETLK - returns if the xbDbf file can not be exclusively locked
<li>F_SETLKW - will wait to execute until it can exclusively lock the file
<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_CLOSE_ERROR<TD>If intermediate work file can not be closed
<TR><TH ALIGN="LEFT">XB_OPEN_ERROR<TD>Could not open file
<TR><TH ALIGN="LEFT">XB_NO_MEMORY<TD>Memory allocation error
<TR><TH ALIGN="LEFT">XB_WRITE_ERROR<TD>Error writing to file
<TR><TH ALIGN="LEFT">XB_SEEK_ERROR<TD>Seek error encountered
<TR><TH ALIGN="LEFT">XB_LOCK_FAILED<TD>Can not lock file or index
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/packdbf.cpp">packdbf.cpp</A> for an 
example of how to use this method.
<hr>
<h3>Method xbShort xbDbf::PutRecord( xbLong RecNo )</h3><br>
This method copies the record buffer into record <em>RecNo</em> in the database. 
This method can be used for updating records which were retrieved by 
the GetRecord method.<br><br>
This method updates any open index files.<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_LOCK_FAILED<TD>Write lock not successful
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>If there is no error
<TR><TH ALIGN="LEFT">XB_NOT_OPEN<TD>Database is not open
<TR><TH ALIGN="LEFT">XB_INVALID_RECORD<TD>Invalid record number
<TR><TH ALIGN="LEFT">XB_SEEK_ERROR<TD>Seek operation failed
<TR><TH ALIGN="LEFT">XB_WRITE_ERROR<TD>Write operation failed
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample3.cpp">sample3.cpp</A> for an
example of how to use this method.
<hr>

<h3>Method xbShort xbDbf::RebuildAllIndicis( void )</h3><br>
This method rebuilds all opened indicis for the database file.<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_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.
<hr>



<h3>Method xbShort xbDbf::RecordDeleted( void )</h3><br>
This method returns TRUE (or 1) if a record is marked for deletion and
returns FALSE (or 0) if the record is not marked for deletion.  <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">TRUE (1)<TD>Record is marked for deletion
<TR><TH ALIGN="LEFT">FALSE (0)<TD>Record is not marked for deletion
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample4.cpp">sample4.cpp</A> for an
example of how to use this method.
<hr>


<h3>Method xbShort xbDbf::SetVersion( xbShort Vswitch )</h3><br>

This method sets the version of xbDbf and DBT database files and memo files 
to be created using the CreateDatabase method.  The default setting is 
3 - dBASE III+ version files.  It can be set to 4 - for dBASE IV style
files.<br><br>
Vswitch is one of:<br>
0 - return current setting<br>
3 - Set to create version III files (default)<br>
4 - Set to create version IV files<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>Setting updated
<TR><TH ALIGN="LEFT">3 or 4<TD>If Vswitch = 0, it returns current version setting
<TR><TH ALIGN="LEFT">XB_INVALID_OPTION<TD>Vswictch not one of 0,3 or 4
</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 xbDbf::UndeleteAllRecords( void )</h3><br>
This method unmarks all marked for deletion records in the database.<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>No error encountered
<TR><TH ALIGN="LEFT">XB_INVALID_RECORD<TD>Could not mark record
<TR><TH ALIGN="LEFT">XB_NOT_OPEN<TD>If the file is not open
<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/undelall.cpp">undelall.cpp</A> for an example 
of how to use this method.
<hr>

<h3>Method xbShort xbDbf::UndeleteRecord( void )</h3><br>
This method removes the mark for deletion on the current record in the 
database.<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>No error encountered
<TR><TH ALIGN="LEFT">XB_INVALID_RECORD<TD>Could not unmark record
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample4.cpp">sample4.cpp</A> for an 
example of how to use this method.
<hr>

<h3>Method xbShort xbDbf::Zap( xbShort WaitOption )</h3><br>
This method removes all records from a database and any open indices.
<br><br>
<em>WaitOption</em> is one of:<br><br>
<li>F_SETLK - returns if the xbDbf file can not be exclusively locked
<li>F_SETLKW - will wait to execute until it can exclusively lock the file
<br><br>
<TABLE BORDER>
<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>No error encountered
<TR><TH ALIGN="LEFT">XB_LOCK_FAILED<TD>Could not lock file
<TR><TH ALIGN="LEFT">XB_WRITE_ERROR<TD>Could not write to file
<TR><TH ALIGN="LEFT">XB_OPEN_ERROR<TD>Could not open temp database
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/zap.cpp">zap.cpp</A> for an 
example of how to use this method.
<hr>

<A HREF="mailto:xbase@startech.keller.tx.us">
Send me mail - xbase@startech.keller.tx.us</A><br>
<p>(c)1997 StarTech
<p><img src="xbase.jpg"><br><hr>
</BODY>
</xbHtml>