Can't make it work

Apr 5, 2011 at 6:48 PM


I get the test working, but when I copy the macros into my project it doesn't work. I am very sorry for being stupid, but clearly I have failed to do something. Please help.

Apr 5, 2011 at 7:16 PM


You'd have to describe your problem in a bit more detail. What error do you get?


Apr 5, 2011 at 7:17 PM

Found out the problem. It works when I have it in the same directory. It must be a path issue.

Apr 5, 2011 at 7:26 PM
Edited Apr 6, 2011 at 1:04 PM


Apr 15, 2011 at 4:54 PM


I have a database and it is populated nicely with various tables, but I cannot see an example of how to get a simple sum query to work. "SELECT SUM(ColName) WHERE OtherColName = x"  etc.. The closest seems to be printcolumns but that doesn't seem fit for purpose. 

The simple approaches I tried failed utterly and after a day of messing I was wondering if someone could help me. Sorry for being a moron in advance.

Apr 15, 2011 at 6:07 PM


It looks like you're not sure about the SQL language as used by SQLite. The complete query language for SQLite is documented here:

Your SUM query needs a table name, so it would go "SELECT SUM(ColName) FROM TableName WHERE OtherColName='xxx'".


The SQLiteXXXX functions defined in the SQLite module, match exactly a subset of the SQLite API that is documented here: and So for example SQLite3PrepareV2 matches exactly the SQLite function sqlite3_prepare_v2 documented here:

Now for your example, you could start with the TestSelect() function in the SQLite3Demo module in the distributed workbook. Instead of calling PrintColumns after the SQLite3Step you could access the result column directly be calling  

   mySum = SQLite3ColumnDouble(stmtHandle, 0).

If you're still stuck, write back with some details of what you are trying.


Apr 16, 2011 at 4:45 PM


I am now fully up and running. Many thanks for great help.


May 3, 2011 at 9:41 PM

OK, it has been wonderful, I am massively impressed. Now I am slightly stuck with PRAGMA. I want to return the col names for a table, but I can't seem to make the PRAGMA index_info(mytable) statement work. Can I do something like "SELECT FROM PRAGMA index_info(mytable);"? 

May 3, 2011 at 9:55 PM

Hi Ben,

I'd expect the PRAGMAs to work and return a result set when called just like that. But I think you are looking for PRAGMA index_list(table-name); and then for each named index you'd call PRAGMA index_info(index-name);. You seem to be trying index_info directly with the table name.

You could also download the SQLite3.exe command-line shell from the SQLite site: to experiment with the SQLite syntax in an interactive setting.