# HG changeset patch # User Adam Chlipala # Date 1236712643 14400 # Node ID 96ebc6bdb5a0c838000267c26d56541cd3c6101c # Parent 3c6d535d3d8bd76ffcc07bb69ce417ac729541ac Batch example diff -r 3c6d535d3d8b -r 96ebc6bdb5a0 demo/batch.ur --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demo/batch.ur Tue Mar 10 15:17:23 2009 -0400 @@ -0,0 +1,80 @@ +datatype list t = Nil | Cons of t * list t + +table t : {Id : int, A : string} + +fun allRows () = + query (SELECT * FROM t) + (fn r acc => return (Cons ((r.T.Id, r.T.A), acc))) + Nil + +fun doBatch ls = + case ls of + Nil => return () + | Cons ((id, a), ls') => + dml (INSERT INTO t (Id, A) VALUES ({[id]}, {[a]})); + doBatch ls' + +fun del id = + dml (DELETE FROM t WHERE t.Id = {[id]}) + +fun show withDel lss = + let + fun show' ls = + case ls of + Nil => + | Cons ((id, a), ls) => + {[id]} {[a]} {if withDel then +