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

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

#include <cursor.h>

Inheritance diagram for dballe::db::v5::Cursor:
dballe::db::Cursor

Public Member Functions

 Cursor (v5::DB &db)
 
virtual dballe::DBget_db () const
 Get the database that created this cursor.
 
int query (const Record &query, unsigned int wanted, unsigned int modifiers)
 Create and execute a database query. More...
 
void query_datetime_extremes (const Record &query, Record &result)
 
int remaining () const
 Get the number of rows still to be fetched. More...
 
bool next ()
 Get a new item from the results of a query. More...
 
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. More...
 
virtual int get_station_id () const
 Get the station identifier.
 
virtual double get_lat () const
 Get the station latitude.
 
virtual double get_lon () const
 Get the station longitude.
 
virtual const char * get_ident (const char *def=0) const
 Get the station identifier, or NULL if missing.
 
virtual const char * get_rep_memo (const char *def=0) const
 Get the report name.
 
virtual Level get_level () const
 Get the level.
 
virtual Trange get_trange () const
 Get the level.
 
virtual void get_datetime (int(&dt)[6]) const
 Get the datetime.
 
virtual wreport::Varcode get_varcode () const
 Get the variable code.
 
virtual wreport::Var get_var () const
 Get the variable.
 
virtual int attr_reference_id () const
 Return an integer value that can be used to refer to the current variable for attribute access.
 
unsigned query_attrs (const AttrList &qcs, Record &attrs)
 Query attributes for the current variable.
 
virtual void attr_insert (const Record &attrs)
 Insert/overwrite new attributes for the current variable. More...
 
virtual void attr_remove (const AttrList &qcs)
 Delete attributes for the current variable. More...
 
- Public Member Functions inherited from dballe::db::Cursor
virtual unsigned test_iterate (FILE *dump=0)
 Iterate the cursor until the end, returning the number of items. More...
 

Data Fields

v5::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.
 
bool query_station_vars
 True if we are querying station variables.
 
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. More...
 

Detailed Description

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

Member Function Documentation

virtual void dballe::db::v5::Cursor::attr_insert ( const Record attrs)
virtual

Insert/overwrite new attributes for the current variable.

Parameters
attrsThe record with the attributes to be added

Implements dballe::db::Cursor.

virtual void dballe::db::v5::Cursor::attr_remove ( const AttrList &  qcs)
virtual

Delete attributes for the current variable.

Parameters
qcsArray of WMO codes of the attributes to delete. If empty, all attributes associated to id_data will be deleted.

Implements dballe::db::Cursor.

int dballe::db::v5::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.
bool dballe::db::v5::Cursor::next ( )
virtual

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

Implements dballe::db::Cursor.

int dballe::db::v5::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
int dballe::db::v5::Cursor::remaining ( ) const
virtual

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.

Implements dballe::db::Cursor.

void dballe::db::v5::Cursor::to_record ( Record rec)
virtual

Fill in a record with the contents of a dba_db_cursor.

Parameters
recThe record where to store the values

Implements dballe::db::Cursor.


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