Received: from mailsys01.intnet.net (mailhost.wwc.com [198.252.32.15]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f49NndA77315 for ; Wed, 9 May 2001 19:49:39 -0400 (EDT) (envelope-from jconway2@home.com) Received: from [206.19.64.3] (HELO jecw2k1) by mailsys01.intnet.net (CommuniGate Pro SMTP 3.3.2) with SMTP id 7907307; Wed, 09 May 2001 19:48:46 -0400 Message-ID: <00c201c0d8e2$b3706530$54d410ac@jecw2k1> From: "Joe Conway" To: "Joseph Shraibman" Cc: References: <3AF9AECE.DE93E098@selectacast.net> <000c01c0d8d2$cefddf90$54d410ac@jecw2k1> <3AF9D542.88C9FACD@selectacast.net> Subject: Re: 'record old is unassigned yet' when using trigger in 7.1.1 Date: Wed, 9 May 2001 16:49:33 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Archive-Number: 200105/70 X-Sequence-Number: 2871 > ... but that had the same problem. So then I tried: > > create function utbl_set_statchangedate() returns opaque as > 'begin > IF TG_OP = \'UPDATE\' > THEN > NEW.statchangedate := CURRENT_DATE; > ELSE IF OLD.status <> NEW.status > THEN > NEW.statchangedate := CURRENT_DATE; > END IF; > return NEW; > end; > ' language 'plpgsql'; There is no "else if" in plpgsql, if I remember correctly. Try: create function utbl_set_statchangedate() returns opaque as 'begin IF TG_OP = ''UPDATE'' THEN NEW.statchangedate := CURRENT_DATE; ELSE IF OLD.status <> NEW.status THEN NEW.statchangedate := CURRENT_DATE; END IF; END IF; return NEW; end; ' language 'plpgsql'; -- Joe