dm_db_select_data_points Interface

public interface dm_db_select_data_points

Generic data points select function.


Module Procedures

private function db_select_data_points_array(db, dps, node_id, sensor_id, target_id, response_name, from, to, error, limit, npoints) result(rc)

Returns data points from observations database in dps. This function selects only responses of error E_NONE, unless argument error is passed, then only of the given error code.

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(dp_type), intent(out), allocatable :: dps(:)

Returned data points.

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

Node id.

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

Sensor id.

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

Target id.

character(len=*), intent(in) :: response_name

Response name.

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

Beginning of time span.

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

End of time span.

integer, intent(in), optional :: error

Response error code.

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

Max. number of data points.

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

Number of data points.

Return Value integer

private function db_select_data_points_iter(db, db_stmt, dp, node_id, sensor_id, target_id, response_name, from, to, error, limit) result(rc)

Iterator function that returns data points from observations database in dp. This function selects only responses of error E_NONE, unless argument error is passed, then only of the given error code. The statement db_stmt must be finalised once finished.

The function returns the following error codes:

  • E_DB_BIND if value binding failed.
  • E_DB_NO_ROWS if no more rows are available.
  • 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(dp_type), intent(out) :: dp

Returned data point.

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

Node id.

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

Sensor id.

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

Target id.

character(len=*), intent(in) :: response_name

Response name.

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

Beginning of time span.

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

End of time span.

integer, intent(in), optional :: error

Response error code.

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

Max. number of data points.

Return Value integer