annotate demo/tree.ur @ 713:baaae037e7f6

Retry failed record summary unifications at the end, in hopes that more has been learned
author Adam Chlipala <adamc@hcoop.net>
date Thu, 09 Apr 2009 14:59:29 -0400
parents 1a317a707d71
children 1db127b245ed
rev   line source
adamc@471 1 sequence s
adamc@469 2 table t : { Id : int, Parent : option int, Nam : string }
adamc@708 3 PRIMARY KEY Id
adamc@469 4
adamc@469 5 open TreeFun.Make(struct
adamc@469 6 val tab = t
adamc@469 7 end)
adamc@469 8
adamc@469 9 fun row r = <xml>
adamc@471 10 #{[r.Id]}: {[r.Nam]} <a link={del r.Id}>[Delete]</a>
adamc@471 11
adamc@471 12 <form>
adamc@471 13 Add child: <textbox{#Nam}/> <submit action={add (Some r.Id)}/>
adamc@471 14 </form>
adamc@469 15 </xml>
adamc@469 16
adamc@471 17 and main () =
adamc@469 18 xml <- tree row None;
adamc@469 19 return <xml><body>
adamc@469 20 {xml}
adamc@471 21
adamc@471 22 <form>
adamc@471 23 Add a top-level node: <textbox{#Nam}/> <submit action={add None}/>
adamc@471 24 </form>
adamc@469 25 </body></xml>
adamc@471 26
adamc@471 27 and add parent r =
adamc@471 28 id <- nextval s;
adamc@471 29 dml (INSERT INTO t (Id, Parent, Nam) VALUES ({[id]}, {[parent]}, {[r.Nam]}));
adamc@471 30 main ()
adamc@471 31
adamc@471 32 and del id =
adamc@471 33 dml (DELETE FROM t WHERE Id = {[id]});
adamc@471 34 main ()