acnet_status.i2.v = db_select(handle.g.v, request_buffer.i1a.r,
This routine reads data from relational databases using SQL.
Help with datatypes and creating tables is in intro_database.
Multiple SQL commands are allowed, but in most cases all returned
data sets must be homogenous to avoid errors.
handle database connection handle returned from
a previous call to 'db_open'
request_buffer SQL statment text, NULL terminated string
num_rows an input/output parameter, input is number of
rows that will fit in reply_buffer, output
is number of rows actually returned.
Ignored if db_select is setting up
bytes_per_row EXACT size of each and every returned row
(sum of the lengths of all columns requested)
If db_select is setting up a call to
'db_nextrow' and bytes_per_row is not passed in
'db_nextrow', this value is used.
reply_buffer user's array of structures into which the
returned rows will be moved, NULL if
'db_nextrow' is going to be called
Note on text/image columns:
Sybase image and text columns are treated specially. Instead of
embedding the data directly into the caller's reply_buffer, a buffer is
malloc'd and a pointer to it is placed in the reply_buffer. The
function db_free_image should be used to free the buffer responsibility
to free the image/data buffers. One buffer is malloc'd for each column
of each row that contains image/text data. All non-NULL buffer
pointers MUST be freed, or a memory leak will result.
The column in the reply_buffer should be declared as "unsigned char*".
If the length of the image/text data is needed (i.e., if it is not
fixed length or self-describng) then you should include
"datalength(name)" as one of the columns of the query (where "name" is
the name of the column in question). For convenience, a null byte is
appended to text data.
01. This function may also be used to modify data, however in the
case when no explicit result or status is expected, the 'db_modify'
function is more appropriate.
This function returns ACNET status values as follows:
SQL_SMALLROW success, but row is smaller than bytes_per_row
SQL_MOREROWS success, but more than num_rows are available
SQL_xxx database access failure
This function requires the following include files:
db_modify, db_open, db_close, db_error, db_nextrow, db_free_image