Update function - Mailing list pgsql-novice

From Rob
Subject Update function
Date
Msg-id Pine.LNX.4.33L2.0204121133430.18761-100000@Genesis
Whole thread Raw
Responses Re: Update function
List pgsql-novice
Hi all,

I have a table with products in and each products has 13 a digit barcode
as its primary key.  There
are two basic types of barcodes - those that start with 25 and those that
start with 60.  For barcodes that start with 25 only the first six digits
matter, the rest are just check digits.  Unfortunately, the full barcode
has been parsed into the database, resulting in duplicate product
information. eg. 2543210000222 and 2543210000123 are the same product.
However, the real problem is that the barcode 2543210000000 may also
exist.

I need some way to get rid of all these duplicates and I also need a way
to change all the 25 barcodes such that the barcode consists of the first
6 digits and 7 zeros e.g. 2543210000123 becomes 2543210000000 (I need the
barcode to be 13 digits)

I'm really stuck.  Any suggestions would be welcome.  What would really be
useful is an example on how to move through a result set one record at a
time, check if that changing the barcode on that current record does not
result in an alreadly existing barcode.  If it doesn't, then then record
is updated through an update, if it does, the record is deleted.

HELP

Thanks


--
Rob

He who dies with the most toys ...

                    ... still dies


pgsql-novice by date:

Previous
From: thiemo
Date:
Subject: Re: Failing tcp/ip connection
Next
From: John Taylor
Date:
Subject: Matching a large number of user chosen