Cursor (databases) - Positioned Update/delete Statements

Positioned Update/delete Statements

Cursors can not only be used to fetch data from the DBMS into an application but also to identify a row in a table to be updated or deleted. The SQL:2003 standard defines positioned update and positioned delete SQL statements for that purpose. Such statements do not use a regular WHERE clause with predicates. Instead, a cursor identifies the row. The cursor must be opened and already positioned on a row by means of FETCH statement.

UPDATE table_name SET ... WHERE CURRENT OF cursor_name DELETE FROM table_name WHERE CURRENT OF cursor_name

The cursor must operate on an updatable result set in order to successfully execute a positioned update or delete statement. Otherwise, the DBMS would not know how to apply the data changes to the underlying tables referred to in the cursor.

Read more about this topic:  Cursor (databases)

Famous quotes containing the words delete and/or statements:

    Generalization, especially risky generalization, is one of the chief methods by which knowledge proceeds... Safe generalizations are usually rather boring. Delete that “usually rather.” Safe generalizations are quite boring.
    Joseph Epstein (b. 1937)

    Nonwhite and working-class women, if they are ever to identify with the organized women’s movement, must see their own diverse experiences reflected in the practice and policy statements of these predominantly white middle-class groups.
    Kimberly Crenshaw (b. 1959)