Difference between revisions of "Dbicreat()"

From Recital Documentation Wiki
Jump to: navigation, search
 
 
(One intermediate revision by one user not shown)
Line 11: Line 11:
  
 
<input parameter>
 
<input parameter>
char *ndxname; /* Address of a buffer containing the name of the .NDX file to be created */
+
char *ndxname; /* Address of a buffer containing the name of the .NDX file to be created */
char *keyexpr; /* Address of a buffer containing the key expression */
+
char *keyexpr; /* Address of a buffer containing the key expression */
int keylen; /* Index key length */
+
int keylen; /* Index key length */
char keytype; /* Index key data type */
+
char keytype; /* Index key data type */
  
 
<output parameters>
 
<output parameters>
Line 41: Line 41:
 
#include "dbl.h"
 
#include "dbl.h"
  
int rc; /* Return code */
+
int rc; /* Return code */
  
 
rc = dbicreat("person.ndx", "SSN", 10, 'C');
 
rc = dbicreat("person.ndx", "SSN", 10, 'C');
if (rc = = SUCCESS) printf("index person created n");
+
if (rc == SUCCESS) printf("index person created \n");
 
else {
 
else {
printf("error number %d n", rc);
+
printf("error number %d \n", rc);
 
exit (1);
 
exit (1);
 
}
 
}

Latest revision as of 11:12, 1 May 2009

PURPOSE

create an index file


SYNOPSIS

#include "dbl.h"
 
	int	dbicreat(ndxname, keyexpr, keylen, keytype)
 
	<input parameter>
	char	*ndxname;	/* Address of a buffer containing the name of the .NDX file to be created */
	char	*keyexpr;		/* Address of a buffer containing the key expression */
	int	keylen;		/* Index key length */
	char	keytype;		/* Index key data type */
 
	<output parameters>
	none


RETURN VALUE

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


DESCRIPTION

This function creates an .NDX file. A key provided by a user is usually a character string that consists of one or more field names of a data record, e.g., "NAME+SSN".

NOTE: This function only creates the header of the index file. Other library functions (i.e. dbakey()) must be used to fill the index with the appropriate keys.


EXAMPLE

The following example creates an .NDX file "person.ndx" whose key expression, length and type are "SSN", 10 and 'C' respectively. "SSN" is a field name of the associated .DBF file.

#include "dbl.h"
 
	int	rc;	/* Return code */
 
	rc = dbicreat("person.ndx", "SSN", 10, 'C');
	if (rc == SUCCESS) printf("index person created \n");
	else {
		printf("error number %d \n", rc);
		exit (1);
	}


SEE ALSO

dbakey(), dbcreat(), dbicache(), dbkexpr(), dbputrk()