Re: Is this possible?

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: johnf <jfabiani(at)yolo(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Is this possible?
Date: 2009-02-17 08:10:38
Message-ID: dcc563d10902170010u13769d5ei13414a6621f36e54@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Mon, Feb 16, 2009 at 7:36 PM, johnf <jfabiani(at)yolo(dot)com> wrote:
> Hi,
> I'm not to sure this is possible.
>
> I need to replace a primary key (pkid) with the value of a different field.
> I have
> pkid = 200
> attendid = 301
>
> I need the pkid = 301
>
> But there may or may not be a pkid that already exist that has the value of
> 301. The attendid is unique and the pkid data type is serial (has a
> sequence).

If the FK is on update cascade just update it. and setval() the
sequence to be max(pkid)+1.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Steve Nyemba 2009-02-17 12:30:01 Stored Procedure Generator?
Previous Message A. Kretschmer 2009-02-17 06:32:26 Re: Is this possible?