#include <dballe/core/record.h>
#include <dballe/core/var.h>
#include <dballe/db/cursor.h>
Go to the source code of this file.
Typedefs | |
typedef struct _dba_db * | dba_db |
DB-ALLe connection. | |
Functions | |
dba_err | dba_db_create (const char *dsn, const char *user, const char *password, dba_db *db) |
Start a session with DBALLE. | |
void | dba_db_delete (dba_db db) |
End a session with DBALLE. | |
dba_err | dba_db_reset (dba_db db, const char *repinfo_file) |
Reset the database, removing all existing DBALLE tables and re-creating them empty. | |
dba_err | dba_db_delete_tables (dba_db db) |
Delete all the DB-ALLe tables from the database. | |
dba_err | dba_db_update_repinfo (dba_db db, const char *repinfo_file, int *added, int *deleted, int *updated) |
Update the repinfo table in the database, with the data found in the given file. | |
dba_err | dba_db_rep_cod_from_memo (dba_db db, const char *memo, int *rep_cod) |
Get the report code from a report mnemonic. | |
dba_err | dba_db_check_rep_cod (dba_db db, int rep_cod, int *valid) |
Verify that a rep_cod is supported by the database. | |
dba_err | dba_db_ana_query (dba_db db, dba_record query, dba_db_cursor *cur, int *count) |
Start a query on the anagraphic archive. | |
dba_err | dba_db_insert (dba_db db, dba_record rec, int can_replace, int pseudoana_can_add, int *ana_id, int *context_id) |
Insert a record into the database. | |
dba_err | dba_db_query (dba_db db, dba_record rec, dba_db_cursor *cur, int *count) |
Query the database. | |
dba_err | dba_db_remove (dba_db db, dba_record rec) |
Remove data from the database. | |
dba_err | dba_db_remove_orphans (dba_db db) |
Remove orphan values from the database. | |
dba_err | dba_db_qc_query (dba_db db, int id_context, dba_varcode id_var, const dba_varcode *qcs, size_t qcs_size, dba_record attrs, int *count) |
Query QC data. | |
dba_err | dba_db_qc_insert_or_replace (dba_db db, int id_context, dba_varcode id_var, dba_record attrs, int can_replace) |
Insert a new QC value into the database. | |
dba_err | dba_db_qc_insert (dba_db db, int id_context, dba_varcode id_var, dba_record attrs) |
Insert a new QC value into the database. | |
dba_err | dba_db_qc_insert_new (dba_db db, int id_context, dba_varcode id_var, dba_record attrs) |
Insert a new QC value into the database. | |
dba_err | dba_db_qc_remove (dba_db db, int id_context, dba_varcode id_var, dba_varcode *qcs, int qcs_size) |
Delete QC data for the variable `var' in record `rec' (coming from a previous dba_query). |
dba_err dba_db_ana_query | ( | dba_db | db, | |
dba_record | query, | |||
dba_db_cursor * | cur, | |||
int * | count | |||
) |
Start a query on the anagraphic archive.
db | The dballe session id | |
query | The record with the query data (see Keywords used by dba_record) |
cur | The dba_db_cursor variable that will hold the resulting dba_db_cursor that can be used to get the result values (See dba_db_cursor_next). dba_db_ana_query() will create the cursor, and it is up to the caller to delete it using dba_db_cursor_delete(). |
count | The count of items in the anagraphic archive, returned by the function |
Verify that a rep_cod is supported by the database.
db | The dballe database | |
rep_cod | The report code to verify |
valid | Set to 1 if the report code is supported, 0 if not |
Start a session with DBALLE.
dsn | The ODBC DSN of the database to use | |
user | The user name to use to connect to the DSN | |
password | The password to use to connect to the DSN. To specify an empty password, pass "" or NULL | |
db | The dba_db handle returned by the function |
void dba_db_delete | ( | dba_db | db | ) |
End a session with DBALLE.
All the resources associated with db will be freed. db should not be used anymore, unless it is recreated with dba_open
db | The dballe session id |
Delete all the DB-ALLe tables from the database.
db | The dballe session id |
dba_err dba_db_insert | ( | dba_db | db, | |
dba_record | rec, | |||
int | can_replace, | |||
int | pseudoana_can_add, | |||
int * | ana_id, | |||
int * | context_id | |||
) |
Insert a record into the database.
In a record with the same phisical situation already exists, the function fails.
db | The dballe session id. | |
rec | The record to insert. | |
can_replace | If true, then existing data can be rewritten, else data can only be added. | |
pseudoana_can_add | If true, then it is allowed to add new pseudoana records to the database. Otherwise, data can be added only by reusing existing ones. |
ana_id | ID of the pseudoana record for the entry just inserted. NULL can be used if the caller is not interested in this value. | |
context_id | ID of the context record for the entry just inserted. NULL can be used if the caller is not interested in this value. |
dba_err dba_db_qc_insert | ( | dba_db | db, | |
int | id_context, | |||
dba_varcode | id_var, | |||
dba_record | attrs | |||
) |
Insert a new QC value into the database.
If the same QC value exists for the same data, it is overwritten
db | The dballe session id | |
id_context | The database id of the context related to the attributes to insert | |
id_var | The varcode of the variable related to the attributes to add. See vartable.h | |
attrs | The record with the attributes to be added |
dba_err dba_db_qc_insert_new | ( | dba_db | db, | |
int | id_context, | |||
dba_varcode | id_var, | |||
dba_record | attrs | |||
) |
Insert a new QC value into the database.
If the same QC value exists for the same data, the function fails.
db | The dballe session id | |
id_context | The database id of the context related to the attributes to insert | |
id_var | The varcode of the variable related to the attributes to add. See vartable.h | |
attrs | The record with the attributes to be added |
dba_err dba_db_qc_insert_or_replace | ( | dba_db | db, | |
int | id_context, | |||
dba_varcode | id_var, | |||
dba_record | attrs, | |||
int | can_replace | |||
) |
Insert a new QC value into the database.
db | The dballe session id | |
id_context | The database id of the context related to the attributes to insert | |
id_var | The varcode of the variable related to the attributes to add. See vartable.h | |
attrs | The record with the attributes to be added | |
can_replace | If true, then existing data can be rewritten, else data can only be added. |
dba_err dba_db_qc_query | ( | dba_db | db, | |
int | id_context, | |||
dba_varcode | id_var, | |||
const dba_varcode * | qcs, | |||
size_t | qcs_size, | |||
dba_record | attrs, | |||
int * | count | |||
) |
Query QC data.
db | The dballe session id | |
id_context | The database id of the context related to the attributes to retrieve | |
id_var | The varcode of the variable related to the attributes to retrieve. See vartable.h | |
qcs | The WMO codes of the QC values requested. If it is NULL, then all values are returned. | |
qcs_size | Number of elements in qcs | |
attrs | The dba_record that will hold the resulting attributes |
count | Number of QC items returned in qc |
dba_err dba_db_qc_remove | ( | dba_db | db, | |
int | id_context, | |||
dba_varcode | id_var, | |||
dba_varcode * | qcs, | |||
int | qcs_size | |||
) |
Delete QC data for the variable `var' in record `rec' (coming from a previous dba_query).
db | The dballe session id | |
id_context | The database id of the context related to the attributes to remove | |
id_var | The varcode of the variable related to the attributes to remove. See vartable.h | |
qcs | Array of WMO codes of the QC data to delete. If NULL, all QC data associated to id_data will be deleted. | |
qcs_size | Number of items in the qcs array. |
dba_err dba_db_query | ( | dba_db | db, | |
dba_record | rec, | |||
dba_db_cursor * | cur, | |||
int * | count | |||
) |
Query the database.
When multiple values per variable are present, the results will be presented in increasing order of priority.
db | The dballe session id | |
rec | The record with the query data (see technical specifications, par. 1.6.4 "parameter output/input") |
cur | The dba_db_cursor variable that will hold the resulting dba_db_cursor that can be used to get the result values (See dba_db_cursor_next) dba_db_query will create the cursor, and it is up to the caller to delete it using dba_db_cursor_delete. | |
count | The number of values returned by the query |
dba_err dba_db_remove | ( | dba_db | db, | |
dba_record | rec | |||
) |
Remove data from the database.
db | The dballe session id | |
rec | The record with the query data (see technical specifications, par. 1.6.4 "parameter output/input") to select the items to be deleted |
Remove orphan values from the database.
Orphan values are currently:
db | Database to operate on |
Reset the database, removing all existing DBALLE tables and re-creating them empty.
db | The dballe session id | |
repinfo_file | The name of the CSV file with the report type information data to load. The file is in CSV format with 6 columns: report code, mnemonic id, description, priority, descriptor, table A category. If repinfo_file is NULL, then the default of /etc/dballe/repinfo.csv is used. |
dba_err dba_db_update_repinfo | ( | dba_db | db, | |
const char * | repinfo_file, | |||
int * | added, | |||
int * | deleted, | |||
int * | updated | |||
) |
Update the repinfo table in the database, with the data found in the given file.
db | The dballe session id | |
repinfo_file | The name of the CSV file with the report type information data to load. The file is in CSV format with 6 columns: report code, mnemonic id, description, priority, descriptor, table A category. If repinfo_file is NULL, then the default of /etc/dballe/repinfo.csv is used. |
added | The number of repinfo entryes that have been added | |
deleted | The number of repinfo entryes that have been deleted | |
updated | The number of repinfo entryes that have been updated |