SQLite Forum

sqlite3_blob_read returns SQL Logic Error
Login

sqlite3_blob_read returns SQL Logic Error

(1) By anonymous on 2021-04-30 01:54:29 [source]

A continuation of a previous post re sqlite3_blob_open([...]) - This bit works fine now thanks to Keith.

Again, I must be doing somethin wrong but this time, I think I understand what the doc on the subject said but can't be 100% sure.


Sorry to inconvenience so be kind, I am new to this (I think I have mentioned this before :) ) 

	sqlite3_blob *pBlob = 0;
	int size = 0;

	if(!Open())
		return;

	_rc = sqlite3_blob_open(_db, UTF8String(schema).c_str(),
				UTF8String(table).c_str(),
				UTF8String(column).c_str(),
				rowId, flags, &pBlob);
	if (_rc == SQLITE_OK)
		{
		size = sqlite3_blob_bytes(pBlob);
		buffer = new Byte[size];

		_rc = sqlite3_blob_read(pBlob, &buffer, size , 1);  // returns code 1 SQL Logic Error

		if(_rc != SQLITE_OK)
			{
			_sqliteError.retCode = _rc;
			_sqliteError.errorMsg.sprintf(sqlite3_errmsg(_db));

			if(FSqliteError)
				FSqliteError(this, _sqliteError);

			throw Exception(_sqliteError.errorMsg);
			}

		}
	else
		{
		sqlite3_blob_close(pBlob);

		_sqliteError.retCode = _rc;
		_sqliteError.errorMsg.sprintf(sqlite3_errmsg(_db));
		if(FSqliteError)
			FSqliteError(this, _sqliteError);

		throw Exception(_sqliteError.errorMsg);
		}
	Close();

(2) By anonymous on 2021-04-30 03:30:09 in reply to 1 [link] [source]

NVM, I found my error iOffset set at 0 gets through earlier, when set to 0 got another type of error.

I am learning, I think

Cheers