- let sth = dbh#prepare_cached
- "set constraints \"hosts_hostname_cn\" deferred" in
- sth#execute [];
- let sth = dbh#prepare_cached "update hosts set canonical_hostname = ?
- where id = ?" in
- sth#execute [`String canonical_hostname; `Int hostid];
- let sth = dbh#prepare_cached "delete from hostnames where hostid = ?" in
- sth#execute [`Int hostid];
- let sth = dbh#prepare_cached "insert into hostnames (hostid, name)
- values (?, ?)" in
- sth#execute [`Int hostid; `String canonical_hostname];
- List.iter (fun name ->
- sth#execute [`Int hostid; `String name]) hostnames;
+ PGSQL(dbh) "set constraints \"hosts_hostname_cn\" deferred";
+ PGSQL(dbh) "update hosts set canonical_hostname = $canonical_hostname
+ where id = $hostid";
+ PGSQL(dbh) "delete from hostnames where hostid = $hostid";
+ List.iter (
+ fun name ->
+ PGSQL(dbh) "insert into hostnames (hostid, name)
+ values ($hostid, $name)";
+ ) hostnames;