blob: 4c0e4e4ae948cf3440e7608ea7b1cdc238b01c05 (
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
table t1 : {A : int, B : string, C : float, D : bool}
fun display (q : sql_query [T1 = [A = int, B = string, C = float, D = bool]] []) =
s <- query q
(fn fs _ => return (Some fs.T1))
None;
return <html><body>
{case s of
None => cdata "Row not found."
| Some s =>
<body>
A: {cdata (show _ s.A)}<br/>
B: {cdata (show _ s.B)}<br/>
C: {cdata (show _ s.C)}<br/>
D: {cdata (show _ s.D)}<br/>
</body>}
</body></html>
fun lookupA (inp : {A : string}) =
display (SELECT * FROM t1 WHERE t1.A = {readError _ inp.A})
fun lookupB (inp : {B : string}) =
display (SELECT * FROM t1 WHERE t1.B = {inp.B})
fun lookupC (inp : {C : string}) =
display (SELECT * FROM t1 WHERE t1.C = {readError _ inp.C})
fun lookupD (inp : {D : string}) =
display (SELECT * FROM t1 WHERE t1.D = {readError _ inp.D})
fun main () : transaction page = return <html><body>
<lform>
A: <textbox{#A}/>
<submit action={lookupA}/>
</lform>
<lform>
B: <textbox{#B}/>
<submit action={lookupB}/>
</lform>
<lform>
C: <textbox{#C}/>
<submit action={lookupC}/>
</lform>
<lform>
D: <textbox{#D}/>
<submit action={lookupD}/>
</lform>
</body></html>
|