ziv@2290: table tab : {Id : int, Val : int} PRIMARY KEY Id
ziv@2290:
ziv@2290: fun check id =
ziv@2290: res <- oneOrNoRows (SELECT tab.Val FROM tab WHERE tab.Id = {[id]});
ziv@2290: return
ziv@2290: {case res of
ziv@2290: None => ?
ziv@2290: | Some row => {[row.Tab.Val]}}
ziv@2290:
ziv@2290:
ziv@2290: fun flush id =
ziv@2290: dml (UPDATE tab SET Val = Val + 1 WHERE Id = {[id]});
ziv@2290: return
ziv@2290: Changed {[id]}!
ziv@2290:
ziv@2290:
ziv@2290: fun main x y =
ziv@2290: r <- rand;
ziv@2290: let
ziv@2290: val id = r % x
ziv@2290: val doFlush = (r / x) % y = 0
ziv@2290: in
ziv@2290: if doFlush then flush id else check id
ziv@2290: end