Getting result from EXECUTE

From: Robert Fitzpatrick <lists(at)webtent(dot)net>
To: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Getting result from EXECUTE
Date: 2007-09-08 23:18:33
Message-ID: 1189293513.15437.2.camel@columbus.webtent.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a trigger function that I want to apply to several tables, hence
my use of TG_RELNAME. I just want the record to get inserted if an
UPDATE comes from my view rule if the record for the client doesn't
already exist. This is what I have, but I'm finding the FOUND is not
returned for EXECUTE. How can I accomplish what I need?

CREATE OR REPLACE FUNCTION "public"."create_fldclientnumber_trigg_func" () RETURNS trigger AS'
begin
EXECUTE ''SELECT * FROM '' || TG_RELNAME || '' WHERE fldclientnumber = '' || NEW.fldclientnumber;
IF NOT FOUND THEN
EXECUTE ''INSERT INTO '' || TG_RELNAME || '' (fldclientnumber) VALUES ('' || NEW.fldclientnumber || '')'';
END IF;
RETURN NEW;
end;
'LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;

Thanks for the help.

--
Robert

Responses

Browse pgsql-general by date

  From Date Subject
Next Message novnov 2007-09-09 00:58:06 Re: Scalability Design Questions
Previous Message Scott Marlowe 2007-09-08 22:45:48 Re: Scalability Design Questions