Received: from mail.postgresql.org (webmail.postgresql.org [216.126.85.28]) by mail.postgresql.org (8.11.1/8.11.1) with SMTP id f15Hshx41875 for ; Mon, 5 Feb 2001 12:54:43 -0500 (EST) (envelope-from pgsql-sql-owner@postgresql.org) Received: from news.tht.net (news.hub.org [216.126.91.242]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f0V4xuq86209 for ; Tue, 30 Jan 2001 23:59:56 -0500 (EST) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.1/8.11.1) id f0V4eVA03702 for pgsql-sql@postgresql.org; Tue, 30 Jan 2001 23:40:31 -0500 (EST) (envelope-from news) From: Ian Harding X-Newsgroups: comp.databases.postgresql.sql Subject: Re: Getting Results From Trigger Date: Tue, 30 Jan 2001 20:46:40 -0800 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 53 Message-ID: <3A7798B0.4481CE1@pakrat.com> References: <3A76F0E3.F6A4A5F0@lighthouseasp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: scrappy@hub.org X-Mailer: Mozilla 4.61 [en] (X11; U; Linux 2.2.12-20 i686) X-Accept-Language: en To: pgsql-sql@postgresql.org X-Archive-Number: 200102/55 X-Sequence-Number: 1225 cbell wrote: > Hello everyone, I was hoping someone could help me with this... > > I'm running postgres 7.02 on redhat 6.2, apache 1.3.14 and mod_perl > 1.24_01. I'm also using perl modules DBI 1.14 and DBD-Pg-0.95 to acces > the Postgres database. > > Everytime my inventory file gets updated, I would like to have the > quantity on hand returned to my perl script. I set up the following > function to do this: > > CREATE FUNCTION inv_lookup () RETURNS OPAQUE AS ' > BEGIN > RAISE NOTICE ''%'', NEW.qtyonhand; > RETURN new; > end; > 'language 'plpgsql'; > > Then I create the trigger like this... > > CREATE TRIGGER qty after inventory for each row execute procedure > inv_lookup(); > > If I do any sort of updates from within psql I get the correct data > which is the Qtyonhand field in this format: > > NOTICE: 15 > > However, in my perl program, I'm unsure as to how to get this > information back. The Postgres Documentation says that the results from > > a Notice get sent back to the application, but I check the DBI->err, > DBI->errstr, and DBI->state and they are empty. The result code for the > > actual SQL command I run is just 1 for success. > > Does anyone know how to get these results from within a perl scripts??? > Thanks in advance for any help. > > Chris. I have spent a little time trying to get MS SQL Server triggers to give up their secrets to my AOLServer scripts, but it seems it can't be done. An update, insert or delete query (called DML by AOLServer, whatever that means) can't have any return value. I found I was able to work around it, as I suspect you could, with another query. After the insert, just select the quantity on hand for the item in question, right? Ian