Difference between revisions of "Public.setsnmpinterfacekeysoninsert (trigger function)"
Line 1: | Line 1: | ||
== wikibot == | == wikibot == | ||
+ | |||
+ | {| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | ||
+ | |- | ||
+ | | '''Trigger Function | ||
+ | | public.setsnmpinterfacekeysoninsert | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | |||
+ | === Source === | ||
+ | <pre> | ||
CREATE OR REPLACE FUNCTION public.setsnmpinterfacekeysoninsert() | CREATE OR REPLACE FUNCTION public.setsnmpinterfacekeysoninsert() | ||
RETURNS trigger | RETURNS trigger | ||
Line 47: | Line 58: | ||
END; | END; | ||
$function$ | $function$ | ||
+ | </pre> | ||
+ | |||
+ | === References === | ||
+ | {| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | ||
+ | |- style="background:silver" | ||
+ | | '''Dependency Type | ||
+ | | '''Object Type | ||
+ | | '''Referenced Object | ||
+ | |||
|- | |- | ||
| Select | | Select | ||
| Table | | Table | ||
| [[public.snmpinterface_(table)|public.snmpinterface]] | | [[public.snmpinterface_(table)|public.snmpinterface]] | ||
+ | |||
+ | |} |
Revision as of 08:39, 11 February 2010
wikibot
Trigger Function | public.setsnmpinterfacekeysoninsert |
Source
CREATE OR REPLACE FUNCTION public.setsnmpinterfacekeysoninsert() RETURNS trigger LANGUAGE plpgsql AS $function$ BEGIN -- -- (Used for Trigger insert with old style foreign key) -- This condition keeps the snmpInterfaceId inSync with the composite foreign key of nodeid, ipaddr, ifindex -- This usually happens when a new record is written by our JDBC code (non-Hibernate DAO) for the old JDBC style -- code has no knowledge of the new keys -- IF NEW.snmpInterfaceId IS NULL THEN IF NEW.ifIndex IS NOT NULL THEN SELECT snmpif.id INTO NEW.snmpInterfaceId FROM snmpinterface snmpif WHERE (snmpif.nodeid = NEW.nodeid AND snmpif.snmpIfIndex = NEW.ifIndex); IF NOT FOUND THEN RAISE EXCEPTION 'IpInterface Trigger Notice, Condition 1: No SnmpInterface found for... nodeid: % ifindex: %', NEW.nodeid, NEW.ifIndex; END IF; END IF; -- -- (Used for Insert with new style foreign key) -- This condition keeps the composite foreign key of nodeid, ipaddr, ifindex inSync with the SnmpInterfaceId -- This usually happens when a new record is written by our Hibernate DAOs... these DAOs have no knowledge of -- the composite key columns -- ELSIF NEW.snmpInterfaceId IS NOT NULL AND (NEW.nodeId IS NULL OR NEW.ifIndex IS NULL) THEN SELECT snmpif.nodeid, snmpif.snmpIfIndex INTO NEW.nodeid, NEW.ifIndex FROM snmpinterface snmpif WHERE (snmpif.id = NEW.snmpInterfaceId); IF NOT FOUND THEN RAISE EXCEPTION 'IpInterface Trigger Notice: No SnmpInterface found for snmpInterfaceId: %', NEW.snmpInterfaceId; END IF; END IF; RETURN NEW; END; $function$
References
Dependency Type | Object Type | Referenced Object |
Select | Table | public.snmpinterface |