You must Sign In to post a response.
  • Category: SQL Server

    How to use serial cursor and scrollable cursor in SQL SERVER...?

    Hi SW Engineers,
    please Any one can help me..how to use serial cursor and scrollable cursor on record set in sql...
  • #652546
    Static Cursor: A Database Cursor is called a Static Cursor if it captures the snapshot of data only at the time when the ResultSet (or Recordset in case of MS SQL Server) is created with no further DB interaction afterwards. And hence a Static Cursor will be unaware of any data changes made into the database after the ResultSet has been created. A Static Cursor facilitates scrolling through the static ResultSet and it supports both absolute and relative positioning. Reason being, the ResultSet is static and hence the cursor can always be sure of the position of all the records/rows. Relative positioning can be specified in terms of offsets from the current, top or bottom rows.

    Scrollable Cursor
    Programmers may declare cursor as scrollable or not scrollable. The scrollablity indicates the direction in which a cursor can move. With a non scrollable cursor, also known as forward only can fetch each row at most one.

    A programmer may position a scrollable cursor anywhere in the result set using the fetch SQL statement. The keyword scroll must be specified when declaring the cursor. The default is non-scroll cursor.

    Syntax for declaring scrollable cursor
    declare cursor_name senstivity scroll cursor for select .... from ...

    Example which demonstrate the use of Scrollable cursor
    declare cur_std scroll cursor for select * from student --Declare a cursor named cur_std


    open cur_std


    fetch next from cur_std
    fetch absolute 3 from cur_std


    fetch prior from cur_std


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.