473,289 Members | 1,940 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,289 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 11659

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:...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.