Trigger calling a function HELP ME!

From: <abief_ag_-postgresql(at)yahoo(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Trigger calling a function HELP ME!
Date: 2004-04-21 14:43:12
Message-ID: 20040421144312.83625.qmail@web13909.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi all,

first of all, let me explain what I'm trying to do.

I have a table with a fairly complicated trigger. In this trigger I
have a specific set of codelines that can be executed in more than 50
places that works on the new.* fields in order to fix/clean them.

In order to improve readability, I created a function that manages this
small set of codelines, but I'm stuck on the following error:

---
ERROR: return type mismatch in function returning tuple at or near
"imp_test_to_out_test"
CONTEXT: compile of PL/pgSQL function "imp_test_trigger" near line 2
---

as a model, I've created this run-down example:
---
CREATE TABLE public.imp_test
(
id int8,
value text
) WITHOUT OIDS;

CREATE OR REPLACE FUNCTION public.imp_test_to_out_test(imp_test)
RETURNS imp_test AS
'begin
return new;
end;'
LANGUAGE 'plpgsql' STABLE;

CREATE OR REPLACE FUNCTION public.imp_test_trigger()
RETURNS trigger AS
'begin
return imp_test_to_out_test(new);
end;'
LANGUAGE 'plpgsql' STABLE;

CREATE TRIGGER imp_test_trigger_001
BEFORE INSERT OR UPDATE
ON public.imp_test
FOR EACH ROW
EXECUTE PROCEDURE public.imp_test_trigger();
---
Whenever I run the following select, I get the a.m. result:

---
insert into imp_test
(id, value)
values(1, 'A');
---

Can somebody help me?

regards,

=====
Riccardo G. Facchini

Browse pgsql-sql by date

  From Date Subject
Next Message Edmund Bacon 2004-04-21 14:52:20 Re: Order by YYYY MM DD in reverse chrono order trouble
Previous Message Erik Aronesty 2004-04-21 14:13:25 datediff script