Re: Common question: what's wrong - Mailing list pgsql-novice

From Terry Lee Tucker
Subject Re: Common question: what's wrong
Date
Msg-id 200501150855.59342.terry@esc1.com
Whole thread Raw
In response to Common question: what's wrong  (przygoda@klub.chip.pl)
List pgsql-novice
I believe that if you want the default value in new.id_oferta, then do
nothing. If the value is not set, the default will be applied. I don't think
you can do it the way you are tying to.

On Thursday 13 January 2005 08:32 am, przygoda@klub.chip.pl saith:
> This is a trigger function:
>
> CREATE FUNCTION public.trigger_null2default() RETURNS trigger AS 'BEGIN
> IF TG_RELNAME = ''g_oferty'' THEN
>     IF NEW.id_oferta ISNULL THEN
>         NEW.id_oferta = DEFAULT ;
>     END IF;
> END IF;
> RETURN NEW;
> END;'  LANGUAGE 'plpgsql' IMMUTABLE;
>
> There is an error near DEFAULT when firing trigger (on insert)
> How can I set defaults without doing INSERT INTO 'g_oferta' (DEFAULT,
> NEW...?
>
> Martin
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
>                http://archives.postgresql.org

--
 Work: 1-336-372-6812
 Cell: 1-336-363-4719
email: terry@esc1.com

pgsql-novice by date:

Previous
From: John DeSoi
Date:
Subject: Re: Common question: what's wrong
Next
From: "Hadi Saboohi"
Date:
Subject: Get DB Structure