adamc@1204: type fruit = int adamc@1204: table fruit : { Id : fruit, Nam : string, Weight : float, Secret : string } adamc@1204: PRIMARY KEY Id, adamc@1204: CONSTRAINT Nam UNIQUE Nam adamc@1204: adamc@1204: type order = int adamc@1204: table order : { Id : order, Fruit : fruit, Qty : int, Code : int } adamc@1204: PRIMARY KEY Id, adamc@1204: CONSTRAINT Fruit FOREIGN KEY Fruit REFERENCES fruit(Id) adamc@1199: adamc@1205: policy query_policy (SELECT fruit.Id, fruit.Nam, fruit.Weight adamc@1205: FROM fruit) adamc@1205: policy query_policy (SELECT order.Id, order.Fruit, order.Qty adamc@1205: FROM order, fruit adamc@1206: WHERE order.Fruit = fruit.Id adamc@1206: AND order.Qty = 13) adamc@1200: adamc@1200: fun main () = adamc@1204: x1 <- queryX (SELECT fruit.Id, fruit.Nam adamc@1204: FROM fruit) adamc@1204: (fn x =>
  • {[x.Fruit.Id]}: {[x.Fruit.Nam]}
  • ); adamc@1204: adamc@1204: x2 <- queryX (SELECT fruit.Nam, order.Qty adamc@1204: FROM fruit, order adamc@1206: WHERE fruit.Id = order.Fruit adamc@1206: AND order.Qty = 13) adamc@1204: (fn x =>
  • {[x.Fruit.Nam]}: {[x.Order.Qty]}
  • ); adamc@1200: adamc@1200: return adamc@1204: adamc@1204: adamc@1200: