adamc@773: table t : { Id : int, Nam : string, Parent : option int }
adamc@773: PRIMARY KEY Id,
adamc@773: CONSTRAINT Nam UNIQUE Nam,
adamc@773: CONSTRAINT Id CHECK Id >= 0,
adamc@773: CONSTRAINT Parent FOREIGN KEY Parent REFERENCES t(Id)
adamc@773:
adamc@773: fun main () =
adamc@773: list <- queryX (SELECT * FROM t)
adamc@773: (fn r =>
adamc@773:
{[r.T.Id]}
adamc@773:
{[r.T.Nam]}
adamc@773:
{case r.T.Parent of
adamc@773: None => NULL
adamc@773: | Some id => {[id]}}
adamc@773:
);
adamc@773: return
adamc@773:
adamc@773:
Id
Name
Parent
adamc@773: {list}
adamc@773:
adamc@773:
adamc@773:
adamc@773:
adamc@773:
adamc@773: and add r =
adamc@773: dml (INSERT INTO t (Id, Nam, Parent)
adamc@773: VALUES ({[readError r.Id]}, {[r.Nam]},
adamc@773: {[case r.Parent of
adamc@773: "" => None
adamc@773: | s => Some (readError s)]}));
adamc@773: main ()