0

I'm trying to insert a point into a Postgresql table with c++. This is what I have so far:

const char * paramValues[1];
paramValues[0] = "{100,200}";
res = PQexecParams(conn, "insert into test (pt) values ($1::point)", 1, NULL, paramValues, NULL, NULL, 0);

It gives the error: "invalid input error for type point"

What should I be using instead of {100,200}? I've also tried paramValues[0] = "point(100,200)";

user3791372
  • 4,445
  • 6
  • 44
  • 78

1 Answers1

0

paramValues[0] = "100,200"; does the trick.

I'll also add for composite types, a ( and ) goes around the values like so: paramValues[1] = "(10.25, some name)" which would represent a type created with create type foo (some_real real, some_name varchar(100))

user3791372
  • 4,445
  • 6
  • 44
  • 78
  • Please don't add "thank you" as an answer. Instead, vote up the answers that you find helpful. – ivarni Aug 07 '14 at 04:38
  • Excuse me? "Thank you" is not the answer but the code is. There are no other answers but mine. – user3791372 Aug 07 '14 at 05:06
  • My bad. This answer popped up in the review queue were the only thing visible to reviewers is the answer itself. Adding "Thanks" was a nice way to confuse me. I would suggest you edit and remove "Thanks" or you risk other reviewers making the same mistake. – ivarni Aug 07 '14 at 05:10
  • Maybe the software should be rewritten to show the question when reviewing answers as context is everything! – user3791372 Aug 07 '14 at 05:13
  • I think the idea with providing less context is to make the review process faster, if it was too time consuming then people wouldn't do it. What happened was basically that the software flagged the answer as suspicious due to it's length and then it is subject to peer review which may or may not end up with a flag for moderator attention. My first comment was a canned reply provided by the system. It's nothing to worry about, your answer looks fine now. (More on review queues here: https://meta.stackexchange.com/questions/161390/what-are-the-review-queues-and-how-do-they-work) – ivarni Aug 07 '14 at 05:30
  • @ivarni maybe adding the answer count would help moderators to prevent this same problem – user3791372 Aug 07 '14 at 08:42