SQLStmtAttribute Command
Obsolete
Refer to the SQLStmtAttribute method in the cSQLStatement class.
SQLStmtAttribute hstmt iAttribId To sAttribValue
The SQLStmtAttribute command allows the programmer to get statement attributes.
Attributes
| Attribute | Description |
|---|---|
| COLUMNCOUNT | The number of columns in the result set of the statement. |
| ROWCOUNT | The number of rows in the result of the statement. For update, delete, or insert statements, this attribute returns the number of rows affected by the statement. |
| ROWCOUNT_TYPE | The accuracy of the rowcount attribute. This attribute can be: |
| - 1: The rowcount returns the exact number of rows. | |
| - 0: The rowcount does not return a meaningful value. | |
| - -1: The rowcount is approximate. |
The rowcount type depends on the type of cursor used for the Embedded SQL statement. Some back ends will automatically adjust cursor types. For example, SQL Server does not support all cursor types for certain statements. If a statement is issued for a non-supported cursor type, the cursor type will be adjusted.
The attributes described above can be accessed through predefined constants. These constants have the SQLSTMTATTRIB_ prefix. To get the number of columns of a statement, one would program:
SQLStmtAttribute hstmt SQLSTMTATTRIB_COLUMNCOUNT To iNumColumns
Example
A full source example of getting the column count of a select statement is:
Open Customer
SQLFileConnect Customer To hdbc
SQLOpen hdbc To hstmt
SQLExecDirect hstmt "SELECT * FROM Customer"
SQLStmtAttribute hstmt SQLSTMTATTRIB_COLUMNCOUNT To iNumColumns
Showln "The statement has " iNumColumns " columns."