Re: Executing SQL commands via triggers without the use of procedures

From: Jeff Eckermann <jeff_eckermann(at)yahoo(dot)com>
To: Susan Hoddinott <susan(at)perth(dot)dialix(dot)com(dot)au>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Executing SQL commands via triggers without the use of procedures
Date: 2003-03-01 16:35:51
Message-ID: 20030301163551.66721.qmail@web20809.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

--- Susan Hoddinott <susan(at)perth(dot)dialix(dot)com(dot)au> 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/

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Rod Taylor 2003-03-01 17:07:04 Re: Denormalizing during select
Previous Message Denis Arh 2003-03-01 14:53:10 Epoch extraction