0

I've decided to use postgreSQL as database for a game project(C++).

At the moment I'm using Oracle and it's Pro*C precompiler at work and heard that postgreSQL also has something similar called ECPG.

It's also possible to access data from the the postgres database directly by using the SQL in a string.

So the difference between "normal" and using ECPG, is that you can write your SQL statements like code?, or are there any other differences I should be aware of?.

(PS: i know I'm using it at work, but I haven't noticed any other differences)

Looking forward to hearing from you guys.

jeromintus
  • 367
  • 1
  • 5
  • 14

1 Answers1

1

Yes, ECPG is covered in the documentation.

So the difference between "normal" and using ECPG, is that you can write your SQL statements like code?

Well, SQL statements are code. A SQL statement just looks like a SQL statement. This is what a CREATE TABLE statement might look like in ECPG.

EXEC SQL CREATE TABLE foo (number integer, ascii char(16));

ECPG allows variable substitution. (Maybe that's what you meant by "write your SQL statements like code".)

EXEC SQL INSERT INTO sometable VALUES (:v1, 'foo', :v2);

All this stuff is in the documentation.

Mike Sherrill 'Cat Recall'
  • 91,602
  • 17
  • 122
  • 185
  • would you advise to use ECPG, rather than the "normal" way?. Would it be more difficult to move from postgre sql using ECPG to another database, than using no ECPG? – jeromintus Jul 31 '14 at 14:27
  • I'd probably use ECPG and prepared statements. I don't think it makes much difference when switching to a different database management system; you'll probably have a lot of work either way. If you anticipate switching, incorporate that into your testing starting today. – Mike Sherrill 'Cat Recall' Jul 31 '14 at 15:27