replying to my own message - update should my myString2 - that is not an actual error, just copied and pasted it wrong. also i noticed a problem with i in my final for loop. i changed it to j since i was being incremented. i still get the same output however. just to clarify.
--- C S <[EMAIL PROTECTED]> wrote: > Igor, > > thanks for all your help too man. here is what is > in > the table images so far when i do a select. its 3 > blobs: > > sqlite> select imageID, hex(imageData) from Images; > 1|00 0003 0006 0009 000C 000F 0012 0015 0018 001B 00 > 2|00 0001 0002 0003 0004 0005 0006 0007 0008 0009 00 > 3|00 0001 0002 0003 0004 0005 0006 0007 0008 0009 00 > ***************************************************** > > here is what i have now: > > const unsigned short *image; > int i = 0; > > myString2 = "select imageID, imageData from Images"; > > int status = sqlite3_prepare_v2(db, update.c_str(), > -1, &statement, NULL); > > while ((status = sqlite3_step(statement)) == > SQLITE_ROW) > { > i++ > > if(i == 1) > std::cout << "first row" << std::endl; > > else std::cout << "another row" << std::endl; > > num_bytes = sqlite3_column_bytes(statement, i); > num_bytes = num_bytes / sizeof(unsigned short); > image = new unsigned short[num_bytes]; > image = (const unsigned > short*)sqlite3_column_blob(statement, i); > > for(int i = 0; i < num_bytes; i++) > std::cout << "image " << i << ": " << > image[i] > << std::endl; > > //delete [] image; //causes a crash so far. > } > > status = sqlite3_finalize(statement); > if (status != SQLITE_OK) > std::cerr << "Error deleting prepared SQL > statement" << std::endl; > > else std::cout << "finalized statement > successfully" > << std::endl; > > *********************************************** > > Output: > > first row > image 0: 0 > image 1: 3 > image 2: 6 > image 3: 9 > image 4: 12 > image 5: 15 > image 6: 18 > image 7: 21 > image 8: 24 > image 9: 27 > another row > another row > finalized statement successfully > > --so for some reason i get the first > blob(successfully, yes!) but it never increments > after > that. the statement is also finalized successfully. > any reason why the other two blobs are not printing > out? > > as a side note i commented out the deleting of the > image because i got a major abort crash, no doubt > memory leaks/forbidden access issues. > > thanks!! > > > > > > > --- Igor Tandetnik <[EMAIL PROTECTED]> wrote: > > > C S <[EMAIL PROTECTED]> wrote: > > > thanks for the tip on the hex. now i can see my > > > entry of the blob. my original loop to fill the > > > dynamic array with unsigned shorts was this: > > > > > > imageArray = new unsigned short[10]; > > > > > > for(int i = 0; i < 10; i++) > > > imageArray[i] = i; > > > > > > so now if i run the program then do a: > > > > > > select imageID, hex(imageData) from Images; > > > > > > i get the result: > > > > > > 1|0000010002000300040005000600070008000900 > > > > > > i am not sure where the first 2 leading zeros > are > > > coming from > > > > The first value (the one at index 0) in imageArray > > is zero, represented > > by two zero bytes. > > > > > now i need to be able to extract the data back > out > > of > > > the blob with sqlite3_column_blob and > > > sqlite3_column_bytes so that i can repopulate an > > > unsigned short array. > > > > > > if i have multiple blobs in the table Images how > > would > > > i go about retrieving back all this information? > > > > You prepare a select statement, e.g. > > > > select imageID, imageData from Images; > > > > Then you loop over all rows in the resultset with > > sqlite3_step call > > (each call advances to the next row), and for each > > row call > > sqlite3_column_* once for each column you are > > interested in. > > > > Igor Tandetnik > > > > > > > > _______________________________________________ > > sqlite-users mailing list > > sqlite-users@sqlite.org > > > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > > > > > > ____________________________________________________________________________________ > Never miss a thing. Make Yahoo your home page. > http://www.yahoo.com/r/hs > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users