[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sqlite-users
Subject:    Re: [sqlite] sqlite3_get_table question
From:       schachtobi <schachtobi () web ! de>
Date:       2008-12-30 18:44:44
Message-ID: 495A6C1C.6030701 () web ! de
[Download RAW message or body]

Hi,

thanks Dan. This was certainly the problem, since there are a lot of
zeros in the data.

In the meahnwhile I tried out something different. I heard from the
incremental blob API. And it worked!!!

Here is how I solved it:

if(sqlite3_prepare_v2(db, cmd, strlen(cmd), &pStmt, 0) != SQLITE_OK)
{
  printf("Could not prepare statement.\n");
  return;
}

rc = sqlite3_step(pStmt);
if( rc==SQLITE_ROW )
{
  newBlobSize = sqlite3_column_bytes(pStmt, 2);
  if(newBlobSize > blobSize || blobData == NULL)
  {
    printf("(re)allocating buffer\n");
    if(blobData != NULL)
      free(blobData);

    blobData = malloc(newBlobSize);
    blobSize = newBlobSize;	    	
  }
  memcpy(blobData, sqlite3_column_blob(pStmt, 2), newBlobSize);
}

Now I only need to solve a speed problem, but this I will first try out
by myself:-)

Thanks for your help

Tobias

>>> Date: Mon, 29 Dec 2008 11:20:58 +0700
>>> From: Dan <danielk1977@gmail.com>
>>> Subject: Re: [sqlite] sqlite3_get_table question
>>> To: General Discussion of SQLite Database <sqlite-users@sqlite.org>
>>> Message-ID: <65FA0CC6-4248-4675-8100-F069423E0821@gmail.com
>>
>>> Why (ncol+2)?
>>
>> I make the following select statement:
>>
>> SELECT fname, dsize, data, ABS(red-%d)+ABS(green-%d)+ABS(blue-%d) err
>>  FROM ch ORDER BY err LIMIT 1;
>>
>> If I want to have the data then this would be 2 + the number of  
>> heading
>> columns (ncol)
> 
> Right. Obviously.
> 
> Note that sqlite3_get_table() won't work for data with embedded 0x00  
> bytes.
> It will truncate each value at the first one encountered. That could be
> the problem.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic