473,418 Members | 2,344 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,418 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 11759

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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.