view 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 source
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/>*)