HDFql Reference Manual v2.6.0

5.2.18hdfql_cursor_first

Syntax

int hdfql_cursor_first(HDFQL_CURSOR *cursor)

Description

Move a cursor named cursor to the first position within the result set. In other words, the cursor will point to the first element of the result set, and its position is set to zero. If the result set is empty, an error is returned, and its position remains unchanged (i.e. remains minus one).

Parameter(s)

cursor – pointer to a cursor to move to the first position within the result set. If the pointer is NULL (in C), the cursor in use is moved to the first 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 to the first position instead).

Return

int – depending on the success in moving the cursor to the first position within the result set, it can either be HDFQL_SUCCESS or HDFQL_ERROR_EMPTY.

Example(s)

// show (i.e. get) working directory currently in use 
hdfql_execute("SHOW USE DIRECTORY");

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

// move the cursor in use to the first position within the result set 
hdfql_cursor_first(NULL);

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