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

1 次查看(过去 30 天)
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

采纳的回答

MathWorks Support Team
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Database Toolbox 的更多信息

产品


版本

R14SP1

Community Treasure Hunt

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

Start Hunting!

Translated by