[MLton-commit] r5252
Wesley Terpstra
wesley at mlton.org
Sat Feb 17 18:08:46 PST 2007
put some data in for people to see
----------------------------------------------------------------------
U mltonlib/trunk/ca/terpstra/sqlite3-sml/demo.sml
----------------------------------------------------------------------
Modified: mltonlib/trunk/ca/terpstra/sqlite3-sml/demo.sml
===================================================================
--- mltonlib/trunk/ca/terpstra/sqlite3-sml/demo.sml 2007-02-18 02:02:23 UTC (rev 5251)
+++ mltonlib/trunk/ca/terpstra/sqlite3-sml/demo.sml 2007-02-18 02:08:45 UTC (rev 5252)
@@ -37,12 +37,14 @@
end
(* Create the base table needed for Q1 *)
-val () = SQL.simpleExec (db, "create table peanuts (x text, y integer);")
+val () = SQL.simpleExec (db, "create table if not exists \
+ \peanuts (x text, y integer);")
(* Create some queries that have input / output parameters *)
local
open SQL.Query
in
+ val Q0 = prepare db "insert into peanuts values ("iS", "iI");" $
val Q1 = prepare db "select x, y from peanuts\n\
\where y="iI" or x="iS";" oS oI $
handle SQL.Error x => die x
@@ -67,6 +69,12 @@
fun dumpP (s & i) = print (s ^ " " ^ Int.toString i ^ "\n")
fun dumpV v = (Vector.app (fn s => print (s ^ " ")) v; print "\n")
+(* Put some entries into the peanut table *)
+val () = SQL.exec Q0 ("hello" & 6)
+val () = SQL.exec Q0 ("hi" & 6)
+val () = SQL.exec Q0 ("boom" & 4)
+val () = SQL.exec Q0 ("smurf" & 2)
+
(* Run the prepared queries and print the results *)
val () = SQL.app dumpP Q1 (4 & "hi") handle SQL.Error x => die x
val () = SQL.app dumpV Q2 () handle SQL.Error x => die x
More information about the MLton-commit
mailing list