view tests/nested.ur @ 1907:cb57ba73a61d

make uninstall: Uninstall types_cpp.h, urweb_cpp.h Signed-off-by: Anders Kaseorg <andersk@mit.edu> --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
author Anders Kaseorg <andersk@mit.edu>
date Fri, 22 Nov 2013 09:36:14 -0500
parents 8e9f2d247dba
children
line wrap: on
line source
table t : {A : int, B : int}

fun init () =
    dml (DELETE FROM t WHERE TRUE);
    dml (INSERT INTO t (A, B) VALUES (1, 2));
    dml (INSERT INTO t (A, B) VALUES (2, 3))

fun easy () =
    queryX' (SELECT MAX(t.A) AS M FROM t)
    (fn r =>
        queryX (SELECT * FROM t WHERE t.A = {[r.M]})
        (fn r => <xml>({[r.T.A]}, {[r.T.B]})</xml>))

fun hard id =
    queryX' (SELECT t.B AS N FROM t WHERE t.A = {[id]})
    (fn r =>
        b <- hard r.N;
        return <xml>({[id]}, {[r.N]}); {b}</xml>)

fun doit () =
    init ();
    b1 <- easy ();
    b2 <- hard 1;
    return <xml><body>
      {b1}<br/>
      {b2}
    </body></xml>

fun main () = return <xml><body><form><submit action={doit}/></form></body></xml>