PX_INSERT_RECORD(3)
π PX_INSERT_RECORD(3) π
okay bestie, so this one is PX_insert_record β it lives in the Library Functions Manual and it's your girl for adding brand-new records to a Paradox file. let's get into it β¨
β¨ SYNOPSIS β¨
#include <paradox.h>
int PX_insert_record(pxdoc_t *pxdoc, pxval_t **dataptr)
πΈ DESCRIPTION πΈ
So basically, PX_insert_record takes a brand-new record that's already chillin' in the array dataptr and drops it into a Paradox file. π«Ά
Where does it go? the function decides that itself. It starts at the beginning of the file and hunts towards the end looking for a free slot. and a "free slot" can be two things, no cap:
- a slot that got freed up by a previous call to
PX_delete_record(3), or - a data block in the input file that wasn't completely filled
and if there's literally no free slot anywhere in the file, then a new record just gets tacked onto the end. slay, problem solved π
Blobs get written automatically if a blob file was set with PX_set_blob_file(3). π¦
the memory fordataptrand the field values can be freed afterPX_insert_recordhas been called. so you don't need to keep it alive, bestie, it's done its job.
π building the record π
Every single element in that array of pointers to pxval_t can be built super easily with MAKE_PXVAL(pxdoc_t *pxdoc, pxval_t *val) β you just set the actual value afterwards. the way that this is the most common way to build up the record?? iconic:
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);
fr fr, there is currently no need to set the type β though it is recommended. do with that what you will π
π field type tea π
- the field types
pxfMemoBLObandpxfFmtMemoBLObare treated like strings. periodt. - fields of type
pxfAutoIncare automatically incremented if their value is set toNULL. in that case the value is taken from the header of the database. π« - > β οΈ you should not have more than one field of type
pxfAutoIncin your database, otherwise the automatic incrementation will not work. one auto-increment field, that's it, that's the rule. π
β RETURN VALUE β
Returns the record number on success, or -1 on failure. and the number of the first record is 0. π
π SEE ALSO π
π AUTHOR π
this manual page was written by Uwe Steinmann uwe@steinmann.cx. ty bestie π«Ά
and that's the whole page, babe π it's from the Library Functions Manual, it's PX_INSERT_RECORD(3) top to bottom, and ngl there's no date or version line on this one β the footer just says PX_INSERT_RECORD(3) again, so that's all the source tea we've got. go insert some records, you got this β¨π
π¦ where this page comes from
- debian bookworm: pxlib-dev 0.6.8-1+b1
- debian trixie: pxlib-dev 0.6.9-1+b1
- ubuntu jammy: pxlib-dev 0.6.8-1
- ubuntu noble: pxlib-dev 0.6.8-1
- ubuntu questing: pxlib-dev 0.6.9-1
- ubuntu resolute: pxlib-dev 0.6.9-1build1
- ubuntu stonking: pxlib-dev 0.6.10-1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms