annotate caching-tests/test.ur @ 2228:25c94de06e3c

New mouse events oncontextmenu, onmouseenter, and onmouseleave.
author Ziv Scully <ziv@mit.edu>
date Tue, 07 Apr 2015 14:18:53 -0400
parents 6262dabc08d6
children 2f7ed04332a0
rev   line source
ziv@2213 1 table tab : {Id : int, Val : int} PRIMARY KEY Id
ziv@2203 2
ziv@2213 3 fun cache id =
ziv@2225 4 res <- oneOrNoRows (SELECT tab.Val
ziv@2225 5 FROM tab
ziv@2225 6 WHERE tab.Id = {[id]});
ziv@2204 7 return <xml><body>
ziv@2213 8 Reading {[id]}.
ziv@2204 9 {case res of
ziv@2213 10 None => <xml>?</xml>
ziv@2213 11 | Some row => <xml>{[row.Tab.Val]}</xml>}
ziv@2204 12 </body></xml>
ziv@2203 13
ziv@2213 14 fun flush id =
ziv@2225 15 res <- oneOrNoRows (SELECT tab.Val
ziv@2225 16 FROM tab
ziv@2225 17 WHERE tab.Id = {[id]});
ziv@2221 18 (case res of
ziv@2225 19 None => dml (INSERT INTO tab (Id, Val)
ziv@2225 20 VALUES ({[id]}, 0))
ziv@2225 21 | Some row => dml (UPDATE tab
ziv@2225 22 SET Val = {[row.Tab.Val + 1]}
ziv@2225 23 WHERE Id = {[id]}));
ziv@2204 24 return <xml><body>
ziv@2204 25 {case res of
ziv@2213 26 None => <xml>Initialized {[id]}!</xml>
ziv@2213 27 | Some row => <xml>Incremented {[id]}!</xml>}
ziv@2204 28 </body></xml>