Cursor is used to fetch single rows from the result set returned by a query.

CREATE PROCEDURE cursor_proc LANGUAGE SQLSCRIPT AS v_isbn VARCHAR(20);                                                                                        CURSOR c_cursor1 (v_isbn VARCHAR(20)) FOR SELECT isbn, title, price, crcy FROM books WHERE isbn = :v_isbn ORDER BY isbn;                                      BEGIN  OPEN c_cursor1('978-3-86894-012-1');                                                                                                                    IF c_cursor1::ISCLOSED THEN CALL ins_msg_proc('WRONG: cursor not open');                                                                                       ELSE CALL ins_msg_proc('OK: cursor open');  END IF;                                                                                                         FETCH c_cursor1 INTO v_isbn, v_title, v_price, v_crcy;                                                                                                       IF c_cursor1::NOTFOUND THEN CALL ins_msg_proc('WRONG: cursor contains no valid data'); ELSE CALL ins_msg_proc('OK: cursor contains valid data');  END IF;   CLOSE c_cursor1;END;

Related questions