HDFql Reference Manual v2.6.0

5.2.24hdfql_cursor_previous

Syntax

int hdfql_cursor_previous(HDFQL_CURSOR *cursor)

Description

Move a cursor named cursor one position backward from its current position. In other words, the cursor will point to the previous element of the result set, and its position is decremented by one. If the result set is empty or the cursor is in the first position, an error is returned, and its position remains unchanged (i.e. remains minus one) or is set to minus one, respectively.

Parameter(s)

cursor – pointer to a cursor to move one position backward from its current position. If the pointer is NULL (in C), the cursor in use is moved one position backward from its current position instead. The equivalent of a NULL pointer in C++, Java, Python, C#, Fortran, R, and MATLAB HDFql wrappers is NULL, null, None, null, NULL(), NULL, and NaN, respectively. While in C cursor is mandatory, in C++, Java, Python, C#, Fortran, R, and MATLAB it is optional (when not specified, the cursor in use is moved one position backward from its current position instead).

Return

int – depending on the success in moving the cursor one position backward from its current position, it can be HDFQL_SUCCESS, HDFQL_ERROR_EMPTY, or HDFQL_ERROR_BEFORE_FIRST.

Example(s)

// create an HDF5 dataset named "my_dataset" of data type float of two dimensions (size 2x10)
hdfql_execute("CREATE DATASET my_dataset AS FLOAT(2, 10)");

// select (i.e. read) data from dataset "my_dataset" and populate cursor in use with it 
hdfql_execute("SELECT FROM my_dataset");

// move the cursor in use to the last position within the result set 
hdfql_cursor_last(NULL);

// move the cursor in use to the previous position within the result set 
hdfql_cursor_previous(NULL);

// display position of cursor in use within the result set (should be "Position of cursor is 18")
printf("Position of cursor is %lld\n", hdfql_cursor_get_position(NULL));