Implicit Cursors

From https://www.tutorialspoint.com/plsql/plsql_cursors.htm.

Created automatically when issuing a SQL statement. The most recent implicit cursor is referred to as the SQL cursor. You can view and manipulate the information associated with a cursor using its attributes:

  • %FOUND - Returns TRUE if an INSERT, UPDATE, or DELETE statement affected one or more rows or a SELECT INTO statement returned one or more rows. Otherwise, it returns FALSE.
  • %NOTFOUND - The logical opposite of %FOUND.
  • %ISOPEN - Always returns FALSE for implicit cursors, because Oracle closes the SQL cursor automatically after executing its associated SQL statement.
  • %ROWCOUNT - Returns the number of rows affected by an INSERT, UPDATE, or DELETE statement, or returned by a SELECT INTO statement.
Examples:
DECLARE
    l_dept_id departments.dept_id%TYPE;
    l_dept_name departments.dept_name%TYPE;
BEGIN
    SELECT dept_id, dept_name
        INTO l_dept_id, l_dept_name
        FROM departments
        WHERE dept_id = 1;

    IF SQL%FOUND THEN
        dbms_output.PUT_LINE(SQL%ROWCOUNT);  -- 1
    END IF;
END;

results matching ""

    No results matching ""