| Database Toolbox | ![]() |
Get attributes of columns in fetched data set
Syntax
attributes = attr(curs, colnum) attributes = attr(curs)
Description
attributes = attr(curs, colnum)
retrieves attribute information for the specified column number colnum, in the fetched data set curs.
attributes = attr(curs)
retrieves attribute information for all columns in the fetched data set curs, and stores it in a cell array. Use attributes(colnum) to display the attributes for column colnum.
The returned attributes are listed in the following table.
| Attribute |
Description |
fieldName |
Name of the column |
typeName |
Data type |
typeValue |
Numerical representation of the data type |
columnWidth |
Size of the field |
precision |
Precision value for floating and double data types; an empty value is returned for strings |
scale |
Precision value for real and numeric data types; an empty value is returned for strings |
currency |
If true, data format is currency |
readOnly |
If true, the data cannot be overwritten |
nullable |
If true, the data can be NULL |
Message |
Error message returned by fetch |
Example 1 - Get Attributes for One Column
Get the column attributes for the fourth column of a fetched data set.
attr(curs, 4)
ans =
fieldName: 'Age'
typeName: 'LONG'
typeValue: 4
columnWidth: 11
precision: []
scale: []
currency: 'false'
readOnly: 'false'
nullable: 'true'
Message: []
Example 2 - Get Attributes for All Columns
Get the column attributes for curs, and assign them to attributes.
attributes = attr(curs)
View the attributes of column 4.
attributes(4)
MATLAB returns the attributes of column 4.
ans =
fieldName: 'Age'
typeName: 'LONG'
typeValue: 4
columnWidth: 11
precision: []
scale: []
currency: 'false'
readOnly: 'false'
nullable: 'true'
Message: []
See Also
cols, columnnames, columns, dmd, fetch, get, tables, width
| Alphabetical List of Functions | bestrowid | ![]() |