Mercurial > urweb
annotate demo/sql.ur @ 537:a4a7cd341a1b
Signature compatibility
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sat, 29 Nov 2008 13:50:53 -0500 |
parents | 20fab0e96217 |
children | 1a317a707d71 |
rev | line source |
---|---|
adamc@410 | 1 table t : { A : int, B : float, C : string, D : bool } |
adamc@410 | 2 |
adamc@410 | 3 fun list () = |
adamc@410 | 4 rows <- queryX (SELECT * FROM t) |
adamc@410 | 5 (fn row => <xml><tr> |
adamc@410 | 6 <td>{[row.T.A]}</td> <td>{[row.T.B]}</td> <td>{[row.T.C]}</td> <td>{[row.T.D]}</td> |
adamc@410 | 7 <td><a link={delete row.T.A}>[delete]</a></td> |
adamc@410 | 8 </tr></xml>); |
adamc@410 | 9 return <xml> |
adamc@410 | 10 <table border=1> |
adamc@410 | 11 <tr> <th>A</th> <th>B</th> <th>C</th> <th>D</th> </tr> |
adamc@410 | 12 {rows} |
adamc@410 | 13 </table> |
adamc@410 | 14 |
adamc@410 | 15 <br/><hr/><br/> |
adamc@410 | 16 |
adamc@410 | 17 <form> |
adamc@410 | 18 <table> |
adamc@410 | 19 <tr> <th>A:</th> <td><textbox{#A}/></td> </tr> |
adamc@410 | 20 <tr> <th>B:</th> <td><textbox{#B}/></td> </tr> |
adamc@410 | 21 <tr> <th>C:</th> <td><textbox{#C}/></td> </tr> |
adamc@410 | 22 <tr> <th>D:</th> <td><checkbox{#D}/></td> </tr> |
adamc@410 | 23 <tr> <th/> <td><submit action={add} value="Add Row"/></td> </tr> |
adamc@410 | 24 </table> |
adamc@410 | 25 </form> |
adamc@410 | 26 </xml> |
adamc@410 | 27 |
adamc@410 | 28 and add r = |
adamc@434 | 29 dml (INSERT INTO t (A, B, C, D) |
adamc@471 | 30 VALUES ({[readError r.A]}, {[readError r.B]}, {[r.C]}, {[r.D]})); |
adamc@410 | 31 xml <- list (); |
adamc@410 | 32 return <xml><body> |
adamc@410 | 33 <p>Row added.</p> |
adamc@410 | 34 |
adamc@410 | 35 {xml} |
adamc@410 | 36 </body></xml> |
adamc@410 | 37 |
adamc@410 | 38 and delete a = |
adamc@434 | 39 dml (DELETE FROM t |
adamc@471 | 40 WHERE t.A = {[a]}); |
adamc@410 | 41 xml <- list (); |
adamc@410 | 42 return <xml><body> |
adamc@410 | 43 <p>Row deleted.</p> |
adamc@410 | 44 |
adamc@410 | 45 {xml} |
adamc@410 | 46 </body></xml> |
adamc@410 | 47 |
adamc@410 | 48 fun main () = |
adamc@410 | 49 xml <- list (); |
adamc@410 | 50 return <xml><body> |
adamc@410 | 51 {xml} |
adamc@410 | 52 </body></xml> |