Fetching and updating cursors
Since Row 4, (2002040, Sam, Burke) was fetched after “Sam” was updated to “Joe,” the returned employee ID 2002040 is Joe, Burke.
The third and fourth rows are now copied to the worktable. “Row position” is an imaginary column, in which the values represent the position of each row in the result set.
option specifies that the cursor should return data in binary format.
This reduces conversion effort for both the server and client, at the cost of more programmer effort to deal with platform-dependent binary data formats.
If we process it at once, we may have a memory overflow error.
In addition, we can develop a function that returns a reference to a cursor.
As an example, if a query returns a value of one from an integer column, you would get a string of with a default cursor, whereas with a binary cursor you would get a 4-byte field containing the internal representation of the value (in big-endian byte order). Many applications, including command, the Bind protocol message specifies whether data is to be retrieved in text or binary format.
This choice overrides the way that the cursor is defined.
A searched update modifies multiple rows when the search condition does not uniquely identify a single row.
A PL/pg SQL cursor allows us to encapsulate a query and process each individual row at a time.