Define substitution values to be used when binding null values.
RETCODE dbsetnull(dbproc, bindtype, bindlen, bindval) DBPROCESS *dbproc; int bindtype; int bindlen; BYTE *bindval;
A pointer to the DBPROCESS structure that provides the connection for a particular front-end/server process. It contains all the information that DB-Library uses to manage communications and data between the front end and server.
A symbolic value specifying the type of variable binding to which the substitute value will apply. (See the reference page for dbbind.)
The length in bytes of the substitute value you are supplying. DB-Library ignores it in all cases except CHARBIND and BINARYBIND. All the other types are either fixed length or have a special terminator or embedded byte-count that provides the length of the data.
A generic BYTE pointer to the value you want to use as a null substitution value. dbsetnull makes a copy of the value, so you can free this pointer anytime after this call.
SUCCEED or FAIL.
dbsetnull returns FAIL if you give it an unknown bindtype. It will also fail if the specified DBPROCESS is dead.
The dbbind and dbaltbind routines bind result column values to program variables. After the application calls them, calls to dbnextrow and dbgetrow automatically copy result values into the variables to which they are bound. If the server returns a null value for one of the result columns, DB-Library automatically places a substitute value into the result variable.
Each DBPROCESS has a list of substitute values for each of the binding types. Table 2-28 lists the default substitution values:
Binding type |
Null substitution value |
---|---|
TINYBIND |
0 |
SMALLBIND |
0 |
INTBIND |
0 |
CHARBIND |
Empty string (padded with blanks) |
STRINGBIND |
Empty string (padded with blanks, null-terminated) |
NTBSTRINGBIND |
Empty string (null-terminated) |
VARYCHARBIND |
Empty string |
BINARYBIND |
Empty array (padded with zeros) |
VARYBINBIND |
Empty array |
DATETIMEBIND |
8 bytes of zeros |
SMALLDATETIMEBIND |
8 bytes of zeros |
MONEYBIND |
$0.00 |
SMALLMONEYBIND |
$0.00 |
FLT8BIND |
0.0 |
REALBIND |
0.0 |
DECIMALBIND |
0.0 (with default scale and precision) |
NUMERICBIND |
0.0 (with default scale and precision) |
BOUNDARYBIND |
Empty string (null-terminated) |
SENSITIVITYBIND |
Empty string (null-terminated) |
dbsetnull lets you provide your own null substitution values. When you call dbsetnull to change a particular null substitution value, the new value will remain in force for the specified DBPROCESS until you change it with another call to dbsetnull.
The dbconvert routine also uses the current null substitution values when it needs to set a destination variable to null.
The dbnullbind routine allows you to associate an indicator variable with a bound column. DB-Library will set the indicator value to indicate null data values or conversion errors.