Received: from www8.gmx.net (www8.gmx.net [194.221.183.48]) by hub.org (8.9.3/8.9.3) with SMTP id JAA26374 for ; Wed, 16 Feb 2000 09:51:11 -0500 (EST) (envelope-from anmue@gmx.de) From: anmue@gmx.de Received: (qmail 30203 invoked by uid 0); 16 Feb 2000 14:50:38 -0000 Date: Wed, 16 Feb 2000 15:50:38 +0100 (MET) To: pgsql-interfaces@postgresql.org MIME-Version: 1.0 Subject: problem with libpq++ X-Authenticated-Sender: #0000131320@gmx.net X-Authenticated-IP: [62.156.187.1] Message-ID: <30164.950712638@www8.gmx.net> X-Mailer: WWW-Mail 1.5 (Global Message Exchange) X-Flags: 0001 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hello list, i have a problem with libpq and variable in select. please have a look my sourcecode : /* * testlibpq1.cc * Test the C++ version of LIBPQ, the POSTGRES frontend library. * * queries the template1 database for a list of database names * */ #include #include #include /**********************************************************************************/ typedef struct _user_data { /* first two items must be same as hash_link */ char *user; struct _user_data *next; char *passwd; } user_data; /**********************************************************************************/ int main() { // Begin, by establishing a connection to the backend. // When no parameters are given then the system will // try to use reasonable defaults by looking up environment variables // or, failing that, using hardwired constants const char* dbName = "dbname=testdb"; PgDatabase data(dbName); // check to see that the backend connection was successfully made if ( data.ConnectionBad() ) { cerr << "Connection to database '" << dbName << "' failed." << endl << "Error returned: " << data.ErrorMessage() << endl; exit(1); } /************************************************************************************/ char *user, *passwd, *p; char buf[256]; while (fgets(buf, 256, stdin) != NULL) { if ((p = strchr(buf, '\n')) != NULL) *p = '\0'; /* strip \n */ if ((user = strtok(buf, " ")) == NULL) { printf("ERR\n"); continue;} if ((passwd = strtok(NULL, "")) == NULL) { printf("ERR\n"); continue;} /************************************************************************************/ // fetch instances from the pg_database, the system catalog of databases if ( !data.ExecTuplesOk("select * from test where name={user} and password={passwd}") ) { cerr << "Error" << endl; exit(1); } cout << "if" << user << "and"<< endl; cout << user << " ww " << passwd <