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





---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to [EMAIL PROTECTED] so that your
      message can get through to the mailing list cleanly

Reply via email to