blob: 261ce2263d94c183515e05ba6a2c5ce183369272 (
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
|
sequence s
table t : { Id : int, Data : option blob, Typ : string }
fun view id =
r <- oneRow (SELECT t.Data, t.Typ FROM t WHERE t.Id = {[id]});
case r.T.Data of
None => return <xml>This one's empty.</xml>
| Some data => returnBlob data (blessMime r.T.Typ)
fun save r =
id <- nextval s;
dml (INSERT INTO t (Id, Data, Typ)
VALUES ({[id]}, {[Some (fileData r.Data)]}, {[fileMimeType r.Data]}));
main ()
and saveEmpty () =
id <- nextval s;
dml (INSERT INTO t (Id, Data, Typ)
VALUES ({[id]}, {[None]}, "bogus"));
main ()
and main () =
ls <- queryX (SELECT t.Id FROM t)
(fn r => <xml><li><a link={view r.T.Id}>{[r.T.Id]}</a></li></xml>);
return <xml><body>
{ls}
<br/>
<form>
<upload{#Data}/>
<submit action={save}/>
</form>
<form>
<submit action={saveEmpty}/>
</form>
</body></xml>
|