Return-Path: owner-postman Delivery-Date: Sun, 10 Apr 94 12:23:54 -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 JAA13821 for postgres-redist; Sun, 10 Apr 1994 09:58:48 -0700 Resent-From: POSTGRES mailing list Resent-Message-Id: <199404101658.JAA13821@nobozo.CS.Berkeley.EDU> X-Authentication-Warning: nobozo.CS.Berkeley.EDU: Host localhost didn't use HELO protocol Sender: owner-postman@postgres.Berkeley.EDU X-Return-Path: owner-postman Received: from charlie.usd.edu (charlie.usd.edu [192.55.228.1]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with SMTP id JAA13812 for ; Sun, 10 Apr 1994 09:58:44 -0700 From: SRIRAMK@charlie.usd.edu Date: Sun, 10 Apr 1994 11:57:17 -0500 (CDT) To: postgres@postgres.Berkeley.EDU CC: SRIRAMK@charlie.usd.edu Message-Id: <940410115717.3196@charlie.usd.edu> Subject: Clarification reg ASCII files to PG classes and back Resent-To: postgres-redist@postgres.Berkeley.EDU Resent-Date: Sun, 10 Apr 94 09:58:48 -0700 Resent-XMts: smtp I am writing an application in C which will has to post data from an ASCII file to Postgres classes. I have tried using the copy command embedded in C program as follows in approach 1: Approach 1. #include #include "/home/coyote/postgres/src/backend/tmp/libpq.h" main() { PortalBuffer *p; int i, n; PQsetdb ("ftransferdb1"); PQexec ("begin"); PQexec ("copy LINE from "/home/coyote/postgres/sriramk/srcfile""); 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. So alternatively I tried out the following approach 2 which worked. Approach 2 #include main() { system ("monitor ftransferdb1 < tranferfile"); } where transferfile is the following: copy LINE from "/home/coyote/postgres/sriramk/srcfile" \g I feel Approach 1 is a better way of doing it (if it can be made to work) rather than creating a number of command files (like transferfile above) I had earlier addressed Postgres and tried out the alternative 1 in line with suggestion from Mr Aoki, but I must be missing some point which prevents the approach 1 from working. A suitable and good solution is required as my project involves transferring large volumes of data to and fro. Looking forward to suggestions, Thanks Sriram Kal.