Return-Path: owner-postman Delivery-Date: Sun, 10 Apr 94 16:11:11 -0700 Return-Path: owner-postman Received: from localhost (localhost [127.0.0.1]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with SMTP id OAA14958 for postgres-redist; Sun, 10 Apr 1994 14:06:14 -0700 Resent-From: POSTGRES mailing list Resent-Message-Id: <199404102106.OAA14958@nobozo.CS.Berkeley.EDU> Sender: owner-postman@postgres.Berkeley.EDU X-Return-Path: owner-postman Received: from faerie.CS.Berkeley.EDU (faerie.CS.Berkeley.EDU [128.32.149.14]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with ESMTP id OAA14949 for ; Sun, 10 Apr 1994 14:06:13 -0700 Received: from localhost (localhost [127.0.0.1]) by faerie.CS.Berkeley.EDU (8.6.4/8.1B) with SMTP id OAA14296; Sun, 10 Apr 1994 14:06:02 -0700 Message-Id: <199404102106.OAA14296@faerie.CS.Berkeley.EDU> X-Authentication-Warning: faerie.CS.Berkeley.EDU: Host localhost didn't use HELO protocol From: aoki@postgres.Berkeley.EDU (Paul M. Aoki) To: SRIRAMK@charlie.usd.edu Cc: postgres@postgres.Berkeley.EDU Subject: Re: Clarification reg ASCII files to PG classes and back Reply-To: aoki@postgres.Berkeley.EDU (Paul M. Aoki) In-reply-to: Your message of Sun, 10 Apr 1994 11:57:17 -0500 (CDT) <940410115717.3196@charlie.usd.edu> Date: Sun, 10 Apr 94 14:06:02 -0700 X-Sender: aoki@postgres.Berkeley.EDU Resent-To: postgres-redist@postgres.Berkeley.EDU X-Mts: smtp Resent-Date: Sun, 10 Apr 94 14:06:14 -0700 Resent-XMts: smtp SRIRAMK@charlie.usd.edu writes: > PQsetdb ("ftransferdb1"); > PQexec ("begin"); > PQexec ("copy LINE from "/home/coyote/postgres/sriramk/srcfile""); this last line isn't correct C, but i assume you know that.. > PQputline(".\n"); > PQendcopy(); > PQexec ("end"); > Each individual line in the srcfile needs to be copied as an individual > tuple in the class called LINE. It worked fine when I used the copy command > at the Postgres prompt. But it didn't work in a C program as above. what someone was trying to say with the following (rather opaque) statement in the reference manual: The copy command in POSTGRES has options to read from or write to the net- work connection used by LIBPQ. Therefore, functions are necessary to access this network connection directly so applications may take full advantage of this capability. is that PQgetline, PQputline and PQendcopy are for use with copy to/from stdin/stdout. what isn't very clear is that they are ONLY for use with copy to/from stdin/stdout. if you're happy with copying from a particular file, you don't need PQputline and PQendcopy. i just ran the following program and it works: main() { PQsetdb("foo"); PQexec("create foo (a=int4)"); PQexec("copy foo from \"/home2/aoki/xxx\""); } although it doesn't do any error-checking, etc. most people want to be able to generate instances from within their program and send them directly to the backend (without an intermediate file), which is what the PQputline stuff is for. > I had earlier addressed Postgres and tried out the alternative 1 in line > with suggestion from Mr Aoki hey, i didn't suggest *that*. don't be puttin' words in my mouth.. :-) i suggested you take a look at the example in the libpq section and at the source for monitor. the reason i said to look at monitor is that there are some real-world considerations with respect to error-checking, buffer-handling, etc. that you won't see in a tiny sample program. -- Paul M. Aoki | CS Div., Dept. of EECS, UCB | aoki@postgres.Berkeley.EDU | Berkeley, CA 94720 | ...!uunet!ucbvax!aoki