# Get Scroll Insensitive Cursor command

#### Syntax

    GET SCROLL INSENSITIVE [WITH {HOLD|NOHOLD}]
       CURSOR Identifier AS
       String

WITH HOLD is the default attribute of the cursor. For a non-holdable cursor, use the WITH NOHOLD option.

#### Description

Creates a scrollable insensitive cursor with the name of the Identifier. It does this by issuing a createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY) call and then executing the statement with a java.sql.StatementExecuteQuery request on the value of the String.

If the String is a statement that does not generate a result set, the behavior of the underlying database determines whether an empty result set or an error is issued. If there is an error in executing the statement, no cursor is created.

`ij` sets the cursor name using a java.sql.Statement.setCursorName request. Behavior with respect to duplicate cursor names is controlled by the underlying database. Derby does not allow multiple open cursors with the same name.

Once a scrollable cursor has been created, you can use the following commands to work with the result set:

- Absolute command
- After Last command
- Before First command
- Close command
- First command
- Last command
- Next command
- Previous command
- Relative command

#### Examples

    ij> autocommit off;
    ij> get scroll insensitive cursor scrollCursor as
        'SELECT * FROM menu';
    ij> absolute 5 scrollCursor;
    COURSE    |ITEM                |PRICE
    -----------------------------------------------
    entree    |lamb chop           |14
    ij> after last scrollcursor;
    No current row
    ij> before first scrollcursor;
    No current row
    ij> first scrollcursor;
    COURSE    |ITEM                |PRICE
    -----------------------------------------------
    entree    |lamb chop           |14
    ij> last scrollcursor;
    COURSE    |ITEM                |PRICE
    -----------------------------------------------
    dessert   |creme brulee        |6
    ij> previous scrollcursor;
    COURSE    |ITEM                |PRICE
    -----------------------------------------------
    entree    |lamb chop           |14
    ij> relative 1 scrollcursor;
    COURSE    |ITEM                |PRICE
    -----------------------------------------------
    dessert   |creme brulee        |6
    ij>>previous scrollcursor;
    COURSE    |ITEM                |PRICE
    -----------------------------------------------
    dessert   |creme brulee        |6
    ij> next scrollcursor;
    COURSE    |ITEM                |PRICE
    -----------------------------------------------
    dessert   |creme brulee        |6

    ij> connect 'jdbc:derby:memory:dummy;create=true;user=john'
        as john_conn;
    ij> create table john_tbl(c int);
    0 rows inserted/updated/deleted
    ij> insert into john_tbl values(1),(2),(3);
    3 rows inserted/updated/deleted
    ij> connect 'jdbc:derby:memory:dummy;user=fred' as fred_conn;
    ij(FRED_CONN)> get scroll insensitive cursor john_cursor@john_conn
        as 'select * from john_tbl';
    ij(FRED_CONN)> next john_cursor@john_conn;
    C
    -----------
    1
    ij(FRED_CONN)> getcurrentrownumber john_cursor@john_conn;
    1
    ij(FRED_CONN)> last john_cursor@john_conn;
    C
    -----------
    3
    ij(FRED_CONN)> previous john_cursor@john_conn;
    C
    -----------
    2
    ij(FRED_CONN)> first john_cursor@john_conn;
    C
    -----------
    1
    ij(FRED_CONN)> after last john_cursor@john_conn;
    No current row
    ij(FRED_CONN)> before first john_cursor@john_conn;
    No current row
    ij(FRED_CONN)> relative 2 john_cursor@john_conn;
    C
    -----------
    2
    ij(FRED_CONN)> absolute 1 john_cursor@john_conn;
    C
    -----------
    1
    ij(FRED_CONN)> close john_cursor@john_conn;
    ij(FRED_CONN)> disconnect all;
    ij>

Parent topic: ij commands and errors reference
Related concepts
ij commands
ij errors
Related reference
Absolute command
After Last command
Async command
Autocommit command
Before First command
Close command
Commit command
Connect command
Describe command
Disconnect command
Driver command
Elapsedtime command
Execute command
Exit command
First command
Get Cursor command
Help command
Last command
LocalizedDisplay command
MaximumDisplayWidth command
Next command
Prepare command
Previous command
Protocol command
Readonly command
Relative command
Remove command
Rollback command
Run command
Set Connection command
Show command
Wait For command
Syntax for comments in ij commands
Syntax for identifiers in ij commands
Syntax for strings in ij commands