473,396 Members | 1,756 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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:
Expand|Select|Wrap|Line Numbers
  1. pstmt = con->prepareStatement("INSERT INTO public.comp_inventory(epp_mac_address,epp_data) VALUES (?,?)");
  2.  
  3. pstmt->setString(1, root.get("MAC","null").asString());
  4. pstmt->setString(2, pars);
  5.  
  6. pstmt->execute();
  7. }


Here is an simple insert statement with pqexec.

Expand|Select|Wrap|Line Numbers
  1. ress = PQexec(conn, "INSERT INTO public.device VALUES('1','Audi','52642')");
  2.  
  3.    if (PQresultStatus(ress) != PGRES_COMMAND_OK) {
  4.     std::cout << "insert failed: " << PQresultErrorMessage(ress) << std::endl;
  5.   } else {
  6.     std::cout << "insert counts: " << PQcmdTuples(ress) << std::endl;
  7.   }    
  8.     PQclear(ress);    
  9.     }
  10.  

how can i convert this part according to postgresql??

Expand|Select|Wrap|Line Numbers
  1. pstmt->setString(1, root.get("MAC","null").asString());
  2. pstmt->setString(2, pars);
May 26 '22 #1
0 11749

Sign in to post your reply or Sign up for a free account.

Similar topics

125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
3
by: Marek Lewczuk | last post by:
Hello, I have changed DB from MySQL to PostgreSQL. When I have run my application on PostgreSQL it was disaster - it was much slower than MySQL... I have tried to change PG configuration file...
29
by: Paul Ganainm | last post by:
Hi all, Following up on another thread, here is a comparison between FB and PG from an FB'ers POV. BTW, FB is the love-child of Open-Source-Interbase. BTW, I have tried to be as accurate as I...
3
by: ET | last post by:
I don't know whats the problem, but after I added functions to first verify, then relink linked tables if not found, now I can't convert that database to MDE format. I can split the database, but...
0
by: phil campaigne | last post by:
Phil Campaigne wrote: > Hi Ron, > I had a couple of questions on your instructions: > 1. what is this for? > >#make install-all-headers According to the docs you need it if you are going...
1
by: Anthony_Barker | last post by:
Aberdeen has a review of open source rdbms. The overall review was quite positive but mentioned a few things missing. Features desired according to users: Gui control centre Improved...
9
by: Andy B | last post by:
If I bought one of these boxes/OS combos as a postgresql database server, would postgresql be able to make the best use of it with a huge (e.g. 40GB) database? Box: HP ProLiant DL585, with ...
2
by: kirke | last post by:
Hi, I have a datetime column named dtDateTime. its format is "Oct 27 2006 12:00:00 " I want to group by only date part of it and count my code is $sql1="SELECT ...
2
Shashi Sadasivan
by: Shashi Sadasivan | last post by:
Hi, With my project turning out to have around an enormus different dataTablees, and forms, the compilation time taken has started to show up. Is there a way to convert parts of it as libraries,...
18
by: SharonH | last post by:
I have data that I import from an Excel sheet into Access. the field I have problems with is called . It contains the date and time of the article being weighed. The string comes in like this:...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.