I am taking ID from my user and then i want to delete that ID from the database. I am using postgresql. but the query is not running. When i give hard code value like id=5 then it runs but when i give it user's value like id = DeleteId then it doesn't run. Here is the function:
void DeleteValue(PGconn *conn, int DeleteId)
{
PGresult *res = PQexec(conn, "DELETE FROM testData where ID = DeleteId" );
if (PQresultStatus(res) != PGRES_COMMAND_OK)
{
cout << "Delete testData record failed." << endl;
PQclear(res);
CloseConn(conn);
}
cout << "\nDelete testData record - OK\n";
PQclear(res);
}