X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0B953474E44 for ; Sat, 1 Mar 2003 11:35:51 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 02382-01 for ; Sat, 1 Mar 2003 11:35:47 -0500 (EST) Received: from web20809.mail.yahoo.com (web20809.mail.yahoo.com [216.136.226.198]) by postgresql.org (Postfix) with SMTP id B990B474E42 for ; Sat, 1 Mar 2003 11:35:46 -0500 (EST) Message-ID: <20030301163551.66721.qmail@web20809.mail.yahoo.com> Received: from [68.105.48.176] by web20809.mail.yahoo.com via HTTP; Sat, 01 Mar 2003 08:35:51 PST Date: Sat, 1 Mar 2003 08:35:51 -0800 (PST) From: Jeff Eckermann Subject: Re: Executing SQL commands via triggers without the use of procedures To: Susan Hoddinott , pgsql-sql@postgresql.org In-Reply-To: <001501c2def2$fe2fe9c0$1f84fea9@oemcomputer> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/10 X-Sequence-Number: 12050 --- Susan Hoddinott wrote: > Hello, > > Having scoured the relevant documentation I cannot > find anything which indicates how I simply create a > database trigger to insert into a second table after > insert on a first table, without the use of a > procedure. As I do not want return values etc. this > seems like overkill. Is it possible to create a > trigger which executes SQL directly without the need > to create a procedure? If so, what is the syntax? > You don't need to worry about those return values; nothing will be returned to your application from a trigger function. AFAICT the only difference between PostgreSQL and other DBMSs is that (at least some) others put the procedural logic inside the "create trigger" statement, whereas PostgreSQL puts it in a separate function. You need to think about this only at statement creation time; otherwise everything works just the same. One tip: always use the "create or replace function" syntax, to avoid having your trigger become confused if you change your function definition. __________________________________________________ Do you Yahoo!? Yahoo! Tax Center - forms, calculators, tips, more http://taxes.yahoo.com/