Dbkexpr()

From Recital Documentation Wiki
Jump to: navigation, search

PURPOSE

get key expression


SYNOPSIS

#include "dbl.h"
 
	int	dbkexpr(ndx, keytype, keyexpr, keyprlen, keylen)
 
	<input parameters>
	char	*ndx;		/* .NDX file descriptor */
 
	<output parameters>
	char	keytype;		/* Index key data type:
				   		'C' – CHARACTER
				   		'N' – NUMERIC
				   		'D' – DATE */
	char	*keyexpr;		/* Index key expression */
	int	*kexprlen;		/* Length of index key expression */
	int	*keylen;		/* Index key length */


RETURN VALUE

The dbkexpr() function returns 0 for success, or < 0 if an error occurs. See the section on return code values for a detailed list of return codes.


DESCRIPTION

This function obtains the index information from the specified .NDX file. This information includes:

  • index key data type('C' for CHARACTER keys, 'N' for NUMERIC and 'D' for DATE),
  • index key expression (usually a character string consisting of one or more record field names)
  • length of the index key expression
  • length of the key.


EXAMPLE

This example obtains the index information from the .NDX file whose file descriptor is in "char *ndx" and prints this information on standard output.

#include "dbl.h"
 
	char	*ndx;		/* .NDX file descriptor */
	char	keytype;		/* Key type */
	char	keyexpr[512];	/* Index key expression */
	int	keyexprlen;	/* Expression length */
	int	keylen;		/* Key length */
	int	rc;			/* Return code */
 
	rc = dbkexpr(ndx, &keytype, keyexpr, &keyexprlen, &keylen);
	if (rc == SUCCESS){
		printf("\t Index file information - \n");
		printf("\t \t type = '%c', keyexpression = '%s',
			exprlen = %d, keylen = %d \n". keytype,
				keyexpr, keyexprlen, keylen);
	} else {
		printf("error number %d \n", rc);
		exit (1);
	}


SEE ALSO

dbicreat(), dbkeytoa()