Why do I receive a 'General error' when trying to use INSERT with Database Toolbox 3.0 (R14)?

1 view (last 30 days)
I am using INSERT to add a row to one of the tables in a database. This works the first time I call INSERT, but subsequent calls result in an error message. For example, my first call is:
insert(conn,'productTable',{'productNumber','unitCost'},{1004,3.45});
This call works, but subsequent calls to INSERT result in the following error:
??? Error using ==> database.insert
General error

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This error results when the database has a primary key and you try to insert a row with a non-unique primary key. A primary key is a unique identifier in a table and prevents a row from being inserted that has the same primary key value as another row. A primary key can include values from one or more fields. When you try to add a row with a value in the primary key field that is the same as an existing value in a primary key field, the insert fails and an error appears.

More Answers (0)

Products


Release

R14SP1

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!