Subject: libpq append

From: [email-masked] (Praveen Mamnani)
Date: Fri, 16 Sep 1994 17:08:00 -0600

From: [email-masked] (Praveen Mamnani)
To: [email-masked]
Subject: "append", using libpq ?

I am writing some programs in C using Libpq. I am doing basic
things as, creating a database, inserting some records(classes), 
and retrieving the data.
The reference manual shows the insertion of class using the copy 
command (from stdin). I wanted to execute the query append to 
insert the instances of some classes. I tried PQexec("append..."), 
but this does not seem to work. I am not sure that libpq allows
execution of such queries using PQexec. If not, then is there
another way instead of using copy command and PQputline.

Your help would be very appreciated.

Thanks,

Oops, one more thing. If you have some basic examples of appending
and retrieving data from a database, I would really appreciate if 
I can get some of them.

Thank you .

Praveen.

==============================================================================
   To add/remove yourself to/from the POSTGRES mailing list: send mail with 
   the subject line ADD or DEL to "[email-masked]"

   If this fails, send mail to "[email-masked]" and
   a human will deal with it.  DO NOT post to the "postgres" mailing list.
==============================================================================

---

From: [email-masked] (Paul M. Aoki)
Date: Fri, 16 Sep 94 16:31:38 -0700

[email-masked] (Praveen Mamnani) writes:
> I tried PQexec("append..."), 
> execution of such queries using PQexec.

it does, and by-and-large it works.  (this example maximizes 
minimality rather than correctness.)

faerie:postgres (7)> cat foo.c
main()
{
  (void) PQsetdb("foo");
  (void) PQexec("create bar (x=int4)");
  (void) PQexec("append bar (x=5)");
  (void) PQfinish();
}
faerie:postgres (8)> cc foo.c /private/devel/postgres/lib/libpq.a
faerie:postgres (9)> a.out 
faerie:postgres (10)> monitor -c 'retrieve (bar.all)' foo
---------------
| x           |
---------------
| 5           |
---------------
faerie:postgres (11)> 

there are examples of retrieving rows in the reference manual and 
under src/regress.
--
  Paul M. Aoki          |  University of California at Berkeley
  [email-masked]  |  Dept. of EECS, Computer Science Division (#1776) 
                        |  Berkeley, CA 94720-1776