PX_INSERT_RECORD
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.
Latest News
Released version 0.6.6April 07, 2016
This release fixes some more typos in the documentation.
Released version 0.6.5Jannuary 11, 2012
pxlib isn't dead, its development has just slowed down. This release fixes some typos and optimizes the configuration process.
Released version 0.6.2September 19, 2007
This one fixes a long lasting bug on 64 bit architectures. It also is compilable in a mingw environment and Visual C++ with the help of cmake.
Released version 0.6.1March 29, 2006
There were some bugs related to the changes of the last release. This version fixes them. Besides that the following has changed:
- Much better support for secondary indexes
- PX_insert_record() and PX_update_record() treat null values propperly
- PX_delete_record() now updates the internal index without corrupting it.
- Various man page updates.
- Auto increment fields of type pxfAutoInc.
- Fixed some compile errors and warnings.
- Fixed various small bugs and memory leaks.
February 6, 2006
This version includes some major changes to the api while retaining compatible to older versions. If you use the new functions expect bugs but also a much simplier record handling.
- Databases can be read and written after opening with PX_open_xxx()
- Use a cache for reading encrypted blobs
- Added new functions PX_delete_record(), PX_update_record(), PX_insert_record(), PX_retrieve_record()
- reading and writing encrypted blob files is more efficient.
- No more than 64 blobs will be stored in blocks of type 3
- Fixed various small bugs and memory leaks.
August 11, 2005
- fixed bug when reading header of blob (Thanks to Giovanni Giacobbi)
- fixes bug when reading blobs of a certain size from an encrypted .mb file.
- reading and writing encrypted blob files is more efficient.
July 14, 2005
- support for encrypted databases and blob files
02 Feb 05
After a long time the web site has been overhauled with much more information about pxlib.