dm_db_select_observs Interface

public interface dm_db_select_observs

Generic observations select function.


Module Procedures

private function db_select_observs_array(db, observs, node_id, sensor_id, target_id, from, to, desc, limit, stub, nobservs) result(rc)

Returns observations in observs, with optional node id, sensor id, target id, from, to. By default, observations are returned in ascending order, unless desc is passed and .true.. The maximum number of observations may be passed in limit.

The stub is .true., neither receivers nor requests are read from database.

The total number of observations is returned in optional argument nobservs.

Calling this function is usually slower than db_select_observs_by_id() or db_select_observs_by_time().

The function returns the following error codes:

  • E_ALLOC if memory allocation failed.
  • E_DB_BIND if value binding failed.
  • E_DB_FINALIZE if statement finalisation failed.
  • E_DB_NO_ROWS if no rows are returned.
  • E_DB_PREPARE if statement preparation failed.
  • E_DB_TYPE if returned columns are unexpected.

Arguments

Type IntentOptional Attributes Name
type(db_type), intent(inout) :: db

Database type.

type(observ_type), intent(out), allocatable :: observs(:)

Returned observation data.

character(len=*), intent(in), optional :: node_id

Node id.

character(len=*), intent(in), optional :: sensor_id

Sensor id.

character(len=*), intent(in), optional :: target_id

Target id.

character(len=*), intent(in), optional :: from

Beginning of time span.

character(len=*), intent(in), optional :: to

End of time span.

logical, intent(in), optional :: desc

Descending order.

integer(kind=i8), intent(in), optional :: limit

Max. number of observations.

logical, intent(in), optional :: stub

Without receivers, requests, responses.

integer(kind=i8), intent(out), optional :: nobservs

Total number of observations (may be greater than limit).

Return Value integer

private function db_select_observs_iter(db, db_stmt, observ, node_id, sensor_id, target_id, from, to, desc, limit, stub) result(rc)

Iterator function that returns observations in observ, with optional node id, sensor id, target id, from, to. By default, observations are returned in ascending order, unless desc is passed and .true.. The maximum number of observations may be passed in limit. The statement db_stmt must be finalised once finished.

The stub is .true., neither receivers nor requests are read from database.

The function returns the following error codes:

  • E_DB_BIND if value binding failed.
  • E_DB_NO_ROWS if no rows are returned.
  • E_DB_PREPARE if statement preparation failed.
  • E_DB_TYPE if returned columns are unexpected.

Arguments

Type IntentOptional Attributes Name
type(db_type), intent(inout) :: db

Database type.

type(db_stmt_type), intent(inout) :: db_stmt

Database statement type.

type(observ_type), intent(out) :: observ

Returned observation type.

character(len=*), intent(in), optional :: node_id

Node id.

character(len=*), intent(in), optional :: sensor_id

Sensor id.

character(len=*), intent(in), optional :: target_id

Target id.

character(len=*), intent(in), optional :: from

Beginning of time span.

character(len=*), intent(in), optional :: to

End of time span.

logical, intent(in), optional :: desc

Descending order.

integer(kind=i8), intent(in), optional :: limit

Max. number of observations.

logical, intent(in), optional :: stub

Without receivers, requests, responses.

Return Value integer