X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E2E94D1B51E for ; Mon, 20 Oct 2003 13:01:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 14944-09 for ; Mon, 20 Oct 2003 10:01:03 -0300 (ADT) Received: from web60210.mail.yahoo.com (web60210.mail.yahoo.com [216.109.118.105]) by svr1.postgresql.org (Postfix) with SMTP id 888ABD1B501 for ; Mon, 20 Oct 2003 10:00:59 -0300 (ADT) Message-ID: <20031020130058.61589.qmail@web60210.mail.yahoo.com> Received: from [24.75.42.210] by web60210.mail.yahoo.com via HTTP; Mon, 20 Oct 2003 06:00:58 PDT Date: Mon, 20 Oct 2003 06:00:58 -0700 (PDT) From: Dmitri Fuerle Subject: Question regarding triggers To: pgsql-sql@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-902308228-1066654858=:61044" X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=1.5 tagged_above=0.0 required=5.0 tests=HTML_20_30 X-Spam-Level: * X-Archive-Number: 200310/232 X-Sequence-Number: 15632 --0-902308228-1066654858=:61044 Content-Type: text/plain; charset=us-ascii I'm writing a trigger but running into problems. My problem is that I can not determine anyway to tell what fields are in the *new* record. Without knowing what fields are there I get runtime errors if that's not what is being updated example: CREATE FUNCTION "public"."check_shipment" () RETURNS trigger AS' begin If new.shipment_type_id = 4 then --do something end if; return new; end; in the above example everything works if shipment_type_id is being updated. If it is not I will receive a run-time error because shipment_type_id is not part of the record new. Please help, Dmitri --------------------------------- Do you Yahoo!? The New Yahoo! Shopping - with improved product search --0-902308228-1066654858=:61044 Content-Type: text/html; charset=us-ascii
 
   I'm writing a trigger but running into problems.  My problem is that I can not determine anyway to tell what fields are in the *new* record.  Without knowing what fields are there I get runtime errors if that's not what is being updated example:
 
CREATE FUNCTION "public"."check_shipment" () RETURNS trigger AS'
begin
    If new.shipment_type_id = 4 then
        --do something
    end if;
    return new;
end;
 
in the above example everything works if shipment_type_id is being updated.  If it is not I will receive a run-time error because shipment_type_id is not part of the record new.
 
Please help,
Dmitri
 


Do you Yahoo!?
The New Yahoo! Shopping - with improved product search --0-902308228-1066654858=:61044--