how can i convert this part according to postgresql??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • suslucoder
    New Member
    • May 2022
    • 1

    how can i convert this part according to postgresql??

    Im a newbie in PostgreSQL. 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.

    Here is my mysql code:
    Code:
    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.

    Code:
    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??

    Code:
    pstmt->setString(1, root.get("MAC","null").asString());
    pstmt->setString(2, pars);
    Last edited by zmbd; May 27 '22, 03:32 AM. Reason: [z{Please post in the correct Topic Forum}]
Working...