pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Executing SQL commands via triggers without the use of procedures
5+ messages / 5 participants
[nested] [flat]

* Executing SQL commands via triggers without the use of procedures
@ 2003-02-28 06:31  Susan Hoddinott <susan@perth.dialix.com.au>
  0 siblings, 4 replies; 5+ messages in thread

From: Susan Hoddinott @ 2003-02-28 06:31 UTC (permalink / raw)
  To: pgsql-sql

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?

Regards

Attachments:

  Susan Hoddinott.vcf (application/octet-stream, 170B) download

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Executing SQL commands via triggers without the use of
@ 2003-03-01 02:00  Stephan Szabo <sszabo@megazone23.bigpanda.com>
  parent: Susan Hoddinott <susan@perth.dialix.com.au>
  3 siblings, 0 replies; 5+ messages in thread

From: Stephan Szabo @ 2003-03-01 02:00 UTC (permalink / raw)
  To: Susan Hoddinott <susan@perth.dialix.com.au>; +Cc: pgsql-sql

On Fri, 28 Feb 2003, Susan Hoddinott wrote:

> 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?

Not really... You'll need to wrap it in a simple function.





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Executing SQL commands via triggers without the use of procedures
@ 2003-03-01 16:35  Jeff Eckermann <jeff_eckermann@yahoo.com>
  parent: Susan Hoddinott <susan@perth.dialix.com.au>
  3 siblings, 0 replies; 5+ messages in thread

From: Jeff Eckermann @ 2003-03-01 16:35 UTC (permalink / raw)
  To: Susan Hoddinott <susan@perth.dialix.com.au>; pgsql-sql

--- Susan Hoddinott <susan@perth.dialix.com.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/



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Executing SQL commands via triggers without the use of procedures
@ 2003-03-03 13:22  Oleg Samoylov <olleg@telecom.mipt.ru>
  parent: Susan Hoddinott <susan@perth.dialix.com.au>
  3 siblings, 0 replies; 5+ messages in thread

From: Oleg Samoylov @ 2003-03-03 13:22 UTC (permalink / raw)
  To: pgsql-sql

You can use rules for this purpose.
-- 
Olleg Samoylov




^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Executing SQL commands via triggers without the use of procedures
@ 2003-03-26 23:04  fabio <penguin@email.it>
  parent: Susan Hoddinott <susan@perth.dialix.com.au>
  3 siblings, 0 replies; 5+ messages in thread

From: fabio @ 2003-03-26 23:04 UTC (permalink / raw)
  To: pgsql-sql


> 
> Having scoured the relevant documentation I cannot find anything which indi=
> cates 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 creat=
> e a trigger which executes SQL directly without the need to create a proced=
> ure?  If so, what is the syntax?
> 

hello! I had the same problem, is possible to solve it with a rules but
depend. In my db i used a trigger because,i have multiple insert in
cascade and the rules dont handle this 

manual for trigger procedure:
http://www.postgresql.org/docs/view.php?version=7.3&idoc=1&file=plpgsql-trigger.html

trigger vs rules
http://www.postgresql.org/docs/view.php?version=7.3&idoc=1&file=rules-triggers.html

fabio




^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2003-03-26 23:04 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-02-28 06:31 Executing SQL commands via triggers without the use of procedures Susan Hoddinott <susan@perth.dialix.com.au>
2003-03-01 02:00 ` Re: Executing SQL commands via triggers without the use of Stephan Szabo <sszabo@megazone23.bigpanda.com>
2003-03-01 16:35 ` Jeff Eckermann <jeff_eckermann@yahoo.com>
2003-03-03 13:22 ` Oleg Samoylov <olleg@telecom.mipt.ru>
2003-03-26 23:04 ` fabio <penguin@email.it>

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