Page 1 of 1

PostgreSQL insert/Update problem

Posted: Wed Jul 31, 2002 8:29 am
by Love_Daddy
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

Posted: Wed Jul 31, 2002 8:33 am
by haagen
Try

Code: Select all

INSERT INTO emp (name, salary) VALUES ('Romeo', 1234)
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?).

Re:PostgreSQL insert/Update

Posted: Wed Jul 31, 2002 8:57 am
by Love_Daddy
When I do has you say, I get another error message namely:
Cannot insert a duplicate key into unique index emp_id_key

Posted: Thu Aug 01, 2002 2:37 am
by haagen
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):

Code: Select all

DROP SEQUENCE emp_Id_seq;
CREATE SEQUENCE emp_Id_seq START XX;
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!) :wink: