The mi_column_default_string() function
The mi_column_default_string() function retrieves the default value of the specified column in string format.
Syntax
mi_integer mi_column_default_string(row_desc, column_id,
default_val)
MI_ROW_DESC *row_desc;
mi_integer column_id;
mi_string **default_val;
- row_desc
- A pointer to the row descriptor for the row that contains the column.
- column_id
- Indicates the column identifier, which specifies the position of the column in the specified row descriptor. Column numbering follows C array-indexing conventions: the first column in the row descriptor is at position zero.
- default_val
- A pointer to an mi_string buffer that contains the column default value. The mi_column_default_string() function allocates the mi_string buffer. The default_val parameter is passed by reference.
Valid in client LIBMI application? | Valid in user-defined routine? |
---|---|
Yes | Yes |
Usage
The mi_column_default_string() function returns the default value that is defined for the column by the DEFAULT clause of the CREATE TABLE or ALTER TABLE statements. The mi_column_default_string() function returns the default value for the column in string representation.
For example, you can create a table with two columns that have default values:
CREATE TABLE tab(col1 int DEFAULT 10, col2 varchar(12) DEFAULT 'permanent');
The mi_column_default_string() function
returns a string with the values 10
and ’permanent’
.
Return values
- 0
- The specified column is not defined with a default value.
- 1 and the contents of the mi_string buffer
- The specified column contains a default value. If the value of the mi_string structure is NULL, the default value of the column is NULL.
- MI_ERROR
- The function was not successful.