From: | Niklas Johansson <spot(at)tele2(dot)se> |
---|---|
To: | "Ключников А(dot)С(dot)" <alexs(at)analytic(dot)mv(dot)ru> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Trigger vs Rule |
Date: | 2006-04-03 09:04:25 |
Message-ID: | 5DEF8AEF-9FBD-4C6E-88BD-FA90CB1BDF31@tele2.se |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On 2 apr 2006, at 23.08, Niklas Johansson wrote:
> CREATE OR REPLACE FUNCTION exec_device_type() RETURNS trigger AS $$
> EXECUTE "SELECT device_type" || OLD.type || "(OLD.id)";
> $$ LANGUAGE plpgsql;
Sorry, I was bitten by the bedbug there: a plpgsql function needs a
little more than that to be functional :)
CREATE OR REPLACE FUNCTION exec_device_type() RETURNS trigger AS $$
BEGIN
EXECUTE 'SELECT device_type' || OLD.type || '(OLD.id)';
RETURN NEW/OLD/NULL; -- Depending on your application.
END;
$$ LANGUAGE plpgsql;
But really, you should consider reworking your schema structure.
Having a thousand functions doing almost the same thing is neither
efficient, nor maintainable.
Sincerely,
Niklas Johansson
From | Date | Subject | |
---|---|---|---|
Next Message | Ключников А.С. | 2006-04-03 09:17:36 | Re: Trigger vs Rule |
Previous Message | Brendan Duddridge | 2006-04-03 04:20:00 | Re: Query using SeqScan instead of IndexScan |