Difference between revisions of "Dbgetseqno()"

From Recital Documentation Wiki
Jump to: navigation, search
 
Line 39: Line 39:
 
#include "dblproto.h" /* Recital/Library prototype file */
 
#include "dblproto.h" /* Recital/Library prototype file */
  
static void errorproc(
+
static void errorproc(char *func, char *str, int rc);
char *func,
+
char *str,
+
int rc);
+
  
main()
+
main()
{
+
{
 
int rc; /* Return Code for error handling */
 
int rc; /* Return Code for error handling */
 
char *dbf; /* File descriptor for table */
 
char *dbf; /* File descriptor for table */
Line 68: Line 65:
 
}
 
}
  
static void errorproc(func, str, rc)
+
static void errorproc(func, str, rc)
 
char *func;
 
char *func;
 
char *str;
 
char *str;

Latest revision as of 13:17, 1 May 2009

PURPOSE

return the next sequence number


SYNOPSIS

#include "dbl.h"
 
	int	dbgetseqno(dbf, seqno)
 
	<input parameter>
	char	*dbf; 	/* Table file descriptor */
 
	<output parameters>
	long	*seqno; 	/* Address of a buffer in which the sequence number is returned */


RETURN VALUES

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

The dbgetseqno() function returns the next sequence number for the specified table.


EXAMPLE

The following example sets the sequence number, then gets the sequence number.


#include <stdio.h>
#include "dbl.h"		/* Recital/Library include file */
#include "dblproto.h"	/* Recital/Library prototype file */
 
static void errorproc(char *func, char *str, int rc);
 
main()
{
	int		rc; 		/* Return Code for error handling */
	char		*dbf; 	/* File descriptor for table */
	long		*seqno; 	/* Buffer address for sequence number */
 
	rc = dbdcache(100);
	errorproc("dbdcache()","table cache specified.", rc);
	rc = dbfilemode(1,0);
	rc = dbopen("shipwreck.dbf", &dbf);
	errorproc("dbopen()","table opened shared.", rc);
 
	rc=dbsetseqno(dbf, (long) 49);
	errorproc("dbsetseqno()", "seqno set to 49.", rc);
	rc=dbgetseqno(dbf, seqno);
	errorproc("dbgetseqno()", "seqno retrieved.", rc);
	printf("\t	  Seqno: \t%d\n", *seqno);
 
	rc = dbclose(dbf);
	errorproc("dbclose()", "table closed.", rc);
 
	exit(0);
}
 
static void errorproc(func, str, rc)
	char	*func;
	char	*str;
	int	rc;
{
	if ( rc != SUCCESS ) {
		printf("\n  Error performing function %s -> %d\n", func, rc);
		exit(1);
	}
	printf("Function: \t%s, \t%s - Ok\n", func, str);
	return;
}


SEE ALSO

dbsetseqno()