Re: [Pgsql-ayuda] default a una función

From: Gunnar Wolf <gwolf(at)gwolf(dot)cx>
To: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
Cc: pgsql-ayuda(at)tlali(dot)iztacala(dot)unam(dot)mx
Subject: Re: [Pgsql-ayuda] default a una función
Date: 2003-08-27 20:46:08
Message-ID: 20030827204607.GD2874@gwolf.cx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Alvaro Herrera dijo [Sat, Aug 23, 2003 at 01:06:45PM -0400]:
> On Fri, Aug 22, 2003 at 07:40:28PM -0500, Gunnar Wolf wrote:
>
> Gunnar,
>
> > Quisiera que el valor de salida de esta función fuera el valor default
> > para nuevas inserciones, de modo que pudiera hacerlas pasando sólo el
> > person_id y el proposal_id. Sin embargo, claro está:
> >
> > |ALTER TABLE authors ALTER COLUMN mention_order SET DEFAULT next_author_mention_order(proposal_id);
> > |ERROR: cannot use column references in DEFAULT clause
> >
> > ¿Hay algún modo de lograr lo que estoy buscando?
>
> Claro, usa un trigger que modifique el valor de mention_order usando la
> funcion.

Gusta, gusta... algo como 'IF NEW.mention_order IS NULL THEN
NEW.mention_order := next_author_mention_order(proposal_id);'

Gracias! :D

--
Gunnar Wolf - gwolf(at)gwolf(dot)cx - (+52-55)5630-9700 ext. 1366
PGP key 1024D/8BB527AF 2001-10-23
Fingerprint: 0C79 D2D1 2C4E 9CE4 5973 F800 D80E F35A 8BB5 27AF

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message sandrigo lezcano 2003-08-27 21:39:11 [Pgsql-ayuda] insertar datos NULL
Previous Message red-utm 2003-08-27 20:10:37 Re: [Pgsql-ayuda] pgaccess v0.98