Difference between revisions of "Dbgetseqno()"
From Recital Documentation Wiki
Yvonnemilne (Talk | contribs) |
Yvonnemilne (Talk | contribs) |
||
(One intermediate revision by one user not shown) | |||
Line 11: | Line 11: | ||
<input parameter> | <input parameter> | ||
− | char *dbf; | + | char *dbf; /* Table file descriptor */ |
<output parameters> | <output parameters> | ||
− | long *seqno; /* Address of a buffer in which the sequence number is returned */ | + | long *seqno; /* Address of a buffer in which the sequence number is returned */ |
</code> | </code> | ||
Line 36: | Line 36: | ||
<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" | + | #include "dblproto.h" /* Recital/Library prototype file */ |
− | + | static void errorproc(char *func, char *str, int rc); | |
− | + | ||
− | + | ||
− | + | ||
− | + | main() | |
− | + | { | |
− | int rc; /* Return Code for error handling | + | int rc; /* Return Code for error handling */ |
− | char *dbf; | + | 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 60: | Line 57: | ||
rc=dbgetseqno(dbf, seqno); | rc=dbgetseqno(dbf, seqno); | ||
errorproc("dbgetseqno()", "seqno retrieved.", rc); | errorproc("dbgetseqno()", "seqno retrieved.", rc); | ||
− | printf("t Seqno: t% | + | printf("\t Seqno: \t%d\n", *seqno); |
rc = dbclose(dbf); | rc = dbclose(dbf); | ||
Line 68: | Line 65: | ||
} | } | ||
− | + | static void errorproc(func, str, rc) | |
char *func; | char *func; | ||
char *str; | char *str; | ||
Line 74: | Line 71: | ||
{ | { | ||
if ( rc != SUCCESS ) { | if ( rc != SUCCESS ) { | ||
− | + | printf("\n Error performing function %s -> %d\n", func, rc); | |
− | + | exit(1); | |
} | } | ||
− | printf("Function: t%s, t%s - | + | printf("Function: \t%s, \t%s - Ok\n", func, str); |
return; | return; | ||
} | } |
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; }