Retrieves a column’s default value.
CS_RETCODE blk_default(blkdesc, colnum, buffer, buflen, outlen) CS_BLKDESC *blkdesc; CS_INT colnum; CS_VOID *buffer; CS_INT buflen; CS_INT *outlen;
A pointer to the CS_BLKDESC that serves as a control block for the bulk-copy operation. blk_alloc allocates a CS_BLKDESC structure.
The number of the column of interest. The first column in a table is column number 1, the second is number 2, and so forth.
A pointer to the space in which blk_default will place the default value.
The length, in bytes, of the *buffer data space.
A pointer to an integer variable.
If supplied, blk_default sets *outlen to the length, in bytes, of the default value.
If the default value is larger than buflen bytes, an application can use the value of *outlen to determine how many bytes are needed to hold the value.
blk_default returns:
Returns |
Indicates |
---|---|
CS_SUCCEED |
The routine completed successfully. |
CS_FAIL |
The routine failed. |
blk_default returns CS_FAIL if the application has not called blk_init to initialize the bulk-copy operation.
blk_default is a client-side routine.
An application can call blk_default to find out whether a default value is defined for a particular target column, and, if so, what the default value is.
This information can be useful while preparing to bulk copy rows into a database. The application can set *datalen and *indicator values to specify whether a column’s default value should be used. (datalen and indicator are the addresses of program variables that were bound to the column with blk_bind). See “Specifying Null values for Bulk Copy into the database” for more information.
If the column of interest does not have a default value, blk_default sets *outlen to CS_NO_DEFAULT and returns CS_SUCCEED.
An application can retrieve column defaults with blk_default only during a bulk-copy-in operation. The application cannot call blk_default until blk_init(CS_BLK_IN) returns CS_SUCCEED.