[evolvis-commits] r8107: How to get id of constraint triggers↵
mirabilos at evolvis.org
mirabilos at evolvis.org
Thu Feb 24 15:57:21 CET 2011
Author: mirabilos
Date: 2011-02-24 15:57:21 +0100 (Thu, 24 Feb 2011)
New Revision: 8107
Added:
trunk/gforge_base/evolvisforge-5.1/tools/list_const_triggers.sql
Log:
How to get id of constraint triggers
Added: trunk/gforge_base/evolvisforge-5.1/tools/list_const_triggers.sql
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/tools/list_const_triggers.sql (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/tools/list_const_triggers.sql 2011-02-24 14:57:21 UTC (rev 8107)
@@ -0,0 +1,35 @@
+-- ---- Here is a function that I use to list fk(triggers) on a table. Execute the
+-- ---- function to get the trigger name and then - drop trigger "trigger_name" on
+-- ---- table_name;
+-- -- Version 1.0, June 2002
+-- -- Marie G. Tuite
+-- -- Function lists FK by table.
+-- -- To execute:
+-- -- begin;select fn_list_fk('table_name');
+-- -- fetch all from "<cursor_name>"; end;
+-- create or replace function fn_list_fk(name)
+-- returns refcursor as
+-- '
+-- declare
+-- table_in alias for $1;
+-- rc refcursor;
+-- begin
+-- open rc for
+-- select tgname as trigger_name_sys
+-- ,tgconstrname as trigger_name_given
+-- ,b.relname as table_name
+-- ,tgisconstraint as ri
+-- ,c.relname as parent_table
+-- from pg_trigger a,
+-- pg_class b,
+-- pg_class c
+-- where a.tgrelid=b.oid and b.relname=table_in
+-- and tgconstrrelid = c.oid;
+-- return rc;
+-- end;
+-- '
+-- language 'plpgsql'
+-- ;
+-- select tgname as trigger_name_sys, tgconstrname as trigger_name_given, b.relname as table_name ,tgisconstraint as ri ,c.relname as parent_table from pg_trigger a, pg_class b, pg_class c where a.tgrelid=b.oid and b.relname=table_in and tgconstrrelid = c.oid;
+-- For project_task table
+select tgname as trigger_name_sys, tgconstrname as trigger_name_given, b.relname as table_name ,tgisconstraint as ri ,c.relname as parent_table from pg_trigger a, pg_class b, pg_class c where a.tgrelid=b.oid and b.relname='project_task' and tgconstrrelid = c.oid;
More information about the evolvis-commits
mailing list