diff tests/sql_option.ur @ 467:3f1b9231a37b

Inserted a NULL value
author Adam Chlipala <adamc@hcoop.net>
date Thu, 06 Nov 2008 15:37:38 -0500
parents
children 4efab85405be
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/sql_option.ur	Thu Nov 06 15:37:38 2008 -0500
@@ -0,0 +1,22 @@
+table t : { O : option int }
+
+fun addNull () =
+    dml (INSERT INTO t (O) VALUES (NULL));
+    return <xml>Done</xml>
+
+(*fun add42 () =
+    dml (INSERT INTO t (O) VALUES (42));
+    return <xml>Done</xml>*)
+
+fun main () : transaction page =
+    xml <- queryX (SELECT * FROM t)
+                  (fn r => case r.T.O of
+                               None => <xml>Nada<br/></xml>
+                             | Some n => <xml>Num: {[n]}<br/></xml>);
+    return <xml><body>
+      {xml}
+
+      <a link={addNull ()}>Add a null</a><br/>
+    </body></xml>
+
+(*      <a link={add42 ()}>Add a 42</a><br/>*)