pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: abief_ag_-postgresql@yahoo.com
To: pgsql-sql@postgresql.org
Subject: Trigger calling a function HELP ME!
Date: Wed, 21 Apr 2004 07:43:12 -0700 (PDT)
Message-ID: <20040421144312.83625.qmail@web13909.mail.yahoo.com> (raw)

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



Message-ID: <20040421144312.83625.qmail@web13909.mail.yahoo.com>
Permalink:  ../20040421144312.83625.qmail@web13909.mail.yahoo.com/
Also on:    postgresql.org/message-id/20040421144312.83625.qmail@web13909.mail.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: abief_ag_-postgresql@yahoo.com
  Subject: Re: Trigger calling a function HELP ME!
  In-Reply-To: <20040421144312.83625.qmail@web13909.mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox