'Declaration Public Class PgSqlDependency Implements System.IDisposable |
public class PgSqlDependency : System.IDisposable |
'Declaration Public Class PgSqlDependency Implements System.IDisposable |
public class PgSqlDependency : System.IDisposable |
The PgSqlDependency class is designed to watch for changes in tables on the server. This is accomplished using LISTEN ... NOTIFY server side mechanism and recurring check requests.
To start watching for a table in a schema perform the following steps:
Once you perform these steps the the PgSqlDependency object will poll the server periodically, and if the table is modified since the last call, it will invoke your event handler.
Note that you can use single PgSqlDependency instance to watch for several tables. To do this, specify all necessary tables in the FROM clause of command's SQL statement.
Note also that PgSqlDependency can watch for whole tables only. If you restrict the SELECT statement with WHERE clause, it will not affect notifications.
In PostgreSQL 9.0 and higher, you can also get the infiormation about the table change, that is passed as a second parameter of the NOTIFY command.
This class is not available in Mobile Edition.
CREATE OR REPLACE FUNCTION test.note_dept()
RETURNS TRIGGER AS
BEGIN
PERFORM pg_notify('table_changed_test.dept', TG_OP);
RETURN NULL;
END;
LANGUAGE plpgsql;
CREATE TRIGGER notify_dept AFTER INSERT OR UPDATE OR DELETE
ON test.dept
EXECUTE PROCEDURE test.note_dept();
System.Object
Devart.Data.PostgreSql.PgSqlDependency