Propagating updates to data

You can change your data through a grid routine and propagate the changes to all the servers in the grid.

About this task

You can propagate updates to data on servers in the grid. By default, changes to data that are propagated through the grid are treated the same as changes to data that are made by Enterprise Replication apply threads: they are not replicated again. For example, if you propagate a DELETE statement through the grid to remove old data, you would not want the resulting deleted rows to be replicated as well. Although you can use the grid to run a DML statement, in general, use Enterprise Replication to replicate changes to replicated data.

The grid must exist and you must run the grid routines as an authorized user from an authorized server.

Procedure

To propagate an SQL statement or a stored procedure that updates data, run the ifx_grid_execute() procedure with the DML statements or the stored procedure as the second argument.

Examples

Example 1: Reduce the price of products with low sales

In the following example, the ifx_grid_execute() procedure runs SQL statements that reduce the price of wool overcoats in stores that did not sell an overcoat in the last week:

EXECUTE PROCEDURE ifx_grid_execute('grid1',
		'UPDATE price_table SET price = price * 0.75 
			WHERE item = 
			(SELECT item FROM inventory i, sales s
			  WHERE i.description = "Wool Overcoat"
			     AND  i.item = s.item
			     AND  s.recent_sale_date <
				extend (current ; Interval(7) DAY))');

Example 2: Purge old data

The following example purges all sales records before 2010:
Database retail_db;
	EXECUTE PROCEDURE ifx_grid_execute('grid1',
				'DELETE FROM sales WHERE sales_year < 2010');

Example 3: Run a low inventory report

The following example runs an existing stored procedure named low_inventory():

EXECUTE PROCEDURE ifx_grid_procedure('grid1', 'low_inventory()');