Function DbSeek() Professional

Positions the record pointer to a record based on the value of an index expression

Description

DbSeek() can be used in conjunction with the ODBCDBE since the ODBCDBE is a compound DBE, consisting of the data, dictionary and the order component.

It is required to set the session property ODBCSSN_INDEX_AUTOOPEN to .T. (true) before retrieving the result set by DbUseArea().

Using the auto-open index does not create an index, but provides a virtual index, based on an ordered result set provided by the backend. The index key compromises either by the primary key or by a given ORDER BY clause.

Examples
DbSeek()
// This sample shows how to use a server-side 
// created index (created by CREATE INDEX). 

#include "odbcdbe.ch" 

PROCEDURE MAIN(cConnect) 
LOCAL oSesion 

   oSession := DacSession():new( cConnect ) 

   // turn Auto-open on 
   oSession:setProperty(ODBCSSN_INDEX_AUTOOPEN, .T.) 
   // table test has an index on field NAME 
   USE test NEW 
   ? IndexKey()                      // returns "NAME" 
   IF DbSeek("Meier") 
      ? "Found: ", Recno() 
   ENDIF 
RETURN 
DbSeek() on ORDER BY
// This sample shows ho to use the order by clause 
// to get an index. 

#include "sqlcmd.ch" 

PROCEDURE MAIN 
LOCAL myConn 

    CREATE CONNECTION INTO myConn DATASOURCE "Oracle-Demo" ; 
           USER "Scott" PASSWORD "Tiger" 

    // turn Auto-open on 
    oSession:setProperty(ODBCSSN_INDEX_AUTOOPEN, .T.) 

    // a select statement with an ORDER BY clause 
    SQL "SELECT * FROM CUSTOMER ORDER BY Id, Name" 
    ? IndexKey()                      // returns "Str(Id,10,0) + Name" 
    IF DbSeek("0001"+"Meier") 
        ? "Found at", Recno() 
ELSE 
        ? "Not found." 
    ENDIF 
    CLOSE 
    DELETE CONNECTION myConn 
RETURN 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.