c++ - How to fetch data from sqlite3 without using while 1 and if -


i'm using method of fetching data sqlite3 database:

while(1){    rc = sqlite3_step(stmt);    if(rc == sqlite_row){        ...    }    else if(rc == sqlite_done){        break;    } } 

what not if else construct, looks rather clunky here. , besides, knows if else evil. so, there method of fetching data sqlite, like:

while(sqlite3_step(stmt)){    ... } 

or, probably, there fetch method or similar that.

i want know other people in real world projects.

something should job, though sure check errors after exiting loop.

while((rc = sqlite3_step(stmt)) == sqlite_row) { ... } 

edit: note doesn't account if database busy, can correct either conditional goto after loop, or outside loop continues while rc it's not equal sqlite_done.


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -