view demo/constraints.ur @ 1892:907a82a44f01

Add missing inter-library dependencies This is needed, at least on recent Ubuntu, to fix these linker errors when compiling any Ur/Web application: liburweb.so: undefined reference to `lround' liburweb.so: undefined reference to `ceil' liburweb.so: undefined reference to `RAND_bytes' liburweb.so: undefined reference to `DES_fcrypt' liburweb.so: undefined reference to `SHA256_Init' liburweb.so: undefined reference to `SHA256_Final' liburweb.so: undefined reference to `SHA256_Update' Signed-off-by: Anders Kaseorg <andersk@mit.edu> --- src/c/Makefile.am | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
author Anders Kaseorg <andersk@mit.edu>
date Thu, 21 Nov 2013 14:32:11 -0500
parents 74a090ff296e
children
line wrap: on
line source
table t : { Id : int, Nam : string, Parent : option int }
  PRIMARY KEY Id,
  CONSTRAINT Nam UNIQUE Nam,
  CONSTRAINT Id CHECK Id >= 0,
  CONSTRAINT Parent FOREIGN KEY Parent REFERENCES t(Id)

fun main () =
    list <- queryX (SELECT * FROM t)
            (fn r => <xml><tr>
              <td>{[r.T.Id]}</td>
              <td>{[r.T.Nam]}</td>
              <td>{case r.T.Parent of
                       None => <xml>NULL</xml>
                     | Some id => <xml>{[id]}</xml>}</td>
            </tr></xml>);
    return <xml><body>
      <table>
        <tr> <th>Id</th> <th>Name</th> <th>Parent</th> </tr>
        {list}
      </table>

      <form>
        <table>
          <tr> <th>Id:</th> <td><textbox{#Id}/></td> </tr>
          <tr> <th>Name:</th> <td><textbox{#Nam}/></td> </tr>
          <tr> <th>Parent:</th> <td><textbox{#Parent}/></td> </tr>
          <tr> <th/> <td><submit action={add}/></td> </tr>
        </table>
      </form>
    </body></xml>

and add r =
    dml (INSERT INTO t (Id, Nam, Parent)
           VALUES ({[readError r.Id]}, {[r.Nam]},
               {[case r.Parent of
                   "" => None
                 | s => Some (readError s)]}));
    main ()