version 2003
PA_GetBlobField (tNum; fNum; blob) long
Parameter | Type | Description | |
tNum | short | Table number of the field to access | |
fNum | short | Field number of the field to access | |
blob | void* | Pointer to the BLOB data | |
Function result | long | BLOB size in bytes |
Description
The routine PA_GetBlobField puts the content of the BLOB field number fNum of the current record of the table number tNum, in the data pointed to by blob, and returns its size in bytes.
If the field is not a BLOB field, the routine leaves blob unchanged, returns 0 and an error code in PA_GetLastError.
If BLOB size is unknown, call the function a first time with blob equal to zero. The returned value will be the size of the needed buffer. Allocate the buffer and call the function again with the correct buffer.
blob is a copy of the original, you can manipulate it and dispose of it. If the BLOB is large, you can get the eER_NotEnoughMemory error. You can get a handle to the BLOB simply by calling PA_GetBlobHandleField.
Example
Getting a BLOB field content:
char *theBlob; long blobSize; // First call the routine with a null pointer to get the BLOB size blobSize = PA_GetBlobField( tNum, fNum, 0 ); // Then allocate the buffer theBlob = malloc( blobSize ); // If it is ok, get the BLOB if( theBlob ) { blobSize = PA_GetBlobField( tNum, fNum, theBlob ); // Work with it /* . . . */ // Cleanup free( theBlob ); }
See Also
PA_GetBlobHandleField, PA_SetBlobField, PA_SetBlobHandleField.
Error Handling
Use PA_GetLastError to see if an error occurred (eER_InvalidFileNumber, eER_InvalidFieldNumber, etc.)