D_KEYPREV(1)

NAME
d_keyprev - find the previous key value in an index

SYNOPSIS
#include <typhoon.h>
d_keyprev(ulong keyid)

DESCRIPTION
d_keyprevf finds the next key value smaller than or equal to the current key value in the index specified by keyid. If d_keyprev returns S_NOTFOUND the start of the index has been passed. A subsequent call to d_keyprev will return the last key value in the index.
The id can be either the id of a compound key or a field that is a key by itself.
The actual record is not read from the database until d_recread(1) is called.

EXAMPLE
/* Traverse the customers in alphabetical, descending order */ #include <typhoon.h>
d_keylast(CUSTOMER_NAME);
while( db_status == S_OKAY )
{
    struct customer cust;
    d_recread(&cust);
    printf("%s\n", cust.name);
    d_keyprev(CUSTOMER_NAME);
}

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, i.e. the index is empty.

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.

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

SEE ALSO
d_keyfind(1), d_keynext(1), d_keylast(1), d_recread(1).