Actually, the question is: how to connect to a PostgreSQL 9.2 database using s / s ++ in the Xcode environment (osx 10.8.2)?
upd. The situation is as follows. There is a code working under Linux, here’s a piece that connects:
#include <stdio.h> #include <string.h> EXEC SQL include sqlca; EXEC SQL BEGIN DECLARE SECTION; char ConnectionString [] = "login@192.168.1.1:5432"; char Login [] = "login"; char Password [] = "password"; EXEC SQL END DECLARE SECTION; EXEC SQL BEGIN DECLARE SECTION; int my_id; char my_data[256]; int my_count; char date1[10]; char date2[10]; EXEC SQL END DECLARE SECTION; EXEC SQL WHENEVER SQLERROR SQLPRINT; int main() { EXEC SQL CONNECT TO :ConnectionString USER :Login using :Password; if( sqlca.sqlcode != 0 || strncmp(sqlca.sqlstate,"00",2)) { printf("connect -- NoOK\n"); exit(-1); } else { printf("connect --OK\n"); menu(); } exec sql disconnect; printf("disconnect --OK\n"); }
This code is highly desirable to transfer to the Mac and run in XCode. In principle, this code is not necessarily exactly; it is enough to implement similar functionality, but there is one key problem - Xcode does not recognize any SQL inserts (that is, everything that starts with EXEC). How to implement support for these inserts in this environment?