comparison demo/outer.ur @ 777:87a7702d681d

outer demo
author Adam Chlipala <adamc@hcoop.net>
date Sun, 03 May 2009 14:57:33 -0400
parents
children
comparison
equal deleted inserted replaced
776:9f2555f06901 777:87a7702d681d
1 table t : { Id : int, B : string }
2 PRIMARY KEY Id
3
4 table u : { Id : int, Link : int, C : string, D : option float }
5 PRIMARY KEY Id,
6 CONSTRAINT Link FOREIGN KEY Link REFERENCES t(Id)
7
8 fun main () =
9 xml <- queryX (SELECT t.Id, t.B, u.Id, u.C, u.D
10 FROM t LEFT JOIN u ON t.Id = u.Link)
11 (fn r => <xml><tr>
12 <td>{[r.T.Id]}</td>
13 <td>{[r.T.B]}</td>
14 <td>{[r.U.Id]}</td>
15 <td>{[r.U.C]}</td>
16 <td>{[r.U.D]}</td>
17 </tr></xml>);
18 return <xml><body>
19 <table>{xml}</table>
20
21 <form>Insert into t: <textbox{#Id} size={5}/> <textbox{#B} size={5}/>
22 <submit action={addT}/></form>
23 <form>
24 Insert into u: <textbox{#Id} size={5}/> <textbox{#Link} size={5}/> <textbox{#C} size={5}/>
25 <textbox{#D} size={5}/> <submit action={addU}/>
26 </form>
27 </body></xml>
28
29 and addT r =
30 dml (INSERT INTO t (Id, B) VALUES ({[readError r.Id]}, {[r.B]}));
31 main ()
32
33 and addU r =
34 dml (INSERT INTO u (Id, Link, C, D) VALUES ({[readError r.Id]}, {[readError r.Link]}, {[r.C]}, {[readError r.D]}));
35 main ()