Received: from mail1.hub.org (webmail.hub.org [216.126.85.1]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f5A8CQE07314 for ; Sun, 10 Jun 2001 04:12:26 -0400 (EDT) (envelope-from depesz@depesz.pl) Received: from neron.mgc.pl (host-203-154.tele2.pl [213.173.203.154]) by mail1.hub.org (8.11.3/8.11.1) with ESMTP id f5A7tD299310 for ; Sun, 10 Jun 2001 03:58:09 -0400 (EDT) (envelope-from depesz@depesz.pl) Received: from localhost ([127.0.0.1] helo=neron) by neron.mgc.pl with smtp (Exim 3.22 #1) id 158zlA-0003q6-00; Sun, 10 Jun 2001 09:35:44 +0200 Date: Sun, 10 Jun 2001 09:35:44 +0200 From: hubert depesz lubaczewski To: al_nunes@ciclotecnologia.com.br Cc: pgsql-docs@postgresql.org Subject: Re: Trigger Documentation Message-Id: <20010610093544.14c48d82.depesz@depesz.pl> In-Reply-To: References: X-Mailer: Sylpheed version 0.4.66 (GTK+ 1.2.10; i686-pld-linux) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-2 Content-Transfer-Encoding: 8bit X-Disclaimer: test disclaimer X-Archive-Number: 200106/17 X-Sequence-Number: 812 On Fri, 8 Jun 2001 11:55:08 -0300 (BRT) al_nunes@ciclotecnologia.com.br wrote: > What I need to do now is very simple, I want to make a trigger that check > if some text field is null. If it is, I want to record something on > it. What I was trying (unsuccessfully): > CREATE FUNCTION ins_ip() RETURNS OPAQUE AS ' > BEGIN > IF NEW. ISNULL THEN > NEW. := "something"; > RETURN NEW; > END; you're missing two things. 1st. there should be end if 2nd. is should be NEW. := ''something''; btw. it's better to do it with "DEFAULT" statement in create table. depesz -- hubert depesz lubaczewski http://www.depesz.pl/ ------------------------------------------------------------------------ najwspanialszą rzeczą jaką dało nam nowoczesne społeczeństwo, jest niesamowita wręcz łatwość unikania kontaktów z nim ...