.TH "PX_INSERT_RECORD" "3" .SH "NAME" PX_insert_record \(em Inserts a new record in the Paradox file .SH "SYNOPSIS" .PP #include .PP int PX_insert_record(pxdoc_t *pxdoc, pxval_t **dataptr) .SH "DESCRIPTION" .PP Inserts a new record stored in the array \fBdataptr\fP 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 \fBPX_delete_record(3)\fP 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. .PP Blobs will be automatically written if a blob file was set with \fBPX_set_blob_file(3)\fP. .PP The memory for \fBdataptr\fP and the field values can be freed after \fBPX_insert_record\fP has been called. .PP Each single element in the array of pointers to pxval_t can be easily created with \fBMAKE_PXVAL(pxdoc_t *pxdoc, pxval_t *val)\fP and setting the actual value afterwards. A quite common way to build up the record is the following: .PP .nf 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); .fi .PP .PP There is currently no need to set the type, though it is recommended. .PP The field types pxfMemoBLOb and pxfFmtMemoBLOb are treated like strings. .PP 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. .SH "RETURN VALUE" .PP Returns the record number on success or \-1 on failure. The number of the first record is 0. .SH "SEE ALSO" .PP \fBPX_retrieve_record(3)\fP, \fBPX_delete_record(3)\fP, \fBPX_update_record(3)\fP .SH "AUTHOR" .PP This manual page was written by Uwe Steinmann uwe@steinmann.cx. .\" created by instant / docbook-to-man