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 | 4f288849df2bb1a5a1d9d6f6ec9537badd82b6ab (patch) | |
tree | d20dcbe8aec266976ec07b31a5e11e75162f4fdf /tests/blob.ur | |
parent | 38507c697c6b5f277cabc5eb61afff14ea02da07 (diff) |
Reading blobs from the database
Diffstat (limited to 'tests/blob.ur')
-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> |