If an application connects to a grid node, either by using a grid connection or a direct connection, and then runs an UPDATE or DELETE statement that affects multiple rows then, by default, the results are unpredictable because the statement executes on only one node.
▪ If the application uses a direct connection, the statement executes on the target node of the connection.
▪ If the application uses a grid connection, the statement executes on the node that contains the primary partition of the first row that is affected.
Data that should be affected by the statement but which resides in other nodes is not changed.
Parameters, clauses, keywords, and variables
▪ TRANSACTION: The SET statement affects only the current transaction. When the transaction is complete, the default behavior is restored.
▪ write-options:
– DISTRIBUTED: As long as the application connects to the grid by using a grid connection, the UPDATE or DELETE statement can update or delete all target rows regardless of which grid node contains the primary partition for each row. Unless you also include the TRANSACTION keyword, the distributed-write mode is valid until the connection is closed or the default behavior is restored.
– DEFAULT: Default behavior is restored; the UPDATE or DELETE statement changes target rows on only the current node.
Notes
▪ In the current release, the nodes must be in autocommit mode for the distributed write statement to succeed.
▪ Set the grid write mode back to DEFAULT before executing any SELECT statements. When the grid is in distributed write mode and SELECT statements are executed, the following error is returned:
SOLID Table Error 13607: Grid SQL execute failed, server local, error Fetch operations are not supported.
Examples
In the following scenario, MYTABLE is a table with data that is partitioned across several grid nodes. Run the following SQL statements to delete a subset of rows in the table regardless of the node on which the primary partition for each row is located:
SET GRID WRITE DISTRIBUTED DELETE FROM MYTABLE WHERE ID < 10000 COMMIT WORK; SET GRID WRITE DEFAULT;