adamc@743: sequence s
adamc@743: table t : { Id : int, Data : option blob, Typ : string }
adamc@743:
adamc@743: fun view id =
adamc@743: r <- oneRow (SELECT t.Data, t.Typ FROM t WHERE t.Id = {[id]});
adamc@743: case r.T.Data of
adamc@743: None => return This one's empty.
adamc@743: | Some data => returnBlob data (blessMime r.T.Typ)
adamc@743:
adamc@743: fun save r =
adamc@743: id <- nextval s;
adamc@743: dml (INSERT INTO t (Id, Data, Typ)
adamc@743: VALUES ({[id]}, {[Some (fileData r.Data)]}, {[fileMimeType r.Data]}));
adamc@743: main ()
adamc@743:
adamc@743: and saveEmpty () =
adamc@743: id <- nextval s;
adamc@743: dml (INSERT INTO t (Id, Data, Typ)
adamc@743: VALUES ({[id]}, {[None]}, "bogus"));
adamc@743: main ()
adamc@743:
adamc@743: and main () =
adamc@743: ls <- queryX (SELECT t.Id FROM t)
adamc@743: (fn r => {[r.T.Id]});
adamc@743: return
adamc@743: {ls}
adamc@743:
adamc@743:
adamc@743:
adamc@743:
adamc@743:
adamc@743:
adamc@743: