Re: [Wrapl-discussion] Using SQLite?
Brought to you by:
rajamukherji
|
From: Raja M. <raj...@gm...> - 2008-08-16 08:42:55
|
The complete call is
db:exec(statement, function, userdata)
for each row of the result of executing statement, function(row, userdata)
is called, where row is a table of (column names, values).
To use prepared statements,
st <- db:prepare(statement)
returns a StatementT
st:bind(index, value)
binds value to the index-th parameter
st:step performs one step so you' d typically use
st <- db:prepare(statement);
REP (
WHEN st:step
IS Sqlite.DONE DO EXIT
IS Sqlite.ROW DO (
-- process row, using column_??? functions
)
IS Sqlite.ERROR DO -- handle error I guess
-- any other flags to handle
);
st:reset;
st:column_<type>(index)
returns the index-th column of the current result row from st as <type>,
where <type> is currently blob, double, int or text.
st:column_count
return the number of columns in the result row
st:column_name(index)
returns the name of index-th column
st:reset
resets the statement for another cycle
Although the interface works (the last time I checked, anyway), it does not
reclaim memory correctly. So over time there might be memory leakage. This
is on my TODO list.
Raja
2008/8/16 Jeremy Cowgar <je...@co...>
> How can I execute a query? I see exec, bind, column_text, etc... but not
> sure how to get at a StatementT to use step and column_text.
>
> MOD SqliteTest;
>
> IMP IO.Terminal USE Out;
> IMP DB.Sqlite;
>
> VAR db <- Sqlite.Open("testing.db");
>
> -- db:exec("SELECT * FROM abc", ?????);
>
> db:close();
>
> END SqliteTest.
>
>
> Thanks,
>
> Jeremy
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Wrapl-discussion mailing list
> Wra...@li...
> https://lists.sourceforge.net/lists/listinfo/wrapl-discussion
>
|