简体   繁体   English

我认为错的C ++ sqlite3插入或替换查询

[英]c++ sqlite3 insert or replace query i think is erroring

I am corrected to my database, but when i fire off a command, i get an error. 我已更正我的数据库,但是当我执行命令时,出现错误。

my table: 我的桌子:

a{ id int primary key not null, name varchar not null, and order int not null }

My statement: 我的声明:

string query = "insert or replace into a (id,name,order) values (5,'hi',10)"
int rc;
rc = sqlite3_exec(db, query.c_str(), 0,0,&errMsg);
if(rc != SQLITE_OK){
    cout << "Error Code: " << rc << " SQLError: " << errMsg<<endl;
}

I wasnt sure how this is suppose to work. 我不确定这应该如何工作。 It is triyng to insert. 要插入。 It will see the PK matches.... Then after that, it will replace, will it try to replace the PK with itself? 它将看到PK匹配项。...然后,它将替换,它将尝试用自身替换PK吗? I wasnt sure. 我不确定。 The Returned ErrorCode which RC gives is: RC给出的返回的ErrorCode为:

1   /* SQL error or missing database */

The table was not created in the DB. 该表未在数据库中创建。 One of the dev team changed the schema, dropped old tables, and added new ones without documenting, or giving me any sort of notification. 一个开发团队更改了架构,删除了旧表,并添加了新表,而没有记录文档,也没有给我任何形式的通知。

Should have it resolved though now. 现在应该解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM