Hi All,
Thank for your help so far.
I have another problem, everytime I try to insert or update my table, I get the following error:
ERROR: pg_atoi: error in "Romeo": can't parse "Romeo"
With the following insert
INSERT INTO emp VALUES('Romeo',2584) ;
Table: emp
Values: Id, name,salary
Please help..
Thanks
PostgreSQL insert/Update problem
Moderator: General Moderators
- Love_Daddy
- Forum Commoner
- Posts: 61
- Joined: Wed Jul 10, 2002 6:55 am
- Location: South Africa
- Contact:
Try
If you don't tell pgsql what fields your sending it assumes it is all fields in the right order. With my query I tell that I want to set the ID field to DEFAULT (mybee a serial field -> next number?).
Code: Select all
INSERT INTO emp (name, salary) VALUES ('Romeo', 1234)- Love_Daddy
- Forum Commoner
- Posts: 61
- Joined: Wed Jul 10, 2002 6:55 am
- Location: South Africa
- Contact:
Re:PostgreSQL insert/Update
When I do has you say, I get another error message namely:
Cannot insert a duplicate key into unique index emp_id_key
Cannot insert a duplicate key into unique index emp_id_key
I'm not sure, but it look's like your sequnce is broken. One way to fix this is (if you have a serial field):
The emp_Id_seq works as: table_field_seq. Change XX to the next number you Id should be (SELECT MAX(Id)+1 FROM emp).
I cannot guarantee this will work. But it might be worth trying! (== Backup first!)
Code: Select all
DROP SEQUENCE emp_Id_seq;
CREATE SEQUENCE emp_Id_seq START XX;I cannot guarantee this will work. But it might be worth trying! (== Backup first!)