Previous Topic: Example1Next Topic: Example 3


Example 2

In this example, the DECLARE CURSOR statement defines the cursor, C1. This cursor could be used in an UPDATE statement to update the column named in the clause, or used in a DELETE statement to delete a row.

 EXEC SQL
      DECLARE C1 CURSOR FOR
           SELECT DEPTNO, DEPTNAME, MGRNO
           FROM DEPTTBL
           WHERE EXISTS
                 (SELECT *
                  FROM DIVTBL
                  WHERE DIVTBL.DEPTNO = DEPTTBL.DEPTNO)
 END-EXEC