SQLStmtAttribute - cSQLStatement
[Obsolete] Returns a statement attribute.
Type: Function
Return Data Type: String
Parameters
| Parameter | Type | Description |
|---|---|---|
| iAttribId | Integer | Attribute id to return |
Syntax
Function SQLStmtAttribute Integer iAttribId Returns String
Call Example
Get SQLStmtAttribute iAttribId to StringVariable
Description
SQLStmtAttribute is obsolete and has been replaced by SQLGetStmtAttribute.
Returns the specified statement attribute.
| Attribute | Description | Constant | Meaning |
|---|---|---|---|
| SQLSTMTATTRIB_COLUMNCOUNT | The number of columns in the result set of the statement. | ||
| SQLSTMTATTRIB_ROWCOUNT | The number of rows in the result of the statement. For update, delete or insert statement this attribute returns the number of rows affected by the statement. | ||
| SQLSTMTATTRIB_ROWCOUNT_TYPE | The accuracy of the rowcount attribute. This attribute can be:ConstantMeaning | ||
| 1 | The rowcount returns the exact number of rows | ||
| 0 | The rowcount does not return a meaningfull value | ||
| -1 | The rowcount is approximate | ||
| SQLSTMTATTRIB_NUMMESSAGES | The number of informational messages of the statement. You can get the messages by calling SQLGetMessage. |
The attributes described above can be accessed through predefined constants. These constants have the SQLSTMTATTRIB_ prefix. So to get the number of columns of a statement, one would program:
Get SQLStmtAttribute Of hstmt SQLSTMTATTRIB_COLUMNCOUNT ;
To iNumColumns
Sample
A full source example of getting the column count of a select statement is:
Handle hoSQLMngr
Handle hdbc hstmt
Integer iFetchResult
Integer iNumCols iCol
String sColumn
Object oSQLHandler Is A cSQLHandleManager
Move Self To hoSQLMngr
End_Object
Open Customer
Get SQLFileConnect Of hoSQLMngr Customer.File_number To hdbc
Get SQLOpen Of hdbc To hstmt
Send SQLExecDirect Of hstmt "select * from customer"
Get SQLStmtAttribute Of hstmt SQLSTMTATTRIB_COLUMNCOUNT To iNumCols
Repeat
Get SQLFetch Of hstmt To iFetchResult
If (iFetchResult <> 0) Begin
For iCol From 1 To iNumCols
Get SQLColumnValue Of hstmt iCol To sColumn
Show sColumn
If (iCol < iNumCols) ;
Show ", "
Loop
Showln
End
Until (iFetchResult = 0)
Send SQLClose Of hstmt
Send SQLDisconnect Of hdbc
Return Value
Returns a statement attribute.