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 => {[r.T.Id]} {[r.T.Nam]} {case r.T.Parent of None => NULL | Some id => {[id]}} ); return {list}
Id Name Parent
Id:
Name:
Parent:
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 ()