From 74f41e27e7940eec0320f7358f030185e8c2c2e0 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Tue, 10 Mar 2009 15:17:23 -0400 Subject: Batch example --- demo/batch.ur | 80 +++++++++ demo/batch.urp | 3 + demo/batch.urs | 1 + demo/increment.urp | 1 - demo/prose | 4 + lib/js/urweb.js | 25 ++- src/jscomp.sml | 6 +- src/mono_opt.sml | 2 + src/rpcify.sml | 506 +++++++++++++++++++++++++++++------------------------ 9 files changed, 395 insertions(+), 233 deletions(-) create mode 100644 demo/batch.ur create mode 100644 demo/batch.urp create mode 100644 demo/batch.urs diff --git a/demo/batch.ur b/demo/batch.ur new file mode 100644 index 00000000..454ff691 --- /dev/null +++ b/demo/batch.ur @@ -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 +