<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: A simple Delphi wrapper for Sqlite 3</title>
	<atom:link href="http://www.itwriting.com/blog/articles/a-simple-delphi-wrapper-for-sqlite-3/feed" rel="self" type="application/rss+xml" />
	<link>http://www.itwriting.com/blog</link>
	<description>Tech writing blog</description>
	<lastBuildDate>Sun, 12 Feb 2012 21:04:12 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: tim</title>
		<link>http://www.itwriting.com/blog/articles/a-simple-delphi-wrapper-for-sqlite-3/comment-page-3#comment-1056650</link>
		<dc:creator>tim</dc:creator>
		<pubDate>Thu, 02 Feb 2012 12:22:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.itwriting.com/blog/?page_id=659#comment-1056650</guid>
		<description>Dieter

This is an error in SQLite3.pas. The declaration of sqlite3_bind_text16 is wrong. Should be:

&lt;code&gt;
function sqlite3_bind_text16(hStmt: TSqliteStmt; ParamNum: integer;
  Text: PChar; numBytes: integer; ptrDestructor: TSQLite3Destructor): integer;
cdecl; external SQLiteDLL name &#039;sqlite3_bind_text16&#039;;
&lt;/code&gt;

I&#039;ll update the source shortly.

Tim</description>
		<content:encoded><![CDATA[<p>Dieter</p>
<p>This is an error in SQLite3.pas. The declaration of sqlite3_bind_text16 is wrong. Should be:</p>
<p><code><br />
function sqlite3_bind_text16(hStmt: TSqliteStmt; ParamNum: integer;<br />
  Text: PChar; numBytes: integer; ptrDestructor: TSQLite3Destructor): integer;<br />
cdecl; external SQLiteDLL name 'sqlite3_bind_text16';<br />
</code></p>
<p>I&#8217;ll update the source shortly.</p>
<p>Tim</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dieter Köhler</title>
		<link>http://www.itwriting.com/blog/articles/a-simple-delphi-wrapper-for-sqlite-3/comment-page-3#comment-1055067</link>
		<dc:creator>Dieter Köhler</dc:creator>
		<pubDate>Wed, 01 Feb 2012 14:59:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.itwriting.com/blog/?page_id=659#comment-1055067</guid>
		<description>I encountered an unexpected &quot;constraint failed&quot; error when using a parameterized INSERT command. Here is a minimal code example:

&lt;code&gt;
procedure Test(const F: TFilename);
var
  db: TSQLiteDatabase;
  sql: string;
begin
  db := TSQLiteDatabase.Create(F);
  try
    sql := &#039;CREATE TABLE test ( foo TEXT NOT NULL, CHECK (foo = &#039;&#039;bar&#039;&#039;) )&#039;;
    db.ExecSQL(sql);
    sql := &#039;INSERT INTO test (foo) VALUES (@param)&#039;;
    db.AddParamText(&#039;@param&#039;, &#039;bar&#039;);
    db.ExecSQL(sql);
  finally
    db.Free;
  end;
end;
&lt;/code&gt;

I would expect that the INSERT command is successful, but I recieve an error message stating a violation of the CHECK constraint. A direct INSERT command without a parameter works as expected:

&lt;code&gt;
    sql := &#039;INSERT INTO test (foo) VALUES (&#039;&#039;bar&#039;&#039;)&#039;;
&lt;/code&gt;

I am using Delphi XE 2 and Sqlite 3.7.10.

Dieter</description>
		<content:encoded><![CDATA[<p>I encountered an unexpected &#8220;constraint failed&#8221; error when using a parameterized INSERT command. Here is a minimal code example:</p>
<p><code><br />
procedure Test(const F: TFilename);<br />
var<br />
  db: TSQLiteDatabase;<br />
  sql: string;<br />
begin<br />
  db := TSQLiteDatabase.Create(F);<br />
  try<br />
    sql := 'CREATE TABLE test ( foo TEXT NOT NULL, CHECK (foo = ''bar'') )';<br />
    db.ExecSQL(sql);<br />
    sql := 'INSERT INTO test (foo) VALUES (@param)';<br />
    db.AddParamText('@param', 'bar');<br />
    db.ExecSQL(sql);<br />
  finally<br />
    db.Free;<br />
  end;<br />
end;<br />
</code></p>
<p>I would expect that the INSERT command is successful, but I recieve an error message stating a violation of the CHECK constraint. A direct INSERT command without a parameter works as expected:</p>
<p><code><br />
    sql := 'INSERT INTO test (foo) VALUES (''bar'')';<br />
</code></p>
<p>I am using Delphi XE 2 and Sqlite 3.7.10.</p>
<p>Dieter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Olle</title>
		<link>http://www.itwriting.com/blog/articles/a-simple-delphi-wrapper-for-sqlite-3/comment-page-3#comment-877020</link>
		<dc:creator>Olle</dc:creator>
		<pubDate>Wed, 09 Nov 2011 13:26:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.itwriting.com/blog/?page_id=659#comment-877020</guid>
		<description>Hi,
I&#039;m using the wrapper and I think I have spotted an error.
When the database is locked and I call TSqliteTable.Create the database returns SQLITE_BUSY.
But the code here raises en exception with the text &#039;Could not prepare SQL statement&#039;. I have tried to call TSQLiteDatabase.RaiseError instead and that gives a proper message including the error code indicating that the database is in fact locked!
Can you confirm my view (or tell me what I don&#039;t understand!)

Olle</description>
		<content:encoded><![CDATA[<p>Hi,<br />
I&#8217;m using the wrapper and I think I have spotted an error.<br />
When the database is locked and I call TSqliteTable.Create the database returns SQLITE_BUSY.<br />
But the code here raises en exception with the text &#8216;Could not prepare SQL statement&#8217;. I have tried to call TSQLiteDatabase.RaiseError instead and that gives a proper message including the error code indicating that the database is in fact locked!<br />
Can you confirm my view (or tell me what I don&#8217;t understand!)</p>
<p>Olle</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tim</title>
		<link>http://www.itwriting.com/blog/articles/a-simple-delphi-wrapper-for-sqlite-3/comment-page-3#comment-828675</link>
		<dc:creator>tim</dc:creator>
		<pubDate>Fri, 14 Oct 2011 09:17:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.itwriting.com/blog/?page_id=659#comment-828675</guid>
		<description>@Mops see:

http://www.sqlite.org/faq.html#q6

That said, I really have not thought about this issue on the Delphi side.

Tim</description>
		<content:encoded><![CDATA[<p>@Mops see:</p>
<p><a href="http://www.sqlite.org/faq.html#q6" rel="nofollow">http://www.sqlite.org/faq.html#q6</a></p>
<p>That said, I really have not thought about this issue on the Delphi side.</p>
<p>Tim</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mops</title>
		<link>http://www.itwriting.com/blog/articles/a-simple-delphi-wrapper-for-sqlite-3/comment-page-3#comment-828558</link>
		<dc:creator>Mops</dc:creator>
		<pubDate>Fri, 14 Oct 2011 07:45:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.itwriting.com/blog/?page_id=659#comment-828558</guid>
		<description>Hi,
I&#039;m using this wrapper and I like it. But what about multiuser access?
What&#039;s happens if I will use one DB file by 2 threads?</description>
		<content:encoded><![CDATA[<p>Hi,<br />
I&#8217;m using this wrapper and I like it. But what about multiuser access?<br />
What&#8217;s happens if I will use one DB file by 2 threads?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steven</title>
		<link>http://www.itwriting.com/blog/articles/a-simple-delphi-wrapper-for-sqlite-3/comment-page-3#comment-821080</link>
		<dc:creator>Steven</dc:creator>
		<pubDate>Sun, 09 Oct 2011 18:51:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.itwriting.com/blog/?page_id=659#comment-821080</guid>
		<description>Tim,

Thanks so much for your help.
Your fix solved the problem.

I was making a wrong assumption about reusing the TSqliteTable object. 
Now that you’ve pointed it out it seem pretty obvious. 

Apologies about missing your email.

Best regards,

Steven Brenner</description>
		<content:encoded><![CDATA[<p>Tim,</p>
<p>Thanks so much for your help.<br />
Your fix solved the problem.</p>
<p>I was making a wrong assumption about reusing the TSqliteTable object.<br />
Now that you’ve pointed it out it seem pretty obvious. </p>
<p>Apologies about missing your email.</p>
<p>Best regards,</p>
<p>Steven Brenner</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tim</title>
		<link>http://www.itwriting.com/blog/articles/a-simple-delphi-wrapper-for-sqlite-3/comment-page-3#comment-820764</link>
		<dc:creator>tim</dc:creator>
		<pubDate>Sun, 09 Oct 2011 13:20:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.itwriting.com/blog/?page_id=659#comment-820764</guid>
		<description>Did you get my email? It&#039;s in the routine LoadDB

procedure TmmCAT_SQLiteDB.LoadDB();
var
  sl3tbl: TSqliteTable;
  sTmp :string;
begin
  if fDBsLoaded then
    Exit;

  fsldb := TSQLiteDatabase.Create(fDBFilePath);
  CreateTables;

  try
    sl3tbl := fsldb.GetTable(&#039;SELECT * FROM &#039; + cTblCategories);
    fNumCatsDefined := sl3tbl.Count;

    //tim added to fix leak
    sl3tbl.Free;

    sl3tbl := fsldb.GetTable(&#039;SELECT * FROM &#039; + cTblStats + &#039; WHERE SType = &quot;PRIMARY&quot;&#039;);

    fLUPDate := 0;
    if sl3tbl.Count = 0 then
      Exit;

    sl3tbl.MoveFirst;
    try
      sTmp := sl3tbl.FieldAsString(sl3tbl.FieldIndex[&#039;LUPDate&#039;]);
      fLUPDate := StrToFloat(sTmp);
    except
     Exit;
    end;

  finally
    sl3tbl.Free;
  end;
  fDBsLoaded := True;
end;</description>
		<content:encoded><![CDATA[<p>Did you get my email? It&#8217;s in the routine LoadDB</p>
<p>procedure TmmCAT_SQLiteDB.LoadDB();<br />
var<br />
  sl3tbl: TSqliteTable;<br />
  sTmp :string;<br />
begin<br />
  if fDBsLoaded then<br />
    Exit;</p>
<p>  fsldb := TSQLiteDatabase.Create(fDBFilePath);<br />
  CreateTables;</p>
<p>  try<br />
    sl3tbl := fsldb.GetTable(&#8216;SELECT * FROM &#8216; + cTblCategories);<br />
    fNumCatsDefined := sl3tbl.Count;</p>
<p>    //tim added to fix leak<br />
    sl3tbl.Free;</p>
<p>    sl3tbl := fsldb.GetTable(&#8216;SELECT * FROM &#8216; + cTblStats + &#8216; WHERE SType = &#8220;PRIMARY&#8221;&#8216;);</p>
<p>    fLUPDate := 0;<br />
    if sl3tbl.Count = 0 then<br />
      Exit;</p>
<p>    sl3tbl.MoveFirst;<br />
    try<br />
      sTmp := sl3tbl.FieldAsString(sl3tbl.FieldIndex['LUPDate']);<br />
      fLUPDate := StrToFloat(sTmp);<br />
    except<br />
     Exit;<br />
    end;</p>
<p>  finally<br />
    sl3tbl.Free;<br />
  end;<br />
  fDBsLoaded := True;<br />
end;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steven</title>
		<link>http://www.itwriting.com/blog/articles/a-simple-delphi-wrapper-for-sqlite-3/comment-page-3#comment-820618</link>
		<dc:creator>Steven</dc:creator>
		<pubDate>Sun, 09 Oct 2011 11:11:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.itwriting.com/blog/?page_id=659#comment-820618</guid>
		<description>Hi Tim,

Appreciate you checking it out.

Frankly I&#039;m stumped.
There are 4 procedures in the demo where I&#039;m creating a TSqliteTable table and I&#039;m freeing the table on each of those 4 areas before leaving the procedure.
It must be in front of my face and I&#039;m just not seeing it.


procedure TmmCAT_SQLiteDB.BackupCats;
var
  sl3tbl: TSqliteTable;
...
begin
  fsldb.execsql(&#039;DROP TABLE IF EXISTS &#039; + cTblCatBU);
  CreateTable_CATBU;

  try
    sl3tbl := fsldb.GetTable(&#039;SELECT * FROM &#039; + cTblCategories);
    ....
    ....
  finally
    sl3tbl.Free;
  end;
end;

Sorry to be such a bother.</description>
		<content:encoded><![CDATA[<p>Hi Tim,</p>
<p>Appreciate you checking it out.</p>
<p>Frankly I&#8217;m stumped.<br />
There are 4 procedures in the demo where I&#8217;m creating a TSqliteTable table and I&#8217;m freeing the table on each of those 4 areas before leaving the procedure.<br />
It must be in front of my face and I&#8217;m just not seeing it.</p>
<p>procedure TmmCAT_SQLiteDB.BackupCats;<br />
var<br />
  sl3tbl: TSqliteTable;<br />
&#8230;<br />
begin<br />
  fsldb.execsql(&#8216;DROP TABLE IF EXISTS &#8216; + cTblCatBU);<br />
  CreateTable_CATBU;</p>
<p>  try<br />
    sl3tbl := fsldb.GetTable(&#8216;SELECT * FROM &#8216; + cTblCategories);<br />
    &#8230;.<br />
    &#8230;.<br />
  finally<br />
    sl3tbl.Free;<br />
  end;<br />
end;</p>
<p>Sorry to be such a bother.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tim</title>
		<link>http://www.itwriting.com/blog/articles/a-simple-delphi-wrapper-for-sqlite-3/comment-page-3#comment-820512</link>
		<dc:creator>tim</dc:creator>
		<pubDate>Sun, 09 Oct 2011 09:31:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.itwriting.com/blog/?page_id=659#comment-820512</guid>
		<description>Steven

Whenever you create a TSqliteTable you have to free it. I found one instance in your code where this is not done. Then the project runs without leaks for me (I don&#039;t have Eureka but using ReportMemoryLeaksOnShutdown).

Tim</description>
		<content:encoded><![CDATA[<p>Steven</p>
<p>Whenever you create a TSqliteTable you have to free it. I found one instance in your code where this is not done. Then the project runs without leaks for me (I don&#8217;t have Eureka but using ReportMemoryLeaksOnShutdown).</p>
<p>Tim</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steven</title>
		<link>http://www.itwriting.com/blog/articles/a-simple-delphi-wrapper-for-sqlite-3/comment-page-3#comment-820461</link>
		<dc:creator>Steven</dc:creator>
		<pubDate>Sun, 09 Oct 2011 08:37:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.itwriting.com/blog/?page_id=659#comment-820461</guid>
		<description>Looks like the email was being rejected because of the attachment.
I put a zip containing the demo file package on one my websites and sent you an email with a link so that you can download it.

Best regards,
...Steven</description>
		<content:encoded><![CDATA[<p>Looks like the email was being rejected because of the attachment.<br />
I put a zip containing the demo file package on one my websites and sent you an email with a link so that you can download it.</p>
<p>Best regards,<br />
&#8230;Steven</p>
]]></content:encoded>
	</item>
</channel>
</rss>

