Difference between revisions of "Dbupdm()"

From Recital Documentation Wiki
Jump to: navigation, search
 
 
(2 intermediate revisions by one user not shown)
Line 4: Line 4:
  
  
==SYSNOPSIS==
+
==SYNOPSIS==
  
 
<code lang="c">
 
<code lang="c">
Line 12: Line 12:
  
 
<input parameters>
 
<input parameters>
char *dbt; /* .DBT file descriptor */
+
char *dbt; /* .DBT file descriptor */
char *memo /* Address of a buffer containing the memo to be put into the file */
+
char *memo /* Address of a buffer containing the memo to be put into the file */
char *oldfield; /* Address of old memo field which should be released, 0 if no reclaim of space is to be made */
+
char *oldfield; /* Address of old memo field which should be released, 0 if no reclaim of space is to be made */
  
 
<output parameters>
 
<output parameters>
char *field; /* Address in the record buffer where the memo is stored */
+
char *field; /* Address in the record buffer where the memo is stored */
  
 
</code>
 
</code>
Line 48: Line 48:
  
 
if(rc = dbgetr, (long) 2, record, &status) !=0) {
 
if(rc = dbgetr, (long) 2, record, &status) !=0) {
printf("Get Memo Failure: %dn", rc);
+
printf("Get Memo Failure: %d\n", rc);
 
exit(1);
 
exit(1);
 
}
 
}
  
 
if(rc = dbgetm( dbt, &record[53], memobuffer, 0) !=0) {
 
if(rc = dbgetm( dbt, &record[53], memobuffer, 0) !=0) {
printf("Get Memo Failure: %dn", rc);
+
printf("Get Memo Failure: %d\n", rc);
 
exit(1);
 
exit(1);
 
}
 
}
Line 64: Line 64:
 
&record[53],
 
&record[53],
 
&record[53]) !=0) {
 
&record[53]) !=0) {
printf("Memo Update Failure: %dn",rc);
+
printf("Memo Update Failure: %d\n",rc);
 
exit(1);
 
exit(1);
 
}
 
}
  
 
if(rc = dbupdr(dbf, (long)2, record) !=0) {
 
if(rc = dbupdr(dbf, (long)2, record) !=0) {
printf("Record Update failure: %dn", rc);
+
printf("Record Update failure: %d\n", rc);
 
exit(1);
 
exit(1);
 
}
 
}

Latest revision as of 15:58, 1 May 2009

PURPOSE

update memo in a memo file


SYNOPSIS

#include "dbl.h"
 
	int	dbpudm(dbt, memo, field, oldfield)
 
	<input parameters>
	char	*dbt;			/* .DBT file descriptor */
	char	*memo		/* Address of a buffer containing the memo to be put into the file */
	char	*oldfield;		/* Address of old memo field which should be released, 0 if no reclaim of space is to be made */
 
	<output parameters>
	char	*field;		/* Address in the record buffer where the memo is stored */


RETURN VALUE

The dbupdm() function returns 0 for success. See the section on return value codes for a detailed list of failure codes.


DESCRIPTION

This function updates a memo in the specified .dbt file. The memo to be updated must first be acquired by using dbgetr() or by other means. The last parameter of this function controls the reallocation of existing memo entries. If the address is specified, the function adds the existing memo entry to the free block list which controls allocation of space in the .dbt file. The address will usually be the same as the third parameter. If no reallocation is desired, the fourth parameter is null (0). This function does not automatically update the memo pointer in the record. The function dbputr() or others that commit records must be used.


EXAMPLE

The following example adds more information to the end of an existing memo entry. Note the use of dbgetr() and dbgetm(). It is assumed that the 4 byte memo pointer starts at the 54th array element (&record[53]).

#include "dbl.h"
 
	int	dbf, dbt;
	char	record[1000];
	char	status;
	int	rc;
	char	memobuffer[512];
 
	if(rc = dbgetr, (long) 2, record, &status) !=0) {
		printf("Get Memo Failure: %d\n", rc);
		exit(1);
	}
 
	if(rc = dbgetm( dbt, &record[53], memobuffer, 0) !=0) {
		printf("Get Memo Failure: %d\n", rc);
		exit(1);
	}
 
	strcat(memobuffer,
		"This string is appended to the end of the retrieved
			  memo");
 
	if(rc = dbupdm( dbt, memobuffer,
			&record[53],
			&record[53]) !=0) {
		printf("Memo Update Failure: %d\n",rc);
		exit(1);
	}
 
	if(rc = dbupdr(dbf, (long)2, record) !=0) {
		printf("Record Update failure: %d\n", rc);
		exit(1);
	}


SEE ALSO

dbgetm(), dbgetr(), dbmopen(), dbputm(), dbputr()