Difference between revisions of "OpenDBX/C API/odbx column count"
m (1 revision(s)) |
|||
(5 intermediate revisions by 3 users not shown) | |||
Line 2: | Line 2: | ||
'''Get the number of columns in the current result set''' | '''Get the number of columns in the current result set''' | ||
− | #include < | + | #include <opendbx/api.h> |
− | + | ||
int '''odbx_column_count'''( | int '''odbx_column_count'''( | ||
odbx_result_t* '''''result''''' ) | odbx_result_t* '''''result''''' ) | ||
Line 11: | Line 11: | ||
Returns the number of columns which belongs to the current result set allocated by [[OpenDBX/API/odbx_result|odbx_result]](). The number will never change within a result set with one notable exception: MySQL returns all outstanding rows of a previous result set first if they were not fetched completely by [[OpenDBX/API/odbx_row_fetch|odbx_row_fetch]]() before. Therefore, the column count might change in this special situation. It is strongly advised to fetch all rows of a result set before calling [[OpenDBX/API/odbx_result|odbx_result]]() again because other backends will return an error in this case. | Returns the number of columns which belongs to the current result set allocated by [[OpenDBX/API/odbx_result|odbx_result]](). The number will never change within a result set with one notable exception: MySQL returns all outstanding rows of a previous result set first if they were not fetched completely by [[OpenDBX/API/odbx_row_fetch|odbx_row_fetch]]() before. Therefore, the column count might change in this special situation. It is strongly advised to fetch all rows of a result set before calling [[OpenDBX/API/odbx_result|odbx_result]]() again because other backends will return an error in this case. | ||
− | The '''''result''''' parameter required by this function must be a valid result set returned by [[OpenDBX/API/odbx_result|odbx_result]]() and must not has been feed to [[OpenDBX/API/ | + | The '''''result''''' parameter required by this function must be a valid result set returned by [[OpenDBX/API/odbx_result|odbx_result]]() and must not has been feed to [[OpenDBX/API/odbx_result_finish|odbx_result_finish]]() before. |
== Return value == | == Return value == | ||
Line 26: | Line 26: | ||
* [[OpenDBX/API/odbx_column_type|odbx_column_type]]() | * [[OpenDBX/API/odbx_column_type|odbx_column_type]]() | ||
* [[OpenDBX/API/odbx_result|odbx_result]]() | * [[OpenDBX/API/odbx_result|odbx_result]]() | ||
− | |||
− | |||
− | |||
− |
Latest revision as of 23:10, 28 April 2009
Get the number of columns in the current result set
#include <opendbx/api.h>
int odbx_column_count( odbx_result_t* result )
Description
Returns the number of columns which belongs to the current result set allocated by odbx_result(). The number will never change within a result set with one notable exception: MySQL returns all outstanding rows of a previous result set first if they were not fetched completely by odbx_row_fetch() before. Therefore, the column count might change in this special situation. It is strongly advised to fetch all rows of a result set before calling odbx_result() again because other backends will return an error in this case.
The result parameter required by this function must be a valid result set returned by odbx_result() and must not has been feed to odbx_result_finish() before.
Return value
odbx_column_count() returns the number of columns/fields which are available in the current result set. The value depends on the column list being part of the SELECT query and it is zero if the query wasn't a SELECT-like query.
Errors
This function will also return zero if the result parameter is invalid.