diff options
author | 2008-10-30 15:16:37 -0400 | |
---|---|---|
committer | 2008-10-30 15:16:37 -0400 | |
commit | d710cc7a5aa246763af96dfca57ec8a7a5a6fd37 (patch) | |
tree | fe9ae1798baecaadf006b54d792997b0fb2db54c /lib | |
parent | 5400696e2584c331c6fa6c9627a6c60d08327480 (diff) |
Time MIN/MAX
Diffstat (limited to 'lib')
-rw-r--r-- | lib/top.ur | 8 | ||||
-rw-r--r-- | lib/top.urs | 10 |
2 files changed, 18 insertions, 0 deletions
@@ -157,3 +157,11 @@ fun oneOrNoRows (tables ::: {{Type}}) (exps ::: {Type}) query q (fn fs _ => return (Some fs)) None + +fun oneRow (tables ::: {{Type}}) (exps ::: {Type}) + (q : sql_query tables exps) [tables ~ exps] = + o <- oneOrNoRows q; + return (case o of + None => error <xml>Query returned no rows</xml> + | Some r => r) + diff --git a/lib/top.urs b/lib/top.urs index 22cebb16..6e9dda4e 100644 --- a/lib/top.urs +++ b/lib/top.urs @@ -116,3 +116,13 @@ val oneOrNoRows : tables ::: {{Type}} -> exps ::: {Type} [[nm] ~ acc] => [nm = $fields] ++ acc) [] tables)) + +val oneRow : tables ::: {{Type}} -> exps ::: {Type} + -> sql_query tables exps + -> fn [tables ~ exps] => + transaction + $(exps + ++ fold (fn nm (fields :: {Type}) acc + [[nm] ~ acc] => + [nm = $fields] ++ acc) + [] tables) |