From susan@perth.dialix.com.au Fri Feb 28 13:01:44 2003 X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EA501476193 for ; Fri, 28 Feb 2003 08:01:44 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 34206-02 for ; Fri, 28 Feb 2003 08:01:29 -0500 (EST) Received: from home.dialix.com (unknown [216.14.192.249]) by postgresql.org (Postfix) with ESMTP id 624894761A1 for ; Fri, 28 Feb 2003 01:31:15 -0500 (EST) Received: from oemcomputer (dialup-35.37.194.203.acc01-stge-pth.comindico.com.au [203.194.37.35]) by home.dialix.com (8.11.6/8.9.3/JustNet) with SMTP id h1S6Wkk48621 for ; Fri, 28 Feb 2003 17:32:47 +1100 (EST) (envelope-from susan@perth.dialix.com.au) Message-ID: <001501c2def2$fe2fe9c0$1f84fea9@oemcomputer> From: "Susan Hoddinott" To: Subject: Executing SQL commands via triggers without the use of procedures Date: Fri, 28 Feb 2003 14:31:12 +0800 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0011_01C2DF36.0AC1DB60" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6600 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 X-Virus-Scanned: by amavisd-new X-Archive-Number: 200302/633 X-Sequence-Number: 12031 This is a multi-part message in MIME format. ------=_NextPart_000_0011_01C2DF36.0AC1DB60 Content-Type: multipart/alternative; boundary="----=_NextPart_001_0012_01C2DF36.0AC1DB60" ------=_NextPart_001_0012_01C2DF36.0AC1DB60 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello, 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? Regards ------=_NextPart_001_0012_01C2DF36.0AC1DB60 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hello,
 
Having scoured the relevant documentation = I cannot=20 find anything which indicates how I simply create a database trigger to ins= ert=20 into a second table after insert on a first table, without the use of a=20 procedure.  As I do not want return values etc. this seems like=20 overkill.  Is it possible to create a trigger which executes SQL direc= tly=20 without the need to create a procedure?  If so, what is the=20 syntax?
 
Regards
------=_NextPart_001_0012_01C2DF36.0AC1DB60-- ------=_NextPart_000_0011_01C2DF36.0AC1DB60 Content-Type: application/octet-stream; name="Susan Hoddinott.vcf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Susan Hoddinott.vcf" BEGIN:VCARD VERSION:2.1 N:Hoddinott;Susan FN:Susan Hoddinott EMAIL;INTERNET:susan@perth.dialix.com.au EMAIL;PREF;INTERNET:susan@hexworx.com REV:20030228T063112Z END:VCARD ------=_NextPart_000_0011_01C2DF36.0AC1DB60-- From sszabo@megazone23.bigpanda.com Sat Mar 1 02:00:06 2003 X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 93504475843 for ; Fri, 28 Feb 2003 21:00:06 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 31525-09 for ; Fri, 28 Feb 2003 21:00:02 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 0F173475461 for ; Fri, 28 Feb 2003 21:00:02 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 81E1CD60F; Fri, 28 Feb 2003 18:00:05 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 6E73A5C04; Fri, 28 Feb 2003 18:00:05 -0800 (PST) Date: Fri, 28 Feb 2003 18:00:05 -0800 (PST) From: Stephan Szabo To: Susan Hoddinott Cc: Subject: Re: Executing SQL commands via triggers without the use of In-Reply-To: <001501c2def2$fe2fe9c0$1f84fea9@oemcomputer> Message-ID: <20030228175804.N7046-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new X-Archive-Number: 200302/642 X-Sequence-Number: 12040 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. From jeff_eckermann@yahoo.com Sat Mar 1 16:35:51 2003 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/ From olleg@telecom.mipt.ru Mon Mar 3 13:22:59 2003 X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AFF5947595A for ; Mon, 3 Mar 2003 08:22:59 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 36089-10 for ; Mon, 3 Mar 2003 08:22:58 -0500 (EST) Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id 4328747590C for ; Mon, 3 Mar 2003 08:22:49 -0500 (EST) Received: by news.hub.org (Postfix, from userid 8) id 2866443A841; Mon, 3 Mar 2003 08:22:49 -0500 (EST) From: Oleg Samoylov X-Newsgroups: comp.databases.postgresql.sql Subject: Re: Executing SQL commands via triggers without the use of procedures Date: Mon, 03 Mar 2003 16:22:51 +0300 Organization: MIPT Telecom Lines: 4 Message-ID: References: <001501c2def2$fe2fe9c0$1f84fea9@oemcomputer> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: ru, en In-Reply-To: <001501c2def2$fe2fe9c0$1f84fea9@oemcomputer> To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/68 X-Sequence-Number: 12108 You can use rules for this purpose. -- Olleg Samoylov From penguin@email.it Wed Mar 26 23:04:48 2003 X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1DE33476350 for ; Wed, 26 Mar 2003 18:04:48 -0500 (EST) Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id 8682A47634E for ; Wed, 26 Mar 2003 18:04:47 -0500 (EST) Received: by news.hub.org (Postfix, from userid 8) id 674AC43A611; Wed, 26 Mar 2003 18:04:47 -0500 (EST) From: "fabio" X-Newsgroups: comp.databases.postgresql.sql Subject: Re: Executing SQL commands via triggers without the use of procedures Date: Thu, 27 Mar 2003 00:04:48 +0100 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 21 Message-ID: References: <001501c2def2$fe2fe9c0$1f84fea9@oemcomputer> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 X-Complaints-To: usenet@news.hub.org User-Agent: Pan/0.13.4 (She had eyes like strange sins. (Debian GNU/Linux)) To: pgsql-sql@postgresql.org Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-12.9 required=5.0 tests=BAYES_10,QUOTE_TWICE_1,REFERENCES,USER_AGENT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/601 X-Sequence-Number: 12639 >=20 > Having scoured the relevant documentation I cannot find anything which in= di=3D > cates how I simply create a database trigger to insert into a second tabl= e =3D > after insert on a first table, without the use of a procedure. As I do n= ot=3D > want return values etc. this seems like overkill. Is it possible to cre= at=3D > e a trigger which executes SQL directly without the need to create a proc= ed=3D > ure? If so, what is the syntax? >=20 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=20 manual for trigger procedure: http://www.postgresql.org/docs/view.php?version=3D7.3&idoc=3D1&file=3Dplpgs= ql-trigger.html trigger vs rules http://www.postgresql.org/docs/view.php?version=3D7.3&idoc=3D1&file=3Drules= -triggers.html fabio