# 5.2.22 hdfql_cursor_next

Part of: [5 Application Programming Interface](5-application-programming-interface.md) › [5.2 Functions](5-2-functions.md)

### Syntax

int hdfql_cursor_next(HDFQL_CURSOR \*_cursor_)

### Description

Move a cursor named _cursor_ one position forward from its current position. In other words, the cursor will point to the next element of the result set, and its position is incremented by one. If the result set is empty or the cursor is in the last position, an error is returned, and its position remains unchanged (i.e. remains minus one) or is set to the value returned by [hdfql_cursor_get_count](5-2-12-hdfql-cursor-get-count.md), respectively.

### Parameter(s)

_cursor_ – pointer to a cursor to move one position forward from its current position. If the pointer is NULL (in C), the cursor in use is moved one position forward 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 forward from its current position instead).

### Return

int – depending on the success in moving the cursor one position forward from its current position, it can be [HDFQL_SUCCESS](5-1-constants.md#hdfql_success), [HDFQL_ERROR_EMPTY](5-1-constants.md#hdfql_error_empty), or [HDFQL_ERROR_AFTER_LAST](5-1-constants.md#hdfql_error_after_last).

### Example(s)

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

// move the cursor in use to the next position within the result set 
hdfql_cursor_next(NULL);

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