Difference between revisions of "Dbgetseqno()"

From Recital Documentation Wiki
Jump to: navigation, search
 
Line 14: Line 14:
  
 
<output parameters>
 
<output parameters>
long *seqno; /* Address of a buffer in which the sequence
+
long *seqno; /* Address of a buffer in which the sequence number is returned */
number is returned */
+
  
 
</code>
 
</code>

Revision as of 10:45, 2 April 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%dn", *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 -> %dn", func, rc);
	exit(1);
	}
	printf("Function: t%s, t%s - Okn", func, str);
	return;
}


SEE ALSO

dbsetseqno()