Search Postgresql Archives

Getting result from EXECUTE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux