From: Alex Pilosov <alex@pilosoft.com>
To: Larry Rosenman <ler@lerctr.org>
Cc: PostgreSQL SQL List <pgsql-sql@postgresql.org>
Subject: Re: Why doesn't this pgsql function compile?
Date: Fri, 15 Jun 2001 18:27:03 -0400 (EDT)
Message-ID: <Pine.BSO.4.10.10106151826220.17529-100000@spider.pilosoft.com> (raw)
In-Reply-To: <20010615170950.A3303@lerami.lerctr.org>
On Fri, 15 Jun 2001, Larry Rosenman wrote:
<snip>
you are missing an endif:
> DROP TRIGGER netblock_bgp ON networks;
> DROP FUNCTION networks_trigger_router();
> CREATE FUNCTION networks_trigger_router()
> RETURNS opaque
> AS 'BEGIN
> IF TG_OP = ''DELETE'' AND OLD.router ISNULL
> THEN return OLD;
> END IF;
> IF TG_OP = ''INSERT'' AND NEW.router ISNULL
> THEN return NEW;
> END IF;
> IF TG_OP = ''INSERT'' AND get_router_nexthop(NEW.router) ISNULL
> THEN return NEW;
> END IF;
> IF TG_OP = ''DELETE'' AND get_router_nexthop(OLD.router) ISNULL
> THEN return OLD;
> END IF;
> IF TG_OP = ''INSERT''
> THEN add_ip_route(host(network(NEW.netblock)),
> host(netmask(NEW.netblock)),
> get_router_ethernet(NEW.router),
> get_router_nexthop(NEW.router),
> get_router_nexthop_user(NEW.router),
> get_router_nexthop_password(NEW.router),
> get_router_nexthop_enpass(NEW,router));
> return NEW;
> END IF;
> IF TG_OP = ''DELETE''
> THEN del_ip_route(host(network(OLD.netblock)),
> host(netmask(OLD.netblock)),
> get_router_ethernet(OLD.router),
> get_router_nexthop(OLD.router),
> get_router_nexthop_user(OLD.router),
> get_router_nexthop_password(OLD.router),
> get_router_nexthop_enpass(OLD,router));
> return OLD;
^^^^^^^^^^^^^^^^
END IF;
> -- TG_OP must be UPDATE to get here....
> IF OLD.router NOTNULL and get_router_nexthop(OLD.router) NOTNULL
> AND NEW.router NOTNULL and OLD.router != NEW.router
> THEN del_ip_route(host(network(OLD.netblock)),
> host(netmask(OLD.netblock)),
> get_router_ethernet(OLD.router),
> get_router_nexthop(OLD.router),
> get_router_nexthop_user(OLD.router),
> get_router_nexthop_password(OLD.router),
> get_router_nexthop_enpass(OLD,router));
> END IF;
> IF NEW.router NOTNULL and get_router_nexthop(NEW.router) NOTNULL
> THEN add_ip_route(host(network(NEW.netblock)),
> host(netmask(NEW.netblock)),
> get_router_ethernet(NEW.router),
> get_router_nexthop(NEW.router),
> get_router_nexthop_user(NEW.router),
> get_router_nexthop_password(NEW.router),
> get_router_nexthop_enpass(NEW,router));
> END IF;
> return NEW;
> END;'
> LANGUAGE 'plpgsql';
> CREATE TRIGGER netblock_bgp
> BEFORE UPDATE OR INSERT OR DELETE
> ON networks
> FOR EACH ROW
> EXECUTE PROCEDURE networks_trigger_router();
>
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: alex@pilosoft.com, ler@lerctr.org
Subject: Re: Why doesn't this pgsql function compile?
In-Reply-To: <Pine.BSO.4.10.10106151826220.17529-100000@spider.pilosoft.com>
References: <20010615170950.A3303@lerami.lerctr.org> <Pine.BSO.4.10.10106151826220.17529-100000@spider.pilosoft.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox