diff options
author | 2008-10-21 18:44:52 -0400 | |
---|---|---|
committer | 2008-10-21 18:44:52 -0400 | |
commit | d66bb9f256db65e3487dec361a4a5a9d7ee238b0 (patch) | |
tree | 02a7bb0fa4faec1697c91fbc22c46014b3ff49c5 /demo/sql.ur | |
parent | d249f18f65213b5a198f39e254982293ecaa0e10 (diff) |
Sql demo
Diffstat (limited to 'demo/sql.ur')
-rw-r--r-- | demo/sql.ur | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/demo/sql.ur b/demo/sql.ur new file mode 100644 index 00000000..9e9effff --- /dev/null +++ b/demo/sql.ur @@ -0,0 +1,52 @@ +table t : { A : int, B : float, C : string, D : bool } + +fun list () = + rows <- queryX (SELECT * FROM t) + (fn row => <xml><tr> + <td>{[row.T.A]}</td> <td>{[row.T.B]}</td> <td>{[row.T.C]}</td> <td>{[row.T.D]}</td> + <td><a link={delete row.T.A}>[delete]</a></td> + </tr></xml>); + return <xml> + <table border=1> + <tr> <th>A</th> <th>B</th> <th>C</th> <th>D</th> </tr> + {rows} + </table> + + <br/><hr/><br/> + + <form> + <table> + <tr> <th>A:</th> <td><textbox{#A}/></td> </tr> + <tr> <th>B:</th> <td><textbox{#B}/></td> </tr> + <tr> <th>C:</th> <td><textbox{#C}/></td> </tr> + <tr> <th>D:</th> <td><checkbox{#D}/></td> </tr> + <tr> <th/> <td><submit action={add} value="Add Row"/></td> </tr> + </table> + </form> + </xml> + +and add r = + () <- dml (INSERT INTO t (A, B, C, D) + VALUES ({readError r.A}, {readError r.B}, {r.C}, {r.D})); + xml <- list (); + return <xml><body> + <p>Row added.</p> + + {xml} + </body></xml> + +and delete a = + () <- dml (DELETE FROM t + WHERE t.A = {a}); + xml <- list (); + return <xml><body> + <p>Row deleted.</p> + + {xml} + </body></xml> + +fun main () = + xml <- list (); + return <xml><body> + {xml} + </body></xml> |