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
Id
Name
Parent
{list}
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 ()