xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

HS_Replace()

Changes a HiPer-SEEK index entry.

Syntax

HS_Replace( <nHsxHandle>, ;
            <cNewIndex> , ;
            <nIndexEntry> ) --> nErrorCode

Arguments

<nHsxHandle>
This is the numeric file handle of the HiPer-SEEK index file to replace an index entry in. The file handle is returned from HS_Open() or HS_Create().
<cNewIndex>
This is a character string holding the new value for the index entry specified with <nIndexEntry>.
<nIndexEntry>
The ordinal position of the index entry to change must be specified as a numeric value.

Return

The function returns numeric 1 whan the index entry is successfully changed, or a negative number as error code:

Error codes of HS_Replace()
ValueDescription
-4Error while attempting to seek during buffer flushing.
-6Write error during buffer flushing.
-7<nIndexEntry> is out of bounds.
-16Invalid parameters are passed.
-18Illegal HiPer-SEEK index file handle.
-20File cannot be locked.
-21Lock table exhausted.
-22File cannot be unlocked.

Description

HS_Replace() changes the value of the index entry <nIndexEntry> in a HiPer-SEEK index file. This is necessary, for example, when a database record is changed with REPLACE and the changes must be reflected in the index file. HiPer-SEEK index files are not automatically updated with REPLACE operations, but must be updated programmatically.

Info

See also:HS_Add(), HS_Delete(), REPLACE
Category: Database functions , HiPer-SEEK functions , Index functions , xHarbour extensions
Source:rdd\hsx\hsx.c
LIB:lib\xhb.lib
DLL:dll\xhbdll.dll

Example

// The example demonstrates how a HiPER seek index is updated after
// a database record is changed.

   PROCEDURE Main
      LOCAL cIndex := "Cust->Lastname + Cust->Firstname + Cust->City"
      LOCAL nHandle, nRet

      USE Customer ALIAS Cust EXCLUSIVE

      nHandle := HS_Index( "Customer.hsx", cIndex, 3, 1 )

      GOTO 10
      REPLACE Cust->City WITH "New York"
      COMMIT

      nRet := HS_Replace( nHandle, &(cIndex), Recno() )
      IF nRet < 1
         ? "Error on updating index:", nRet
      ELSE
         ? "Index updated"
      ENDIF

      HS_Close( nHandle )
      USE

   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe