Difference between revisions of "Dbsetseqno()"

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 *dbf; /* .DBF file descriptor */
+
char *dbf; /* .DBF file descriptor */
long seqno; /* Sequence number to set */
+
long seqno; /* Sequence number to set */
  
 
<output parameter>
 
<output parameter>
 
none
 
none
  
</code>
 
 
</code>
 
</code>
  
Line 40: Line 39:
 
<code lang="c">
 
<code lang="c">
 
#include <stdio.h>
 
#include <stdio.h>
#include "dbl.h" /* Recital/Library include file */
+
#include "dbl.h" /* Recital/Library include file */
#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 */
long *seqno; /* Buffer address for sequence number */
+
long *seqno; /* Buffer address for sequence number */
  
 
rc = dbdcache(100);
 
rc = dbdcache(100);
Line 64: Line 60:
 
rc=dbgetseqno(dbf, seqno);
 
rc=dbgetseqno(dbf, seqno);
 
errorproc("dbgetseqno()", "seqno retrieved.", rc);
 
errorproc("dbgetseqno()", "seqno retrieved.", rc);
printf("t   Seqno: t%dn", *seqno);
+
printf("\t   Seqno: \t%d\n", *seqno);
  
 
rc = dbclose(dbf);
 
rc = dbclose(dbf);
Line 72: Line 68:
 
}
 
}
  
static void errorproc(func, str, rc)
+
static void errorproc(func, str, rc)
 
char *func;
 
char *func;
 
char *str;
 
char *str;
Line 78: Line 74:
 
{
 
{
 
if ( rc != SUCCESS ) {
 
if ( rc != SUCCESS ) {
printf("n  Error performing function %s -> %dn", func, rc);
+
printf("\n  Error performing function %s -> %d\n", func, rc);
 
exit(1);
 
exit(1);
 
}
 
}
printf("Function: t%s, t%s - Okn", func, str);
+
printf("Function: \t%s, \t%s - Ok\n", func, str);
 
return;
 
return;
 
}
 
}

Latest revision as of 15:21, 1 May 2009

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