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 This one's empty.
| 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 => {[r.T.Id]});
return
{ls}