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)

    We assume that politicians are without honor. We read their statements trying to crack the code. The scandals of their politics: not so much that men in high places lie, only that they do so with such indifference, so endlessly, still expecting to be believed. We are accustomed to the contempt inherent in the political lie.
    Adrienne Rich (b. 1929)