libdballeFortranbindings 4.0.18
|
Simplified interface for Dballe. More...
#include "dbapi.h"
#include "msgapi.h"
#include <dballe/core/verbose.h>
#include <dballe/core/aliases.h>
#include <dballe/db/db.h>
#include <dballe/db/cursor.h>
#include <dballe/db/internals.h>
#include <dballe/msg/formatter.h>
#include <dballe/init.h>
#include <f77.h>
#include <float.h>
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include "handles.h"
Defines | |
#define | TRACEMISSING(type) do {} while(0) |
#define | MISSING_BYTE SCHAR_MAX |
#define | MISSING_INT INT_MAX |
#define | MISSING_REAL FLT_MAX |
#define | MISSING_DOUBLE DBL_MAX |
#define | MAX_SIMPLE 50 |
#define | MAX_SESSION 10 |
#define | STATE (FDBA_HANDLE(simple, *handle)) |
#define | SESSION (FDBA_HANDLE(session, FDBA_HANDLE(simple, *handle).session).session) |
Functions | |
integer | idba_presentati (integer dbahandle, character dsn, character user, character password) |
Start working with a DBALLE database. | |
subroutine | idba_arrivederci (integer dbahandle) |
Stop working with a DBALLE database. | |
integer | idba_preparati (integer dbahandle, integer handle, character anaflag, character dataflag, character attrflag) |
Starts a session with dballe. | |
integer | idba_messaggi (integer handle, character filename, character mode, character type) |
Access a file with wheter messages. | |
integer | idba_fatto (integer handle) |
Ends a session with DBALLE. | |
integer | idba_scopa (integer handle, character repinfofile) |
Reset the database contents, loading default report informations from a file. | |
integer | idba_unset (integer handle, character parameter) |
Remove one parameter from the input record. | |
subroutine | idba_unsetall (integer handle) |
Remove all parameters from the input record. | |
integer | idba_quantesono (integer handle, integer count) |
Count the number of elements in the anagraphical storage, and start a new anagraphical query. | |
integer | idba_elencamele (integer handle) |
Iterate through the anagraphical data. | |
integer | idba_voglioquesto (integer handle, integer count) |
Submit a query to the database. | |
integer | idba_dammelo (integer handle, character parameter) |
Iterate through the query results data. | |
integer | idba_prendilo (integer handle) |
Insert a new item in the database. | |
integer | idba_dimenticami (integer handle) |
Remove all selected items from the database. | |
idba_enq* | |
integer | idba_enqi (integer handle, character parameter, integer value) |
Read one integer value from the output record. | |
integer | idba_enqb (integer handle, character parameter,) |
Read one byte value from the output record. | |
integer | idba_enqr (integer handle, character parameter, real value) |
Read one real value from the output record. | |
integer | idba_enqd (integer handle, character parameter, double value) |
Read one real*8 value from the output record. | |
integer | idba_enqc (integer handle, character parameter, character value) |
Read one character value from the output record. | |
idba_set* | |
integer | idba_seti (integer handle, character parameter, integer value) |
Set one integer value into the input record. | |
integer | idba_setb (integer handle, character parameter,) |
Set one byte value into the input record. | |
integer | idba_setr (integer handle, character parameter, real value) |
Set one real value into the input record. | |
integer | idba_setd (integer handle, character parameter, double value) |
Set one real*8 value into the input record. | |
integer | idba_setc (integer handle, character parameter, character value) |
Set one character value into the input record. | |
integer | idba_setcontextana (integer handle) |
Shortcut function to set query parameters to the anagraphical context. | |
integer | idba_enqlevel (integer handle, integer ltype1, integer l1, integer ltype2, integer l2) |
Shortcut function to read level data. | |
integer | idba_setlevel (integer handle, integer ltype1, integer l1, integer ltype2, integer l2) |
Shortcut function to set level data. | |
integer | idba_enqtimerange (integer handle, integer ptype, integer p1, integer p2) |
Shortcut function to read time range data. | |
integer | idba_settimerange (integer handle, integer ptype, integer p1, integer p2) |
Shortcut function to set time range data. | |
integer | idba_enqdate (integer handle, integer year, integer month, integer day, integer hour, integer min, integer sec) |
Shortcut function to read date information. | |
integer | idba_setdate (integer handle, integer year, integer month, integer day, integer hour, integer min, integer sec) |
Shortcut function to set date information. | |
integer | idba_setdatemin (integer handle, integer year, integer month, integer day, integer hour, integer min, integer sec) |
Shortcut function to set minimum date for a query. | |
integer | idba_setdatemax (integer handle, integer year, integer month, integer day, integer hour, integer min, integer sec) |
Shortcut function to set maximum date for a query. | |
QC functions | |
Functions used to manipulate QC data. All these functions require some context data about the variable, which is automatically available when the variable just came as the result of an idba_dammelo() or has just been inserted with an idba_prendilo(). | |
integer | idba_voglioancora (integer handle, integer count) |
Retrieve QC informations from the last variable returned by idba_dammelo(). | |
integer | idba_ancora (integer handle, character parameter) |
Retrieve QC informations from the last variable returned by idba_dammelo(). | |
integer | idba_critica (integer handle) |
Insert new QC informations for a variable of the current record. | |
integer | idba_scusa (integer handle) |
Remove QC informations for a variable of the current record. | |
integer | idba_spiegal (integer handle, integer ltype1, integer l1, integer ltype2, integer l2, character result) |
Retrieve QC informations from the last variable returned by idba_dammelo(). | |
integer | idba_spiegat (integer handle, integer ptype, integer p1, integer p2, character result) |
Retrieve QC informations from the last variable returned by idba_dammelo(). | |
integer | idba_spiegab (integer handle, character varcode, character value, character result) |
Retrieve QC informations from the last variable returned by idba_dammelo(). | |
integer | idba_test_input_to_output (integer handle) |
Retrieve QC informations from the last variable returned by idba_dammelo(). |
Simplified interface for Dballe.
Every function returns an error indicator, which is 0 if no error happened, or 1 if there has been an error.
When an error happens, the functions in fdba_error.c can be used to get detailed informations about it.
Behind the handle returned by idba_preparati() there are a set of variables that are used as implicit parameters:
query
::dba_record, used to set the parameters of the query made by idba_voglioquesto() work
::dba_record, used by idba_dammelo() to return the parameters qc
::dba_record, used to manipulate qc data. Every time the idba_enq or idba_set functions are used with a variable name starting with an asterisk, they will manipulate the qc
record instead of the others. ana
::dba_cursor, used to iterate on the results of idba_quantesono() query
::dba_cursor, used to iterate on the results of idba_voglioquesto()The simplified interface has two possible states: QUERY
and RESULT
. Then the interface is in the QUERY
state, the idba_enq and idba_set functions operate in the query
::dba_record, to set and check the parameters of a query. idba_voglioquesto() reads the parameters from the query
::dba_record and switches the state to RESULT
, and further calls to idba_dammelo() will put the query results in the work
::dba_record, to be read by the idba_enq functions.
In the RESULT
state, the idba_enq and idba_set functions operate on the work
::dba_record, to inspect the results of the queries. A call to idba_ricominciamo() terminates the current query and goes back to the QUERY
state, resetting the contents of all the ::dba_record of the interface.
idba_prendilo() inserts in the database the data coming from the QUERY
::dba_record if invoked in the query
state, or the data coming from the RESULT
::dba_record if invoked in the result
state. This is done because inserting new values in the database should be independent from the state.
qc functions instead always operate on the qc
::dba_record, which is accessed with the idba_enq and idba_set functions by prefixing the parameter name with an asterisk.
integer idba_ancora | ( | integer | handle, |
character | parameter | ||
) |
Retrieve QC informations from the last variable returned by idba_dammelo().
handle | Handle to a DBALLE session |
parameter | Contains the ID of the parameter retrieved by this fetch |
subroutine idba_arrivederci | ( | integer | dbahandle | ) |
Stop working with a DBALLE database.
dbahandle | The database handle to close. |
integer idba_critica | ( | integer | handle | ) |
Insert new QC informations for a variable of the current record.
QC informations inserted are all those set by the functions idba_seti(), idba_setc(), idba_setr(), idba_setd(), using an asterisk in front of the variable name.
Contrarily to idba_prendilo(), this function resets all the QC informations (but only the QC informations) previously set in input, so the values to be inserted need to be explicitly set every time.
This function will fail if the database is open in QC readonly mode, and it will refuse to overwrite existing values if the database is open in QC add mode.
The variable referred by the QC informations can be specified in three ways:
handle | Handle to a DBALLE session |
integer idba_dammelo | ( | integer | handle, |
character | parameter | ||
) |
Iterate through the query results data.
Every invocation of this function will return a new result, or fill fail with code DBA_ERR_NOTFOUND when there are no more results available.
handle | Handle to a DBALLE session |
parameter | Contains the ID of the parameter retrieved by this fetch |
integer idba_dimenticami | ( | integer | handle | ) |
Remove all selected items from the database.
This function will fail unless the database is open in data rewrite mode.
handle | Handle to a DBALLE session |
integer idba_elencamele | ( | integer | handle | ) |
Iterate through the anagraphical data.
Every invocation of this function will return a new anagraphical data, or fill fail with code DBA_ERR_NOTFOUND when there are no more anagraphical data available.
handle | Handle to a DBALLE session |
integer idba_enqb | ( | integer | handle, |
character | parameter | ||
) |
Read one byte value from the output record.
handle | Handle to a DBALLE session |
parameter | Parameter to query. It can be the code of a WMO variable prefixed by "B" (such as "B01023" ); the code of a QC value prefixed by "*B" (such as "*B01023" ) or a keyword among the ones defined in dba_record_keywords |
value | Where the value will be returned |
integer idba_enqc | ( | integer | handle, |
character | parameter, | ||
character | value | ||
) |
Read one character value from the output record.
handle | Handle to a DBALLE session |
parameter | Parameter to query. It can be the code of a WMO variable prefixed by "B" (such as "B01023" ); the code of a QC value prefixed by "*B" (such as "*B01023" ) or a keyword among the ones defined in dba_record_keywords |
value | Where the value will be returned |
integer idba_enqd | ( | integer | handle, |
character | parameter, | ||
double | value | ||
) |
Read one real*8 value from the output record.
handle | Handle to a DBALLE session |
parameter | Parameter to query. It can be the code of a WMO variable prefixed by "B" (such as "B01023" ); the code of a QC value prefixed by "*B" (such as "*B01023" ) or a keyword among the ones defined in dba_record_keywords |
value | Where the value will be returned |
integer idba_enqdate | ( | integer | handle, |
integer | year, | ||
integer | month, | ||
integer | day, | ||
integer | hour, | ||
integer | min, | ||
integer | sec | ||
) |
Shortcut function to read date information.
handle | Handle to a DBALLE session |
year | Year from the output record |
month | Month the output record |
day | Day the output record |
hour | Hour the output record |
min | Minute the output record |
sec | Second the output record |
integer idba_enqi | ( | integer | handle, |
character | parameter, | ||
integer | value | ||
) |
Read one integer value from the output record.
handle | Handle to a DBALLE session |
parameter | Parameter to query. It can be the code of a WMO variable prefixed by "B" (such as "B01023" ); the code of a QC value prefixed by "*B" (such as "*B01023" ) or a keyword among the ones defined in dba_record_keywords |
value | Where the value will be returned |
integer idba_enqlevel | ( | integer | handle, |
integer | ltype1, | ||
integer | l1, | ||
integer | ltype2, | ||
integer | l2 | ||
) |
Shortcut function to read level data.
handle | Handle to a DBALLE session |
ltype | Level type from the output record |
l1 | L1 from the output record |
l2 | L2 from the output record |
integer idba_enqr | ( | integer | handle, |
character | parameter, | ||
real | value | ||
) |
Read one real value from the output record.
handle | Handle to a DBALLE session |
parameter | Parameter to query. It can be the code of a WMO variable prefixed by "B" (such as "B01023" ); the code of a QC value prefixed by "*B" (such as "*B01023" ) or a keyword among the ones defined in dba_record_keywords |
value | Where the value will be returned |
integer idba_enqtimerange | ( | integer | handle, |
integer | ptype, | ||
integer | p1, | ||
integer | p2 | ||
) |
Shortcut function to read time range data.
handle | Handle to a DBALLE session |
ptype | P indicator from the output record |
p1 | P1 from the output record |
p2 | P2 from the output record |
integer idba_fatto | ( | integer | handle | ) |
Ends a session with DBALLE.
handle | Handle to the session to be closed. |
integer idba_messaggi | ( | integer | handle, |
character | filename, | ||
character | mode, | ||
character | type | ||
) |
Access a file with wheter messages.
handle | The session handle returned by the function |
filename | Name of the file to open |
mode | File open mode. It can be:
|
type | Format of the data in the file. It can be:
|
force_report | if 0, nothing happens; otherwise, choose the output message template using this report type instead of the one in the message |
integer idba_prendilo | ( | integer | handle | ) |
Insert a new item in the database.
This function will fail if the database is open in data readonly mode, and it will refuse to overwrite existing values if the database is open in data add mode.
If the database is open in pseudoana reuse mode, the pseudoana values provided on input will be used to create a pseudoana record if it is missing, but will be ignored if it is already present. If it is open in pseudoana rewrite mode instead, the pseudoana values on input will be used to replace all the existing pseudoana values.
handle | Handle to a DBALLE session |
integer idba_preparati | ( | integer | dbahandle, |
integer | handle, | ||
character | anaflag, | ||
character | dataflag, | ||
character | attrflag | ||
) |
Starts a session with dballe.
You can call idba_preparati() many times and get more handles. This allows to perform many operations on the database at the same time.
idba_preparati() has three extra parameters that can be used to limit write operations on the database, as a limited protection against programming errors.
Note that some combinations of parameters are illegal, such as anaflag=read and dataflag=add (when adding a new data, it's sometimes necessary to insert new pseudoana records), or dataflag=rewrite and qcflag=read (when deleting data, their attributes are deleted as well).
dbahandle | The main DB-ALLe connection handle |
handle | The session handle returned by the function |
anaflag | Controls access to pseudoana records and can have these values:
|
dataflag | Controls access to observed data and can have these values:
|
qcflag | Controls access to data attributes and can have these values:
|
integer idba_presentati | ( | integer | dbahandle, |
character | dsn, | ||
character | user, | ||
character | password | ||
) |
Start working with a DBALLE database.
This function can be called more than once once to connect to different databases at the same time.
dsn | The ODBC DSN of the database to use |
user | The username used to connect to the database |
password | The username used to connect to the database |
dbahandle | The database handle that can be passed to idba_preparati to work with the database. |
integer idba_quantesono | ( | integer | handle, |
integer | count | ||
) |
Count the number of elements in the anagraphical storage, and start a new anagraphical query.
Resulting anagraphical data can be retrieved with idba_elencamele()
handle | Handle to a DBALLE session |
count | The count of elements |
integer idba_scopa | ( | integer | handle, |
character | repinfofile | ||
) |
Reset the database contents, loading default report informations from a file.
It only works in rewrite mode.
handle | Handle to a DBALLE session |
repinfofile | CSV file with the default report informations. See dba_reset() documentation for the format of the file. |
integer idba_scusa | ( | integer | handle | ) |
Remove QC informations for a variable of the current record.
The QC informations to be removed are set with:
idba_setc(handle, "*varlist", "*B33021,*B33003");
The variable referred by the QC informations can be specified in three ways:
handle | Handle to a DBALLE session |
integer idba_setb | ( | integer | handle, |
character | parameter | ||
) |
Set one byte value into the input record.
handle | Handle to a DBALLE session |
parameter | Parameter to set. It can be the code of a WMO variable prefixed by "B" (such as "B01023" ); the code of a QC value prefixed by "*B" (such as "*B01023" ) or a keyword among the ones defined in dba_record_keywords |
value | The value to assign to the parameter |
integer idba_setc | ( | integer | handle, |
character | parameter, | ||
character | value | ||
) |
Set one character value into the input record.
handle | Handle to a DBALLE session |
parameter | Parameter to set. It can be the code of a WMO variable prefixed by "B" (such as "B01023" ); the code of a QC value prefixed by "*B" (such as "*B01023" ) or a keyword among the ones defined in dba_record_keywords |
value | The value to assign to the parameter |
integer idba_setcontextana | ( | integer | handle | ) |
Shortcut function to set query parameters to the anagraphical context.
handle | Handle to a DBALLE session |
integer idba_setd | ( | integer | handle, |
character | parameter, | ||
double | value | ||
) |
Set one real*8 value into the input record.
handle | Handle to a DBALLE session |
parameter | Parameter to set. It can be the code of a WMO variable prefixed by "B" (such as "B01023" ); the code of a QC value prefixed by "*B" (such as "*B01023" ) or a keyword among the ones defined in dba_record_keywords |
value | The value to assign to the parameter |
integer idba_setdate | ( | integer | handle, |
integer | year, | ||
integer | month, | ||
integer | day, | ||
integer | hour, | ||
integer | min, | ||
integer | sec | ||
) |
Shortcut function to set date information.
handle | Handle to a DBALLE session |
year | Year to set in the input record |
month | Month to set in the input |
day | Day to set in the input |
hour | Hour to set in the input |
min | Minute to set in the input |
sec | Second to set in the input |
integer idba_setdatemax | ( | integer | handle, |
integer | year, | ||
integer | month, | ||
integer | day, | ||
integer | hour, | ||
integer | min, | ||
integer | sec | ||
) |
Shortcut function to set maximum date for a query.
handle | Handle to a DBALLE session |
year | Maximum year to set in the query |
month | Maximum month to set in the query |
day | Maximum day to set in the query |
hour | Maximum hour to set in the query |
min | Maximum minute to set in the query |
sec | Maximum second to set in the query |
integer idba_setdatemin | ( | integer | handle, |
integer | year, | ||
integer | month, | ||
integer | day, | ||
integer | hour, | ||
integer | min, | ||
integer | sec | ||
) |
Shortcut function to set minimum date for a query.
handle | Handle to a DBALLE session |
year | Minimum year to set in the query |
month | Minimum month to set in the query |
day | Minimum day to set in the query |
hour | Minimum hour to set in the query |
min | Minimum minute to set in the query |
sec | Minimum second to set in the query |
integer idba_seti | ( | integer | handle, |
character | parameter, | ||
integer | value | ||
) |
Set one integer value into the input record.
handle | Handle to a DBALLE session |
parameter | Parameter to set. It can be the code of a WMO variable prefixed by "B" (such as "B01023" ); the code of a QC value prefixed by "*B" (such as "*B01023" ) or a keyword among the ones defined in dba_record_keywords |
value | The value to assign to the parameter |
integer idba_setlevel | ( | integer | handle, |
integer | ltype1, | ||
integer | l1, | ||
integer | ltype2, | ||
integer | l2 | ||
) |
Shortcut function to set level data.
handle | Handle to a DBALLE session |
ltype | Level type to set in the input record |
l1 | L1 to set in the input record |
l2 | L2 to set in the input record |
integer idba_setr | ( | integer | handle, |
character | parameter, | ||
real | value | ||
) |
Set one real value into the input record.
handle | Handle to a DBALLE session |
parameter | Parameter to set. It can be the code of a WMO variable prefixed by "B" (such as "B01023" ); the code of a QC value prefixed by "*B" (such as "*B01023" ) or a keyword among the ones defined in dba_record_keywords |
value | The value to assign to the parameter |
integer idba_settimerange | ( | integer | handle, |
integer | ptype, | ||
integer | p1, | ||
integer | p2 | ||
) |
Shortcut function to set time range data.
handle | Handle to a DBALLE session |
ptype | P indicator to set in the input record |
p1 | P1 to set in the input record |
p2 | P2 to set in the input record |
integer idba_spiegab | ( | integer | handle, |
character | varcode, | ||
character | value, | ||
character | result | ||
) |
Retrieve QC informations from the last variable returned by idba_dammelo().
handle | Handle to a DBALLE session |
parameter | Contains the ID of the parameter retrieved by this fetch |
integer idba_spiegal | ( | integer | handle, |
integer | ltype1, | ||
integer | l1, | ||
integer | ltype2, | ||
integer | l2, | ||
character | result | ||
) |
Retrieve QC informations from the last variable returned by idba_dammelo().
handle | Handle to a DBALLE session |
parameter | Contains the ID of the parameter retrieved by this fetch |
integer idba_spiegat | ( | integer | handle, |
integer | ptype, | ||
integer | p1, | ||
integer | p2, | ||
character | result | ||
) |
Retrieve QC informations from the last variable returned by idba_dammelo().
handle | Handle to a DBALLE session |
parameter | Contains the ID of the parameter retrieved by this fetch |
integer idba_test_input_to_output | ( | integer | handle | ) |
Retrieve QC informations from the last variable returned by idba_dammelo().
handle | Handle to a DBALLE session |
parameter | Contains the ID of the parameter retrieved by this fetch |
integer idba_unset | ( | integer | handle, |
character | parameter | ||
) |
Remove one parameter from the input record.
handle | Handle to a DBALLE session |
parameter | Parameter to remove. It can be the code of a WMO variable prefixed by "B" (such as "B01023" ); the code of a QC value prefixed by "*B" (such as "*B01023" ) or a keyword among the ones defined in dba_record_keywords |
subroutine idba_unsetall | ( | integer | handle | ) |
Remove all parameters from the input record.
handle | Handle to a DBALLE session |
integer idba_voglioancora | ( | integer | handle, |
integer | count | ||
) |
Retrieve QC informations from the last variable returned by idba_dammelo().
handle | Handle to a DBALLE session |
parameter | Contains the ID of the parameter retrieved by this fetch |
integer idba_voglioquesto | ( | integer | handle, |
integer | count | ||
) |
Submit a query to the database.
The query results can be accessed with calls to idba_dammelo.
handle | Handle to a DBALLE session |
count | Number of values returned by the function |