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