libdballe  5.18
Public Member Functions | Data Fields | Protected Member Functions
dballe::db::Cursor Struct Reference

Structure used to build and execute a query, and to iterate through the results. More...

#include <cursor.h>

Public Member Functions

 Cursor (DB &db)
int query (const Record &query, unsigned int wanted, unsigned int modifiers)
 Create and execute a database query.
int remaining () const
 Get the number of rows still to be fetched.
bool next ()
 Get a new item from the results of a query.
void discard_rest ()
 Discard the results that have not been read yet.
void to_record (Record &rec)
 Fill in a record with the contents of a dba_db_cursor.
unsigned query_attrs (const AttrList &qcs, Record &attrs)
 Query attributes for the current variable.

Data Fields

DBdb
 Database to operate on.
db::Statementstm
 ODBC statement to use for the query.
unsigned int wanted
 What values are wanted from the query.
unsigned int modifiers
 Modifier flags to enable special query behaviours.
unsigned int from_wanted
 What is in the FROM part of the query, used to know what output fields are bound.
DBALLE_SQL_C_SINT_TYPE count
 Number of results still to be fetched.
DBALLE_SQL_C_SINT_TYPE out_lat
 Query results.
DBALLE_SQL_C_SINT_TYPE out_lon
 Query results.
char out_ident [64]
 Query results.
SQLLEN out_ident_ind
 Query results.
DBALLE_SQL_C_SINT_TYPE out_ltype1
 Query results.
DBALLE_SQL_C_SINT_TYPE out_l1
 Query results.
DBALLE_SQL_C_SINT_TYPE out_ltype2
 Query results.
DBALLE_SQL_C_SINT_TYPE out_l2
 Query results.
DBALLE_SQL_C_SINT_TYPE out_pind
 Query results.
DBALLE_SQL_C_SINT_TYPE out_p1
 Query results.
DBALLE_SQL_C_SINT_TYPE out_p2
 Query results.
wreport::Varcode out_varcode
 Query results.
SQL_TIMESTAMP_STRUCT out_datetime
 Query results.
char out_value [255]
 Query results.
DBALLE_SQL_C_SINT_TYPE out_rep_cod
 Query results.
DBALLE_SQL_C_SINT_TYPE out_ana_id
 Query results.
DBALLE_SQL_C_SINT_TYPE out_context_id
 Query results.
DBALLE_SQL_C_SINT_TYPE out_priority
 Query results.

Protected Member Functions

void reset ()
 Reset the cursor at the beginning of a query.
void add_station_info (Record &rec)
 Query extra station info and add it to rec.
int getcount (const Record &query, unsigned int wanted, unsigned int modifiers)
 Return the number of results for a query.

Detailed Description

Structure used to build and execute a query, and to iterate through the results.


Member Function Documentation

int dballe::db::Cursor::getcount ( const Record query,
unsigned int  wanted,
unsigned int  modifiers 
) [protected]

Return the number of results for a query.

This is the same as Cursor::query, but it does a SELECT COUNT(*) only.

Warning:
: do not use it except to get an approximate row count: insert/delete/update queries run between the count and the select will change the size of the result set.

Get a new item from the results of a query.

Returns:
true if a new record has been read, false if there is no more data to read
int dballe::db::Cursor::query ( const Record query,
unsigned int  wanted,
unsigned int  modifiers 
)

Create and execute a database query.

The results are retrieved by iterating the cursor.

Parameters:
queryThe record with the query data (see technical specifications, par. 1.6.4 "parameter output/input"
wantedThe values wanted in output
modifiersOptional modifiers to ask for special query behaviours
Returns:
The count of items in the results

Get the number of rows still to be fetched.

Returns:
The number of rows still to be queried. The value is undefined if no query has been successfully peformed yet using this cursor.

Fill in a record with the contents of a dba_db_cursor.

Parameters:
recThe record where to store the values

The documentation for this struct was generated from the following file: