Difference between revisions of "Dbkexpr()"

From Recital Documentation Wiki
Jump to: navigation, search
 
 
(One intermediate revision by one user not shown)
Line 11: Line 11:
  
 
<input parameters>
 
<input parameters>
char *ndx; /* .NDX file descriptor */
+
char *ndx; /* .NDX file descriptor */
  
 
<output parameters>
 
<output parameters>
char keytype; /* Index key data type:
+
char keytype; /* Index key data type:
  'C' – CHARACTER
+
  'C' – CHARACTER
  'N' – NUMERIC
+
  'N' – NUMERIC
  'D' – DATE*/
+
  'D' – DATE */
char *keyexpr; /* Index key expression */
+
char *keyexpr; /* Index key expression */
int *kexprlen; /* Length of index key expression */
+
int *kexprlen; /* Length of index key expression */
int *keylen; /* Index key length */
+
int *keylen; /* Index key length */
  
 
</code>
 
</code>
Line 46: Line 46:
 
#include "dbl.h"
 
#include "dbl.h"
  
char *ndx; /* .NDX file descriptor */
+
char *ndx; /* .NDX file descriptor */
char keytype; /* Key type */
+
char keytype; /* Key type */
char keyexpr[512]; /* Index key expression */
+
char keyexpr[512]; /* Index key expression */
int keyexprlen; /* Expression length */
+
int keyexprlen; /* Expression length */
int keylen; /* Key length */
+
int keylen; /* Key length */
int rc; /* Return code */
+
int rc; /* Return code */
  
rc = dbkexpr(ndx, &keytype, keyexpr, &keyexprlen,
+
rc = dbkexpr(ndx, &keytype, keyexpr, &keyexprlen, &keylen);
&keylen);
+
if (rc == SUCCESS){
if (rc = = SUCCESS){
+
printf("\t Index file information - \n");
printf("t Index file information - n");
+
printf("\t \t type = '%c', keyexpression = '%s',
printf("t t type = '%c', keyexpression = '%s',
+
exprlen = %d, keylen = %d \n". keytype,
exprlen = %d, keylen = %d n". keytype,
+
 
keyexpr, keyexprlen, keylen);
 
keyexpr, keyexprlen, keylen);
 
} else {
 
} else {
printf("error number %d n", rc);
+
printf("error number %d \n", rc);
 
exit (1);
 
exit (1);
 
}
 
}

Latest revision as of 13:32, 1 May 2009

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()