diff options
author | Adam Chlipala <adamc@hcoop.net> | 2009-04-26 10:45:59 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2009-04-26 10:45:59 -0400 |
commit | 7bd2bc26389467f685958601cff2708751764515 (patch) | |
tree | d20dcbe8aec266976ec07b31a5e11e75162f4fdf /tests | |
parent | bc7a09d702e53faaa882bb7b2591abe68ff5648e (diff) |
Reading blobs from the database
Diffstat (limited to 'tests')
-rw-r--r-- | tests/blob.ur | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/tests/blob.ur b/tests/blob.ur index 2d58faae..ec683068 100644 --- a/tests/blob.ur +++ b/tests/blob.ur @@ -1,16 +1,27 @@ sequence s table t : { Id : int, Nam : option string, Data : blob, Desc : string, Typ : string } +fun view id = + r <- oneRow (SELECT t.Data, t.Typ FROM t WHERE t.Id = {[id]}); + returnBlob r.T.Data (blessMime r.T.Typ) + fun save r = id <- nextval s; dml (INSERT INTO t (Id, Nam, Data, Desc, Typ) VALUES ({[id]}, {[fileName r.Data]}, {[fileData r.Data]}, {[r.Desc]}, {[fileMimeType r.Data]})); main () -and main () = return <xml><body> - <form> - <textbox{#Desc}/> - <upload{#Data}/> - <submit action={save}/> - </form> -</body></xml> +and main () = + ls <- queryX (SELECT t.Id, t.Desc FROM t ORDER BY t.Desc) + (fn r => <xml><li><a link={view r.T.Id}>{[r.T.Desc]}</a></li></xml>); + return <xml><body> + {ls} + + <br/> + + <form> + <textbox{#Desc}/> + <upload{#Data}/> + <submit action={save}/> + </form> + </body></xml> |