annotate demo/tree.ur @ 687:a3ddf05fb3e3

On start-up, delete/nullify rows mentioning clients or channels
author Adam Chlipala <adamc@hcoop.net>
date Thu, 02 Apr 2009 11:42:26 -0400
parents 20fab0e96217
children 1a317a707d71
rev   line source
adamc@471 1 sequence s
adamc@469 2 table t : { Id : int, Parent : option int, Nam : string }
adamc@469 3
adamc@469 4 open TreeFun.Make(struct
adamc@469 5 val tab = t
adamc@469 6 end)
adamc@469 7
adamc@469 8 fun row r = <xml>
adamc@471 9 #{[r.Id]}: {[r.Nam]} <a link={del r.Id}>[Delete]</a>
adamc@471 10
adamc@471 11 <form>
adamc@471 12 Add child: <textbox{#Nam}/> <submit action={add (Some r.Id)}/>
adamc@471 13 </form>
adamc@469 14 </xml>
adamc@469 15
adamc@471 16 and main () =
adamc@469 17 xml <- tree row None;
adamc@469 18 return <xml><body>
adamc@469 19 {xml}
adamc@471 20
adamc@471 21 <form>
adamc@471 22 Add a top-level node: <textbox{#Nam}/> <submit action={add None}/>
adamc@471 23 </form>
adamc@469 24 </body></xml>
adamc@471 25
adamc@471 26 and add parent r =
adamc@471 27 id <- nextval s;
adamc@471 28 dml (INSERT INTO t (Id, Parent, Nam) VALUES ({[id]}, {[parent]}, {[r.Nam]}));
adamc@471 29 main ()
adamc@471 30
adamc@471 31 and del id =
adamc@471 32 dml (DELETE FROM t WHERE Id = {[id]});
adamc@471 33 main ()