Pegasus InfoCorp: Web site design and web software development company

D_KEYFIND (1)

search an index for a specific key value

SYNOPSIS

    #include <typhoon.h>

    d_keyfind(ulong keyid, void *buf)

DESCRIPTION

    d_keyfind is used to lookup a record in a table via one of its indexes. keyid specifies which index to search and buf contains the value to search for. If the index contains more than one occurrence of the key value (only possible for non-unique indexes) d_keyfind returns the first one.

    The id can be either the id of a compound key or a field that is a key by itself.

    If the key value was not found, d_keyfind returns S_NOTFOUND. A subsequent call to d_keynext(1) returns next value in the sorting order.

    The actual record is not read from the database until d_recread(1) is called.

DIAGNOSTICS

    The status code returned by the function is also stored in the global variable db_status.

    S_OKAY

      The key value was found.

    S_NOTFOUND

      The key value was not found.

    S_NOCD

      There is no current database.

    S_INVFLD

      The id is not a valid field.

    S_NOTKEY

      The field id is not a key itself.

CURRENCY CHANGES

    If S_OKAY is returned. the record found becomes the current record.

EXAMPLE

    /* Find the customer called 'Pedersen' */

    #include <typhoon.h>

    if( d_keyfind(CUSTOMER_NAME, "Pedersen") == S_OKAY ) { struct customer cust; d_recread(&cust); printf("Account number %lu\\n", cust.account); }

IDENTIFICATION

    Author: Thomas B. Pedersen. Copyright (c) 1994 Thomas B. Pedersen.

SEE ALSO