Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

px_insert_record(3) [debian man page]

PX_INSERT_RECORD(3)					     Library Functions Manual					       PX_INSERT_RECORD(3)

NAME
PX_insert_record -- Inserts a new record in the Paradox file SYNOPSIS
#include <paradox.h> int PX_insert_record(pxdoc_t *pxdoc, pxval_t **dataptr) DESCRIPTION
Inserts a new record stored in the array dataptr into a Paradox file. The position of the record will be determined by the function itself, starting at the beginning of the file and searching towards the end for a free slot. A free slot can be the result of former calls of PX_delete_record(3) or not completely filled data blocks in the input file. If there is no free slot within the file, then a new record will be added at the end. Blobs will be automatically written if a blob file was set with PX_set_blob_file(3). The memory for dataptr and the field values can be freed after PX_insert_record has been called. Each single element in the array of pointers to pxval_t can be easily created with MAKE_PXVAL(pxdoc_t *pxdoc, pxval_t *val) and setting the actual value afterwards. A quite common way to build up the record is the following: dataptr = (pxval_t **) malloc(PX_get_num_fields(pxdoc)*sizeof(pxval_t *)); MAKE_PXVAL(pxdoc, dataptr[0]); dataptr[0]->type = pxfLong; dataptr[0]->value.lval = 45; dataptr[1]->type = pxfAlpha; dataptr[1]->value.str.val = "test"; dataptr[1]->value.str.len = 4; PX_insert_record(pxdoc, dataptr); free(dataptr[0]); free(dataptr[1]); free(dataptr); There is currently no need to set the type, though it is recommended. The field types pxfMemoBLOb and pxfFmtMemoBLOb are treated like strings. Fields of type pxfAutoInc are automatically incremented if its value is set to NULL. In such a case the value is taken from the header of the database. You should not have more than one field of type pxfAutoInc in your database, otherwise the automatic incrementation will not work. RETURN VALUE
Returns the record number on success or -1 on failure. The number of the first record is 0. SEE ALSO
PX_retrieve_record(3), PX_delete_record(3), PX_update_record(3) AUTHOR
This manual page was written by Uwe Steinmann uwe@steinmann.cx. PX_INSERT_RECORD(3)

Check Out this Related Man Page

PX_GET_RECORD2(3)					     Library Functions Manual						 PX_GET_RECORD2(3)

NAME
PX_get_record2 -- Returns record in Paradox file SYNOPSIS
#include <paradox.h> int PX_get_record2(pxdoc_t *pxdoc, int recno, char *data, int *deleted, pxdatablockinfo_t *pxdbinfo) DESCRIPTION
This function is similar to PX_get_record(3) but takes two extra parameters. If *deleted is set to 1 the function will consider any record in the database, even those which are deleted. If *pxdbinfo is not NULL, the function will return some information about the data block where the record has been read from. You will have to allocate memory for pxdbinfo before calling PX_get_record2. On return *deleted will be set to 1 if the requested record is deleted or 0 if it is not deleted. The struct pxdatablockinfo_t has the fol- lowing fields: blockpos (long) File positon where the block starts. The first six bytes of the block contain the header, followed by the record data. recordpos (long) File position where the requested record starts. size (int) Size of the data block without the six bytes for the header. recno (int) Record number within the data block. The first record in the block has number 0. numrecords (int) The number of records in this block. number (int) The number of the data block. This function may return records with invalid data, because records are not explizitly marked as deleted, but rather the size of a valid data block is modified. A data block is a fixed size area in the file which holds a certain number of records. If for some reason a data block has newer been completely filled with records, the algorithmn anticipates deleted records in this data block, which are not there. This often happens with the last data block in a file, which is likely to not being fully filled with records. If you accessing several records, do it in ascending order, because this is the most efficient way. Note: This function is deprecated. Use PX_retrieve_record(3) instead RETURN VALUE
Returns 0 on success and -1 on failure. SEE ALSO
PX_get_field(3), PX_get_record(3) AUTHOR
This manual page was written by Uwe Steinmann uwe@steinmann.cx. PX_GET_RECORD2(3)
Man Page