Ask Your Question
1

FIREBIRD: Can't add new record to database, sdbc error: violation of PRIMARY or UNIQUE KEY

asked 2019-08-10 04:32:13 +0100

sdritchey gravatar image

I can't add a record to my Firebird database in LO 6.2.5. I get an error message that says:

firebird_sdbc error: *violation of PRIMARY or UNIQUE KEY constraint "INTEG_9" on table "tablename" *Problematic key value is ("ID" = 15) caused by 'isc_dsql_execute'

Any assistance would be much appreciated.

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
2

answered 2019-08-10 15:23:57 +0100

kelsa gravatar image

Run this from menu Tools -> SQL:

SELECT MAX("ID") FROM "TABLENAME"

Observe NUMBER in output field.

Then enter new command:

ALTER TABLE "TABLENAME" ALTER "ID" RESTART WITH NUMBER

You might also want to read https://ask.libreoffice.org/en/questi...

edit flag offensive delete link more

Comments

1

Kelsa this worked, thank you. The numbering sequence used by the primary key ID field had reset to a lower value in the range of previous records, using a duplicate primary ID number. This command reset that value to a number beyond the range previously used.

For reference to others using this information, you need to replace NUMBER with the numerical value you want to use as the new starting point for the primary key auto increment. For me it looked like this:

ALTER TABLE "MYTABLENAME" ALTER "ID" RESTART WITH 1500

sdritchey gravatar imagesdritchey ( 2019-08-10 18:29:02 +0100 )edit
0

answered 2019-08-10 13:19:54 +0100

lazarus477 gravatar image

You most likely entered a duplicate record. Record uniqueness is determined by the primary key field. A value entered in this field must not clash, meaning it must be unique.

If you are new to databases then I suggest the following reading material: Relational database

Read the section describing what a primary key is.

You might also want to read up more on FirebirdDB specifics here.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-08-10 04:32:13 +0100

Seen: 174 times

Last updated: Aug 10