postgresql c++ insert statement
I have a mysql insert query in c++. You can see it below. I want to convert mysql db to postgresql. Im using #include <postgresql/libpq-fe.h> for it.
1 2 3 4 5 6 7 8
|
pstmt = con->prepareStatement("INSERT INTO public.comp_inventory(epp_mac_address,epp_data) VALUES (?,?)");
pstmt->setString(1, root.get("MAC","null").asString());
pstmt->setString(2, pars);
pstmt->execute();
}
|
Here is an simple insert statement with pqexec.
1 2 3 4 5 6 7 8 9 10 11
|
ress = PQexec(conn, "INSERT INTO public.device VALUES('1','Audi','52642')");
if (PQresultStatus(ress) != PGRES_COMMAND_OK) {
std::cout << "insert failed: " << PQresultErrorMessage(ress) << std::endl;
} else {
std::cout << "insert counts: " << PQcmdTuples(ress) << std::endl;
}
PQclear(ress);
}
|
how can i convert this part according to postgresql??
pstmt->setString(1, root.get("MAC","null").asString());
pstmt->setString(2, pars);
Topic archived. No new replies allowed.