pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Problem with Libpq
2+ messages / 2 participants
[nested] [flat]

* Problem with Libpq
@ 1999-06-29 13:08  Pablo Saul Salazar - CESERCOMP <ssalazar@goliat.espol.edu.ec>
  0 siblings, 0 replies; 2+ messages in thread

From: Pablo Saul Salazar - CESERCOMP @ 1999-06-29 13:08 UTC (permalink / raw)
  To: pgsql-interfaces

Hello alls

How obtain a data of type time of a table , because the function
PQgetvalue only return me a data type *char
Please help me




Pablo Salazar Loaiza
 Asistente de Redes
  CESERCOMP-ESPOL





^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* problem with libpq++
@ 2000-02-16 14:50  anmue@gmx.de
  0 siblings, 0 replies; 2+ messages in thread

From: anmue@gmx.de @ 2000-02-16 14:50 UTC (permalink / raw)
  To: pgsql-interfaces

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 <iostream.h>
#include <iomanip.h>
#include
<libpq++.H>

/**********************************************************************************/
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 <<endl;
  // first, print out the attribute names
  int nFields = data.Fields();
  if (data.Tuples() == 1) {
    cout << data.Tuples() << endl;}
   else {cout << "Err" <<endl;}
  // next, print out the instances

}
}


-- 
Sent through Global Message Exchange - http://www.gmx.net




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2000-02-16 14:50 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-06-29 13:08 Problem with Libpq Pablo Saul Salazar - CESERCOMP <ssalazar@goliat.espol.edu.ec>
2000-02-16 14:50 problem with libpq++ anmue@gmx.de

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox