Cursor represents result set & is used to manipulate data row by row - Database

Q.  What type of database object represents a result set and is used to manipulate data row by row?
- Published on 27 Aug 15

a. Trigger
b. Procedure
c. Cursor
d. Monitor

ANSWER: Cursor
 

    Discussion

  • Nirja Shah   -Posted on 02 Nov 15
    Cursors
    - As mentioned previously, you access the data in a ResultSet object through a cursor, which points to one row in the ResultSet object.

    - However, when a ResultSet object is first created, the cursor is positioned before the first row.

    - The method CoffeeTables.viewTable moves the cursor by calling the ResultSet.next method.

    - There are other methods available to move the cursor:

    1. next: Moves the cursor forward one row. Returns true if the cursor is now positioned on a row and false if the cursor is positioned after the last row.

    2. previous: Moves the cursor backward one row. Returns true if the cursor is now positioned on a row and false if the cursor is positioned before the first row.

    3. first: Moves the cursor to the first row in the ResultSet object. Returns true if the cursor is now positioned on the first row and false if the ResultSet object does not contain any rows.

    4. last: Moves the cursor to the last row in the ResultSet object. Returns true if the cursor is now positioned on the last row and false if the ResultSet object does not contain any rows.

    5. beforeFirst: Positions the cursor at the start of the ResultSet object, before the first row. If the ResultSet object does not contain any rows, this method has no effect.

    6. afterLast: Positions the cursor at the end of the ResultSet object, after the last row. If the ResultSet object does not contain any rows, this method has no effect.

    7. relative(int rows): Moves the cursor relative to its current position.

    8. absolute(int row): Positions the cursor on the row specified by the parameter row.

    - The default sensitivity of a ResultSet is TYPE_FORWARD_ONLY, which means that it cannot be scrolled; you cannot call any of these methods that move the cursor, except next, if your ResultSet cannot be scrolled.

Post your comment / Share knowledge


Enter the code shown above:
 
(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)