#include ffs.cam ;N sql.cam - rudimentary SQL-like operations on top of ffs.cam ;A J.N. Oliveira (jno@di.uminho.pt) ;D ; This is a CAMILA library for very rudimentary SQL-like operations ; whose semantics are specified on top of ffs.cam. ; This is expected to evolve towards realistic CAMILA animation of a ; formal semantics of mSQL. ; Last Update: 1999.11.11 ;E FUNC sqlUpdate(c1:A,ue:B->B,c2:A,se:A->2,ffs:(A->B)-set):(A->B)-set ; ; sqlUpdate(c1,ue,c2,se,ffs) corresponds to the outcome of ; the SQL command "UPDATE ffs SET c1=ue WHERE se(c2)", ; where the update expression ue and the selection predicate se ; are provided as lambda-expressions. ; RETURN let (st= { t | t <- ffs : se(t[c2]) }, _=princ("[ ", card(st), " object(s) selected ]\n"), rt= ffs - st, update = lambda(t). let (v=t[c1]) in t + [ c1 -> ue(v) ]) in rt U update-set(st); FUNC sqlSelect(cs:A-set,c:A,se:B->2,ffs:(A->B)-set):(A->B)-set ; ; sqlSelect(cs,c,se,ffs) specifies the outcome of ; SQL command " SELECT cs FROM ffs WHERE se(c) ", ; where the selection predicate se is provided as a lambda-expression. ; RETURN let (st= { t | t <- ffs : se(t[c]) }, _=princ("[ ", card(st), " object(s) selected ]\n"), project = lambda(t). t / cs) in project-set(st); FUNC sqlDelete(c:A,se:A->2,ffs:(A->B)-set):(A->B)-set ; ; sqlDelete(c,se,ffs) specifies the outcome of ; SQL command "DELETE FROM ffs WHERE se(c) ", ; where the selection predicate se is provided as a lambda-expression. ; RETURN let (st= { t | t <- ffs : ~(se(t[c])) }, _=princ("[ ", card(ffs-st), " object(s) deleted ]\n")) in st;