sql samples
[sqlgg.git] / tables.ml
blob5a8942f8c8f4c47e6facaca6991e305bf8b28805
1 (** Global list of tables *)
3 open Printf
5 type table = RA.table
7 let all : table list ref = ref []
9 (** @raise Error when no such table *)
10 let get_from tables name =
11 try
12 List.find (fun (n,_) -> n = name) tables
13 with Not_found -> failwith (sprintf "no such table %s" name)
15 let get name = get_from !all name
16 let get_scheme name = snd (get name)
18 let add v =
19 let (name,scheme) = v in
20 match List.find_all (fun (n,_) -> n = name) !all with
21 | [] -> all := v :: !all
22 | _ -> failwith (sprintf "table %s already exists" name)
24 let print () = List.iter RA.print_table !all