wchIDfield
Returns the DODA field with the IDENTITY attribute set.
Declaration
whcIDfield(FILNO datno)Description
wchIDfield() returns which DODA field has an IDfield (IDENTITY) auto-numbering attribute set.
Where:
- datno is the data file number. In V12 the file number typedef was formally changed from COUNT, a two-byte value to FILNO, a four-byte value. Refer to this link for compatibility details. Four Byte File Numbering
IDfields requires a DAR resource (Direct Access Resource) embedded in the file. The DAR is a specialized high-speed resource.
Return
Returns the DODA index (zero based) for the IDfield (the fieldno passed into addIDfield()). On error, -1 is returned and uerr_cod is set.
| Value | Symbolic Constant | Explanation |
|---|---|---|
| 0 | NO_ERROR | Success |
See c-tree Error Codes for a complete listing of valid c-tree error values.
Example
retval = wchIDfield(fileno);
if (retval <0 ) {
printf("\tERROR: Failed to retrieve ID column with error %d\n", uerr_cod);
}
else
printf("Field %d is an IDENTITY column\n", retval);Override IDENTITY Values
PUTHDR() using the ctIDfieldOverRide mode can turn on and off the ability to override the automatic IDfield values. The override is on a per user, per file basis. A nonzero hdrval turns on the override, and a zero hdrval restores the standard operation. When the override is on for a data file that supports an IDfield, then an add record operation does not fill-in the IDfield value. Whatever is passed in the record buffer is used for the IDfield. And a rewrite permits the IDfield value to change instead of generating the IDFL_CHG error. When the override is enabled, add record operations do not consume IDfield values.
See also
addIDfield(), delIDfield(), getIDfield(), resetIDfield(), IDfields - Extended support
WhichAutoSysTimeFields
Retrieve in bufptr the A_STFIELDS fields definition structure.
Type
ISAM Function
Declaration
VRLEN WhichAutoSysTimeFields(FILNO datno, pVOID bufptr, VRLEN bufsiz);Description
- datno - the data file number. In V12 the file number typedef was formally changed from COUNT, a two-byte value to FILNO, a four-byte value. Refer to this link for compatibility details. Four Byte File Numbering
- bufptr - pointer to a buffer where to store the definition (after successful return, it can be cast to A_STFIELDS)
- bufsiz - size of the bufptr.
Return
The size of bufptr actually used.
- uerr_cod needs to be checked if an error condition occurred.
- A return value of 0 with uerr_cod 0 indicates that no field has been defined.
- uerr_cod set to VBSZ_ERR indicates bufsiz is too small. Return value contains required size.
WhichCtree
Return the current c-tree instance reference name.
Short Name
WCHCTREE()
Type
Low-Level function
Declaration
pTEXT WhichCtree()Description
WhichCtree() returns the active instance reference name. This is useful for displaying the active instance during program execution.
Return
WhichCtree() returns the pointer to the current instance reference name. This is the same instance reference name passed to RegisterCtree(). If there are no active instances, a NULL will be returned. See c-tree Error Codes c-tree Programmer’s Reference Guide for a complete listing of valid c-tree error values.
Example
pCTGVAR ctWNGV;
ctWNGV = GetCtreePointer(WhichCtree());
isam_err = ctWNGV->sisam_errSee also
NextCtree(), RegisterCtree(), SwitchCtree(), UnRegisterCtree(), GetCtreePointer()
WriteData
Write fixed-length data record.
Short Name
WRTREC()
Type
Low-Level data file function
Declaration
COUNT WriteData(FILNO datno, LONG recbyt, pVOID recptr)Description
In V12 the file number typedef was formally changed from COUNT, a two-byte value to FILNO, a four-byte value. Refer to this link for compatibility details. Four Byte File Numbering
WriteData() writes the fixed-length data record from the buffer area pointed to by recptr into record position recbyt for data file datno.
Return
| Value | Symbolic Constant | Explanation |
|---|---|---|
| 0 | NO_ERROR | Successful write. |
| 29 | ZREC_ERR | Attempt to write at byte offset zero. |
| 30 | LEOF_ERR | recbyt exceeds the logical end of file maintained in the data file header. |
| 33 | DNUL_ERR | recptr is NULL. |
| 35 | SEEK_ERR | lseek() failed while preparing for write. |
| 37 | WRITE_ERR | Operating system could not execute write. Most likely cause is a full disk or directory. |
| 57 | DADV_ERR | Proper lock not held when CHKLOK specified. |
See c-tree Error Codes for a complete listing of valid c-tree error values.
Example
FILNO datno;
TEXT recptr[1024];
if (WriteData(datno, NewData(datno), recptr))
printf("\nCould not write record. Error #%d",uerr_cod);Limitations
The recbyt parameter in this function is a 4-byte value capable of addressing at most 4 gigabytes. If your application supports HUGE files (greater than 4 gigabytes), you must use the ctSETHGH() and ctGETHGH() functions to set or get the high-order 4 bytes of the file offset. See also Record Offsets Under Huge File Support.
See also
ReadData(), NewData(), WriteVData()
WriteVData
Write variable-length data record.
Short Name
WRTVREC()
Type
Low-Level variable-length record function
Declaration
COUNT WriteVData(FILNO datno, LONG recbyt, pVOID recptr, VRLEN varlen)Description
In V12 the file number typedef was formally changed from COUNT, a two-byte value to FILNO, a four-byte value. Refer to this link for compatibility details. Four Byte File Numbering
WriteVData() writes varlen bytes from the record buffer pointed to by recptr into the variable-length data record at record position recbyt for data file datno.
Return
WriteVData() may return the following errors, in addition to those for WriteData().
| Value | Symbolic Constant | Explanation |
|---|---|---|
| 0 | NO_ERROR | Successful write. |
| 48 | FMOD_ERR | datno is not assigned to variable-length file. |
| 148 | VLEN_ERR | varlen bytes will not fit into file at position recbyt. |
| 159 | VPNT_ERR | recbyt is zero. |
See c-tree Error Codes for a complete listing of valid c-tree error values.
Example
LONG recbyt;
FILNO datno;
TEXT recptr[1024];
scanf("%1023s",recptr);
recbyt = NewVData(datno,strlen(recptr));
if (WriteVData(datno,recbyt,recptr,strlen(recptr)))
printf("\nCould not write record. Error #%d", uerr_cod);Limitations
The recbyt parameter in this function is a 4-byte value capable of addressing at most 4 gigabytes. If your application supports HUGE files (greater than 4 gigabytes), you must use the ctSETHGH() and ctGETHGH() functions to set or get the high-order 4 bytes of the file offset. See also Record Offsets Under Huge File Support.
See also
WriteData(), ReadVData()