agora inbox for postgres@postgres.berkeley.edu  
help / color / mirror / Atom feed
From: Paul Cole <pcole@ccwf.cc.utexas.edu>
To: Casey Claiborne <mskc@io.com>
To: postgres@postgres.Berkeley.EDU
Subject: Re: res results from PQexec()
Date: Sun, 27 Aug 1995 21:25:57 -0500 (CDT)
Message-ID: <Pine.LNX.3.91.950827211156.3813F-100000@localhost> (raw)
In-Reply-To: <Pine.LNX.3.91.950827202744.3813D-100000@localhost>

I played around with your code snippet.  I found a couple things that my 
version of postgres doesn't like right off the bat.

Your class was called "user" and you had "user" as a data member as well.
My postgres <4.2a> doesn't like "user" at all in any queries whatsoever. 
Must be a reserved word I guess?

Secondly you specified your query as  <user remplaced with template and name>

append template (template.name = blah, template.address = blah, 
                 template.city = blah, template.state = blah)

My postgres doesn't like that either.  It dislikes your qualification of 
the data members with the class.  You've already qualified it by saying 
"append class_name" so..

append template (name = blah, address = blah, city = blah, state = blah)
is quite sufficient.

other than that I found no problems.

I ran the test with:
--------------------

>destroydb testdb
>createdb testdb
>
> monitor testdb
Welcome to the POSTGRES terminal monitor

Go 
* create TEMPLATE (name = text, 
address = text, city = text, 
                    state = text ) \g
* \q
>
> ./test_libpq
>
> monitor testdb
Welcome to the POSTGRES terminal monitor

Go 
* retrieve (TEMPLATE.all) \g

Query sent to backend is "retrieve (TEMPLATE.all) "
---------------------------------------------------------
| name        | address     | city        | state       |
---------------------------------------------------------
| Joe Schmoe  | 1234 NoWhere Drive| BFE City    | Junk        |
---------------------------------------------------------


Enjoy!

  --Paul Cole
  --pcole@ccwf.cc.utexas.edu

=======================================
=======================================

the source for test_libpq follows:
----------------------------------
#include <stdio.h>

#include "libpq.h"

struct struct_user {
char name[20];
char address[50];
char city[20];
char state[10];
};

typedef struct struct_user user;

user TEST_USER = { "Joe Schmoe", "1234 NoWhere Drive", "BFE City", "Junk" };

int main(void)
{
char* res;
char tempdata[600];

sprintf(tempdata, "append TEMPLATE (name = \"%s\", address=\"%s\", 
city=\"%s\", state=\"%s\") ",
        TEST_USER.name, TEST_USER.address, TEST_USER.city, TEST_USER.state);

PQsetdb("testdb");
PQexec("begin");

res = PQexec(tempdata);

if (*res == 'E')
        {
        printf("this did not work 1 \n");
        PQexec("end");
        exit(0);
        }

if (*res == 'I')
        {
        printf("this did not work 2 \n");
        PQexec("end");
        exit(0);
        }
PQexec("end");
PQfinish();     /* 
                 * even though I still don't know what this REALLY does 
                 * PQfinish() isn't even defined in my libpq.h. *shrug*
                 */

return (0);
}

==============================================================================
   To add/remove yourself to/from the POSTGRES mailing list: send mail with 
   the subject line ADD or DEL to "postgres-request@postgres.Berkeley.EDU".
   If this fails, send mail to "post_questions@postgres.Berkeley.EDU" and
   a human will deal with it.  DO NOT post to the "postgres" mailing list.
==============================================================================
              URL: http://s2k-ftp.CS.Berkeley.EDU:8000/postgres/



reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: postgres@postgres.berkeley.edu
  Cc: pcole@ccwf.cc.utexas.edu, mskc@io.com
  Subject: Re: res results from PQexec()
  In-Reply-To: <Pine.LNX.3.91.950827211156.3813F-100000@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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