Re: Function xxxx() does no exist

From: wieck(at)debis(dot)com (Jan Wieck)
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Philippe Lefvre <ph(dot)l(at)libertysurf(dot)fr>, pgsql-sql(at)postgreSQL(dot)org
Subject: Re: Function xxxx() does no exist
Date: 2000-04-14 06:44:50
Message-ID: m12fzqU-0003knC@orion.SAPserv.Hamburg.dsh.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> Philippe =?iso-8859-1?Q?Lef=E8vre?= <ph(dot)l(at)libertysurf(dot)fr> writes:
> > So I created:
> > CREATE FUNCTION chk_itheme_proc(int4) RETURNS int4
> > AS 'SELECT COUNT(i_theme) FROM tbl_theme
> > WHERE i_theme = $1;'
> > LANGUAGE 'sql';
>
> > and I created a trigger:
> > CREATE TRIGGER chk_itheme_trig BEFORE INSERT OR UPDATE ON tbl_article
> > FOR EACH ROW EXECUTE PROCEDURE chk_itheme_proc ('theme');
>
> > but I get the message:
> > ERROR: CreateTrigger: function chk_itheme_proc() does not exist
>
> Poorly worded error message, I'd say. You have a function
> chk_itheme_proc(int4), but the trigger as you show it requires a
> function with a signature of chk_itheme_proc(text) or something close
> to it. Those are different functions.
>
> The error message ought to print out the expected parameter types to
> remind you about that...

No,

trigger procedures in Postgres are allways defined to take no
arguments and have a return type "opaque".

The main error above is, that the "sql" language cannot be
used to define a trigger!

Use the PL/pgSQL or PL/Tcl languages instead. They're
documented in the programmers manual. Version 7.0 will have
PL/Perl too, but I don't know if that one can be used for
trigger procs yet.

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#========================================= wieck(at)debis(dot)com (Jan Wieck) #

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Julie Hunt 2000-04-14 06:51:04 Functions and tablenames
Previous Message Patrik Kudo 2000-04-14 05:54:51 Re: sum a subquery?