summaryrefslogtreecommitdiff
path: root/demo/view.ur
blob: 0dcb42fa0cd0bf2f3847e0c495d791593b121eba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
table t : { A : int }
view v = SELECT t.A AS A FROM t WHERE t.A > 7

fun list [u] (_ : fieldsOf u [A = int]) (title : string) (x : u) : transaction xbody =
    xml <- queryX (SELECT * FROM x)
           (fn r : {X : {A : int}} => <xml><li>{[r.X.A]}</li></xml>);
    return <xml>
      <h2>{[title]}</h2>
      <ul>{xml}</ul>
    </xml>

fun main () =
    listT <- list "T" t;
    listV <- list "V" v;
    return <xml><body>
      {listT}
      {listV}
      <br/>

      <form>Insert: <textbox{#A}/> <submit action={ins}/></form>
    </body></xml>

and ins r =
    dml (INSERT INTO t (A) VALUES ({[readError r.A]}));
    main ()