adamc@880: table t : {A : int, B : int}
adamc@880:
adamc@880: fun init () =
adamc@880: dml (DELETE FROM t WHERE TRUE);
adamc@880: dml (INSERT INTO t (A, B) VALUES (1, 2));
adamc@880: dml (INSERT INTO t (A, B) VALUES (2, 3))
adamc@880:
adamc@880: fun easy () =
adamc@880: queryX' (SELECT MAX(t.A) AS M FROM t)
adamc@880: (fn r =>
adamc@880: queryX (SELECT * FROM t WHERE t.A = {[r.M]})
adamc@880: (fn r => ({[r.T.A]}, {[r.T.B]})))
adamc@880:
adamc@880: fun hard id =
adamc@880: queryX' (SELECT t.B AS N FROM t WHERE t.A = {[id]})
adamc@880: (fn r =>
adamc@880: b <- hard r.N;
adamc@880: return ({[id]}, {[r.N]}); {b})
adamc@880:
adamc@880: fun doit () =
adamc@880: init ();
adamc@880: b1 <- easy ();
adamc@880: b2 <- hard 1;
adamc@880: return
adamc@880: {b1}
adamc@880: {b2}
adamc@880:
adamc@880:
adamc@880: fun main () = return