Difference between revisions of "Dbakey()"

From Recital Documentation Wiki
Jump to: navigation, search
 
(EXAMPLE)
 
(19 intermediate revisions by 2 users not shown)
Line 5: Line 5:
 
==SYNOPSIS==
 
==SYNOPSIS==
  
<code lang="c">
+
<source lang="c">
 
#include<dbl.h>
 
#include<dbl.h>
 
 
Line 11: Line 11:
  
 
<input parameters>
 
<input parameters>
char *ndx; /* .NDX file descriptor */
+
char *ndx; /* .NDX file descriptor */
char key; /* Address of a buffer containing the key */
+
char key; /* Address of a buffer containing the key */
long recno; /* Record number */
+
long recno; /* Record number */
  
 
<output parameters>
 
<output parameters>
 
none
 
none
</code>
+
</source>
  
  
 
==RETURN VALUE==
 
==RETURN VALUE==
  
The dbakey() function returns 0 for success, or<0 if an error occurs.  See the section on [[Library Return Code Values|return code values]] for a detailed list of return codes.
+
The dbakey() function returns 0 for success, or <0 if an error occurs.  See the section on [[Library Return Code Values|return code values]] for a detailed list of return codes.
  
  
Line 37: Line 37:
 
#include "dbl.h"
 
#include "dbl.h"
  
char *ndx; /* .NDX file descriptor */
+
char *ndx; /* .NDX file descriptor */
int rc; /* Return code */
+
int rc; /* Return code */
  
 
rc=dbakey(ndx,"John Smith 5". (long)5);
 
rc=dbakey(ndx,"John Smith 5". (long)5);
if (rc = = SUCCESS) printf("key added n");
+
        if (rc == SUCCESS) printf("key added \n");
else {
+
else  
printf("error number %d n", rc);
+
{
exit (1);
+
                printf("error number %d \n", rc);
 +
                exit (1);
 
}
 
}
  
 
</code>
 
</code>
 
  
 
==SEE ALSO==
 
==SEE ALSO==

Latest revision as of 00:26, 2 June 2009

PURPOSE

add key


SYNOPSIS

#include<dbl.h>
 
	int	dbakey(ndx, key, recno)
 
	<input parameters>
	char	*ndx;	/* .NDX file descriptor */
	char	key;		/* Address of a buffer containing the key */
	long	recno;	/* Record number */
 
	<output parameters>
	none


RETURN VALUE

The dbakey() 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 adds a key with its associated record number to the specified .NDX file which contains keys in a B-tree structure.


EXAMPLE

The following example adds a character key "John Smith 5" and its associated record number 5 to the index file whose descriptor is in "char *ndx".

#include "dbl.h"
 
	char	*ndx;	/* .NDX file descriptor */
	int	rc;		/* Return code */
 
	rc=dbakey(ndx,"John Smith 5". (long)5);
        if (rc == SUCCESS) printf("key added \n");
	else 
	{
                printf("error number %d \n", rc);
                exit (1);
	}

SEE ALSO

dbatokey(), dbicreat(), dbiflsh(), dbrmvkey(), dbtkey(), dbupdr()