Re: I need some magical advice

From: Andreas <maps(dot)on(at)gmx(dot)net>
To: PostgresSQL list <pgsql-sql(at)postgresql(dot)org>
Cc: Oliveiros Cristina <oliveiros(dot)cristina(at)marktest(dot)pt>
Subject: Re: I need some magical advice
Date: 2009-01-29 14:17:23
Message-ID: 4981BA73.2010706@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

yes, there is a serial as primary key. Lets call it "id".
Therfore one could use this to find the oldest record.

Regards
Andreas

Oliveiros Cristina schrieb:
> Andreas,
> Does your table has any field that can be used as primary key? Any
> "ID" field?
>
> Best,
> Oliveiros
>
>
> ----- Original Message ----- From: "Andreas" <maps(dot)on(at)gmx(dot)net>
> To: <pgsql-sql(at)postgresql(dot)org>
> Sent: Thursday, January 29, 2009 11:56 AM
> Subject: [SQL] I need some magical advice
>
>
>> Hi,
>>
>> I'd like to update some records in a table.
>> Those have a status_id and among other columns a varchar with a name
>> and a create_date.
>> The status_id is 0 if nothing was done with this record, yet.
>>
>> For some reasons I've got double entries which I now want to flag to
>> -1 so that they can be sorted out without actually deleting them
>> since there are other tables referencing them.
>>
>> From every group that shares the same name all should get status_id
>> set to -1 where status_id = 0.
>>
>> The tricky bit is:
>> How could I provide, that 1 of every group survives, even then when
>> all have status_id = 0?
>> Sometimes 2 of a group are touched so both have to stay.
>>
>>
>> e.g.
>> c_date, status_id, name
>> 2008/01/01, 0, A --> -1
>> 2008/01/02, 1, A --> do nothing
>> 2008/01/03, 0, A --> -1
>>
>> 2008/01/01, 0, B --> do nothing (single entry)
>>
>> 2008/01/01, 0, C --> do nothing (oldest 0 survives)
>> 2008/01/02, 0, C --> -1
>>
>> 2008/01/01, 1, D --> do nothing
>> 2008/01/02, 1, D --> do nothing
>>
>>
>>
>> --
>> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-sql
>>
>
>

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message M.P.Dankoor 2009-01-29 14:52:31 Re: I need some magical advice
Previous Message Oliveiros Cristina 2009-01-29 13:58:11 Re: I need some magical advice