我正在尝试在我的应用程序中使用Pgocaml进行数据库交互。
这是我要编译的文件:
let () =
let dbh = PGOCaml.connect () in
let insert name salary email =
PGSQL(dbh) "insert into employees (name, salary, email) values ($name, $salary, $?email)"
in
insert "Ann" 10_000_l None;
insert "Bob" 45_000_l None;
insert "Jim" 20_000_l None;
insert "Mary" 30_000_l (Some "mary@example.com");
let print_row (id, name, salary, email) =
let email = match email with Some email -> email | None -> " -"
in Printf.printf "%ld %S %ld %S\n" id name salary email in
let rows =
PGSQL(dbh) "select id, name, salary, email from employees"
in List.iter print_row rows;
PGOCaml.close dbh
这就是我试图编译它的方式:
ocamlbuild -use-ocamlfind -pkg pgocaml pgex.native
这是我得到的错误:
+ ocamlfind ocamldep -package pgocaml -modules pgex.ml > pgex.ml.depends
File "pgex.ml", line 4, characters 19-97:
Error: Syntax error
Command exited with code 2.
为什么我会收到此错误?
提前致谢!