Difference between revisions of "OpenDBX/C API/odbx field value"

From Linuxnetworks
< OpenDBX‎ | C API
Jump to: navigation, search
(enhanced article)
(Description)
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 +
'''Returns the data stored in a field'''
 +
 +
#include <opendbx/api.h>
  
'''#include <odbx.h>'''
 
 
 
  const char* '''odbx_field_value'''(
 
  const char* '''odbx_field_value'''(
     odbx_result_t* '''result''',
+
     odbx_result_t* '''''result''''',
     unsigned long '''pos''' )
+
     unsigned long '''''pos''''' )
 
+
= Description =
+
 
+
'''odbx_field_value()''' returns a pointer to the field value specified by the column index '''pos'''. The field is part of the current row which was retrieved by the latest call to [[OpenDBX row_fetch|odbx_row_fetch()]].
+
  
All values except binary objects are handed back as strings terminated by the zero character. This does also apply to numeric values, dates, etc. They have to be converted to their binary machine dependent representation before arithmetic operations can be done. If a value is undefined, i.e. "NULL" is attached to the field in the database, an equivalent NULL pointer is returned.
+
== Description ==
  
The '''result''' parameter required by this function must be a valid result set returned by [[OpenDBX result|odbx_result()]] and must not have been feed to [[OpenDBX result_free|odbx_result_free()]] before.
+
[[OpenDBX/API/odbx_field_value|odbx_field_value]]() returns a pointer to the field data specified by the column index '''''pos'''''. The field is part of the current row which was retrieved by the latest call to [[OpenDBX/API/odbx_row_fetch|odbx_row_fetch]]().
  
Valid column indices for the requested column provided via '''pos''' start with zero and end with the value returned by [[OpenDBX column_count|odbx_column_count()]] minus one.
+
All values except binary objects (and large objects if the ODBC_CAP_LO interface is supported) are handed back as strings terminated by the zero character. This does also apply to numeric values, dates, etc. They have to be converted to their binary machine dependent representation before arithmetic operations can be done. If a value is undefined, i.e. "NULL" is attached to the field in the database, an equivalent NULL pointer is returned. Backends supporting the large objects interface return a reference to the object that have to be feed into [[OpenDBX/API/odbx_lo_open|odbx_lo_open]]().
  
= Return values =
+
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.
  
The function provides the address of the field value pointing to its beginning back to the caller where the string or binary object is stored in memory. It returns a NULL pointer if the field is a "NULL" value.
+
Valid column indices for the requested column provided via '''''pos''''' start with zero and end with the value returned by [[OpenDBX/API/odbx_column_count|odbx_column_count]]() minus one.
  
= Errors =
+
== Return value ==
  
This function will also return NULL if the '''result''' parameter is invalid or if the value of '''pos''' is out of range.
+
The function provides the address pointing to the beginning of the field value where the string or binary object is stored in memory to the caller. It returns a NULL pointer if the field is a "NULL" value.
  
= See also =
+
== Errors ==
  
* [[OpenDBX column_type|odbx_column_type()]]
+
This function will also return zero if the '''''result''''' parameter is invalid or if the value of '''''pos''''' is out of range.
* [[OpenDBX field_length|odbx_field_length()]]
+
  
 +
== See also ==
  
----
+
* [[OpenDBX/API/odbx_column_type|odbx_column_type]]()
Back to [[OpenDBX API|Overview]]
+
* [[OpenDBX/API/odbx_field_length|odbx_field_length]]()
 +
* [[OpenDBX/API/odbx_result|odbx_result]]()

Latest revision as of 08:16, 6 July 2010

Returns the data stored in a field

#include <opendbx/api.h>
const char* odbx_field_value(
    odbx_result_t* result,
    unsigned long pos )

Description

odbx_field_value() returns a pointer to the field data specified by the column index pos. The field is part of the current row which was retrieved by the latest call to odbx_row_fetch().

All values except binary objects (and large objects if the ODBC_CAP_LO interface is supported) are handed back as strings terminated by the zero character. This does also apply to numeric values, dates, etc. They have to be converted to their binary machine dependent representation before arithmetic operations can be done. If a value is undefined, i.e. "NULL" is attached to the field in the database, an equivalent NULL pointer is returned. Backends supporting the large objects interface return a reference to the object that have to be feed into odbx_lo_open().

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.

Valid column indices for the requested column provided via pos start with zero and end with the value returned by odbx_column_count() minus one.

Return value

The function provides the address pointing to the beginning of the field value where the string or binary object is stored in memory to the caller. It returns a NULL pointer if the field is a "NULL" value.

Errors

This function will also return zero if the result parameter is invalid or if the value of pos is out of range.

See also