pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: hubert depesz lubaczewski <depesz@depesz.pl>
To: al_nunes@ciclotecnologia.com.br
Cc: pgsql-docs@postgresql.org
Subject: Re: Trigger Documentation
Date: Sun, 10 Jun 2001 09:35:44 +0200
Message-ID: <20010610093544.14c48d82.depesz@depesz.pl> (raw)
In-Reply-To: <Pine.LNX.4.21.0106081145560.8814-100000@pinguim.ciclotecnologia.com.br>
References: <Pine.LNX.4.21.0106081145560.8814-100000@pinguim.ciclotecnologia.com.br>

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.<field> ISNULL THEN
>   NEW.<field> := "something";
>    RETURN NEW;
> END;

you're missing two things.
1st. there should be end if
2nd. is should be NEW.<field> := ''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 ...



view thread (2+ messages)

Message-ID: <20010610093544.14c48d82.depesz@depesz.pl>
Permalink:  ../20010610093544.14c48d82.depesz@depesz.pl/
Also on:    postgresql.org/message-id/20010610093544.14c48d82.depesz@depesz.pl

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: depesz@depesz.pl, al_nunes@ciclotecnologia.com.br
  Subject: Re: Trigger Documentation
  In-Reply-To: <20010610093544.14c48d82.depesz@depesz.pl>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox