Skip site navigation (1) Skip section navigation (2)

Re: Common question: what's wrong

From: Terry Lee Tucker <terry(at)esc1(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Common question: what's wrong
Date: 2005-01-15 13:55:59
Message-ID: 200501150855.59342.terry@esc1.com (view raw or flat)
Thread:
Lists: 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(at)klub(dot)chip(dot)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(at)esc1(dot)com

In response to

pgsql-novice by date

Next:From: Hadi SaboohiDate: 2005-01-16 07:35:43
Subject: Get DB Structure
Previous:From: John DeSoiDate: 2005-01-15 13:37:57
Subject: Re: Common question: what's wrong

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group