got it working - many thanks!
Main Topics
Browse All TopicsHi Experts,
I thought I fixed this - funny thing is - it was sort of fixed...
When doing INSERT statements, I use the following form with 'serial' columns (my customer_id column is a serial type)
INSERT INTO Customers (Customer_ID, Telephone) VALUES (DEFAULT, '123-456-7890')
I started with a fresh new database - I was able to do a couple of these inserts like so.
I start again withj a new database and import lots of records by running inserts with explicitly set values for Customer_ID. This works fine. But when I try to run the above INSERT (with DEFAULT instead of an explicitly set Customer_ID), I get the error, "duplicate key value violates unique constraint "custmoers_pkey".
I looked in pgAdmin III at the info associated with customers_pkey:
customers_pkey:
Name customers_pkey
OID 19027
Index OID 19026
Tablespace pg_default
Columns Customer_id
Unique? Yes
Primary? Yes
Clustered? Yes
Access method btree
Constraint
System index? Yes
Thanks for any help!
Mike
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: ivanovnPosted on 2008-03-12 at 07:08:43ID: 21106073
Mike,
e.com/Data base/Postg reSQL/ Q_23 121095.htm l
Similar to my answer in your other thread, the sequence is not smart enough to set itself to the latest value you explicitly inserted into the table. Without setting the sequence to the latest number using something like I posted in your other thread, I don't think you are able to achieve what you are trying to achieve. Once you run inserts without using the sequence explicitly, the sequence becomes useless until it's set to a proper value. I am guessing the best advice I can give you is to not use explicit inserts if you are to use sequence.
Good luck.
Reference thread: http://www.experts-exchang