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 => ({[r.T.A]}, {[r.T.B]}))) fun hard id = queryX' (SELECT t.B AS N FROM t WHERE t.A = {[id]}) (fn r => b <- hard r.N; return ({[id]}, {[r.N]}); {b}) fun doit () = init (); b1 <- easy (); b2 <- hard 1; return {b1}
{b2}
fun main () = return