Re: [sqlite] sqlite3_bind. error as library routine called out of sequence.
Hi Mr Black, I am very thankful to you. My code is working fine. Regards, Bhaskar Reddy. Black, Michael (IS) wrote: > > You have to do all the binds together, THEN step. This works for me. > > > > #include > #include > #include > #include "sqlite3.h" > > int main() > { > sqlite3 *db; > sqlite3_stmt *stmt; > int status; > char *create = "create table > ONTTable(slotId,ponChannelId,onuType,onuId,adminStatus);"; > char *query = "insert into ONTTable > (slotId,ponChannelId,onuType,onuId,adminStatus) values (?1,?2,?3,?4,?5);"; > > > status=sqlite3_open_v2("test.db",,SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE,NULL); > if (status != SQLITE_OK) { > printf("open error:%s\n",sqlite3_errmsg(db)); > exit(1); > } > sqlite3_exec(db,create,NULL,NULL,NULL); > status=sqlite3_prepare_v2(db,query,strlen(query)+1, , NULL); > if (status != SQLITE_OK) { > printf("prepare error:%s\n",sqlite3_errmsg(db)); > exit(1); > } > > status=sqlite3_bind_int(stmt,1,1); > if (status != SQLITE_OK) { > printf("bind1 error:%s\n",sqlite3_errmsg(db)); > exit(1); > } > status=sqlite3_bind_int(stmt,2,2); > if (status != SQLITE_OK) { > printf("bind2 error:%s\n",sqlite3_errmsg(db)); > exit(1); > } > status=sqlite3_bind_int(stmt,3,3); > if (status != SQLITE_OK) { > printf("bind3 error:%s\n",sqlite3_errmsg(db)); > exit(1); > } > status=sqlite3_bind_int(stmt,4,4); > if (status != SQLITE_OK) { > printf("bind4 error:%s\n",sqlite3_errmsg(db)); > exit(1); > } > status=sqlite3_bind_int(stmt,5,5); > if (status != SQLITE_OK) { > printf("bind5 error:%s\n",sqlite3_errmsg(db)); > exit(1); > } > > status=sqlite3_step(stmt); > if (status != SQLITE_DONE) { > printf("step error:%s\n",sqlite3_errmsg(db)); > exit(1); > } > return 0; > } > > > > Michael D. Black > > Senior Scientist > > Advanced Analytics Directorate > > Advanced GEOINT Solutions Operating Unit > > Northrop Grumman Information Systems > > > From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on > behalf of bhaskarReddy [uni...@gmail.com] > Sent: Monday, January 16, 2012 7:46 AM > To: sqlite-users@sqlite.org > Subject: EXT :[sqlite] sqlite3_bind. error as library routine called out > of sequence. > > > Hi Friends, > > When i tried, > query = "insert into ONTTable > (slotId,ponChannelId,onuType,onuId,adminStatus) values (?1,?2,?3,?4,?5);"; > then binding each parameter. > > //sqlite3_prepare_v2(db,query,strlen(query)+1, , NULL); > sqlite3_bind_int(stmt,1,ontTable -> slotId); > sqlite3_step(stmt,DONE); > > //sqlite3_prepare_v2(db,query,strlen(query)+1, , NULL); > sqlite3_bind_int(stmt,1,ontTable -> ponChannelId); > sqlite3_step(stmt,DONE); > > //sqlite_prepare_v2(db,query,strlen(query)+1, , NULL); > sqlite3_bind_int(stmt,1,ontTable -> ontType); > sqlite3_step(stmt,DONE); > > //sqlite3_prepare_v2(db,query,strlen(query)+1, , NULL); > sqlite3_bind_int(stmt,1,ontTable -> onuId); > sqlite3_step(stmt,DONE); > > //sqlite3_bind_prepare_v2(db,query,strlen(query)+1, , NULL); > sqlite3_bind_int(stmt,1,ontTable -> adminStatus); > > I am getting the following error. > sqilte3_bind_int(stmt,1,ontTable -> ponChannelId) failed with status 21: > library routine called out of sequence. > > > > Regards, > Bhaskar Reddy. > > -- > View this message in context: > http://old.nabble.com/sqlite3_bind.-error-as-library-routine-called-out-of-sequence.-tp33147572p33147572.html > Sent from the SQLite mailing list archive at Nabble.com. > > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > -- View this message in context: http://old.nabble.com/sqlite3_bind.-error-as-library-routine-called-out-of-sequence.-tp33147572p33152332.html Sent from the SQLite mailing list archive at Nabble.com. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] sqlite3_bind. error as library routine called out of sequence.
You have to do all the binds together, THEN step. This works for me. #include #include #include #include "sqlite3.h" int main() { sqlite3 *db; sqlite3_stmt *stmt; int status; char *create = "create table ONTTable(slotId,ponChannelId,onuType,onuId,adminStatus);"; char *query = "insert into ONTTable (slotId,ponChannelId,onuType,onuId,adminStatus) values (?1,?2,?3,?4,?5);"; status=sqlite3_open_v2("test.db",,SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE,NULL); if (status != SQLITE_OK) { printf("open error:%s\n",sqlite3_errmsg(db)); exit(1); } sqlite3_exec(db,create,NULL,NULL,NULL); status=sqlite3_prepare_v2(db,query,strlen(query)+1, , NULL); if (status != SQLITE_OK) { printf("prepare error:%s\n",sqlite3_errmsg(db)); exit(1); } status=sqlite3_bind_int(stmt,1,1); if (status != SQLITE_OK) { printf("bind1 error:%s\n",sqlite3_errmsg(db)); exit(1); } status=sqlite3_bind_int(stmt,2,2); if (status != SQLITE_OK) { printf("bind2 error:%s\n",sqlite3_errmsg(db)); exit(1); } status=sqlite3_bind_int(stmt,3,3); if (status != SQLITE_OK) { printf("bind3 error:%s\n",sqlite3_errmsg(db)); exit(1); } status=sqlite3_bind_int(stmt,4,4); if (status != SQLITE_OK) { printf("bind4 error:%s\n",sqlite3_errmsg(db)); exit(1); } status=sqlite3_bind_int(stmt,5,5); if (status != SQLITE_OK) { printf("bind5 error:%s\n",sqlite3_errmsg(db)); exit(1); } status=sqlite3_step(stmt); if (status != SQLITE_DONE) { printf("step error:%s\n",sqlite3_errmsg(db)); exit(1); } return 0; } Michael D. Black Senior Scientist Advanced Analytics Directorate Advanced GEOINT Solutions Operating Unit Northrop Grumman Information Systems From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on behalf of bhaskarReddy [uni...@gmail.com] Sent: Monday, January 16, 2012 7:46 AM To: sqlite-users@sqlite.org Subject: EXT :[sqlite] sqlite3_bind. error as library routine called out of sequence. Hi Friends, When i tried, query = "insert into ONTTable (slotId,ponChannelId,onuType,onuId,adminStatus) values (?1,?2,?3,?4,?5);"; then binding each parameter. //sqlite3_prepare_v2(db,query,strlen(query)+1, , NULL); sqlite3_bind_int(stmt,1,ontTable -> slotId); sqlite3_step(stmt,DONE); //sqlite3_prepare_v2(db,query,strlen(query)+1, , NULL); sqlite3_bind_int(stmt,1,ontTable -> ponChannelId); sqlite3_step(stmt,DONE); //sqlite_prepare_v2(db,query,strlen(query)+1, , NULL); sqlite3_bind_int(stmt,1,ontTable -> ontType); sqlite3_step(stmt,DONE); //sqlite3_prepare_v2(db,query,strlen(query)+1, , NULL); sqlite3_bind_int(stmt,1,ontTable -> onuId); sqlite3_step(stmt,DONE); //sqlite3_bind_prepare_v2(db,query,strlen(query)+1, , NULL); sqlite3_bind_int(stmt,1,ontTable -> adminStatus); I am getting the following error. sqilte3_bind_int(stmt,1,ontTable -> ponChannelId) failed with status 21: library routine called out of sequence. Regards, Bhaskar Reddy. -- View this message in context: http://old.nabble.com/sqlite3_bind.-error-as-library-routine-called-out-of-sequence.-tp33147572p33147572.html Sent from the SQLite mailing list archive at Nabble.com. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] sqlite3_bind. error as library routine called out of sequence.
Hi Friends, When i tried, query = "insert into ONTTable (slotId,ponChannelId,onuType,onuId,adminStatus) values (?1,?2,?3,?4,?5);"; then binding each parameter. //sqlite3_prepare_v2(db,query,strlen(query)+1, , NULL); sqlite3_bind_int(stmt,1,ontTable -> slotId); sqlite3_step(stmt,DONE); //sqlite3_prepare_v2(db,query,strlen(query)+1, , NULL); sqlite3_bind_int(stmt,1,ontTable -> ponChannelId); sqlite3_step(stmt,DONE); //sqlite_prepare_v2(db,query,strlen(query)+1, , NULL); sqlite3_bind_int(stmt,1,ontTable -> ontType); sqlite3_step(stmt,DONE); //sqlite3_prepare_v2(db,query,strlen(query)+1, , NULL); sqlite3_bind_int(stmt,1,ontTable -> onuId); sqlite3_step(stmt,DONE); //sqlite3_bind_prepare_v2(db,query,strlen(query)+1, , NULL); sqlite3_bind_int(stmt,1,ontTable -> adminStatus); I am getting the following error. sqilte3_bind_int(stmt,1,ontTable -> ponChannelId) failed with status 21: library routine called out of sequence. Regards, Bhaskar Reddy. -- View this message in context: http://old.nabble.com/sqlite3_bind.-error-as-library-routine-called-out-of-sequence.-tp33147572p33147572.html Sent from the SQLite mailing list archive at Nabble.com. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users