Update function

From: Rob <rob(at)obsidian(dot)co(dot)za>
To: PostgreSQL Server <postgres(at)obsidian(dot)co(dot)za>, <pgsql-novice(at)postgresql(dot)org>
Subject: Update function
Date: 2002-04-12 15:42:53
Message-ID: Pine.LNX.4.33L2.0204121133430.18761-100000@Genesis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Rob 2002-04-12 16:11:24 Re: Matching a large number of user chosen
Previous Message Helge Bahmann 2002-04-12 11:38:33 Re: Update function