Dbsetseqno()

From Recital Documentation Wiki
Revision as of 15:21, 1 May 2009 by Yvonnemilne (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

PURPOSE

set the sequence number in a table


SYNOPSIS

#include "dbl.h"
 
	int	dbsetseqno(dbf, seqno)
 
	<input parameter>
	char	*dbf;		/* .DBF file descriptor */
	long	seqno;	/* Sequence number to set */
 
	<output parameter>
	none


RETURN VALUE

The dbsetseqno() 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 dbsetseqno() function sets the sequence number for a specified table (.DBF).


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

dbgetseqno()