From: Edmund Bacon <ebacon@onesystem.com>
To: pgsql-interfaces <pgsql-interfaces@postgresql.org>
Subject: ECPG and COPY TO STDOUT
Date: Thu, 01 Apr 2004 12:22:44 -0700
Message-ID: <1080847364.13873.14.camel@elb_lx.onesystem.ca> (raw)
If I use COPY TO STDOUT in an ECPG program, where does the output go?
If I use COPY TO '/tmp/foo', I get the file created, with the data in
it, but trying COPY TO STDOUT produces no output.
What I'm trying to do is to dump a table's data, and have the resulting
file owned by the application user rather than the dba user.
I would rather to not have to create the file in /tmp, copy contents, rm
/tmp file, if I don't have to.
This is the program I'm using:
#include <stdio.h>
EXEC SQL INCLUDE sqlca;
EXEC SQL WHENEVER SQLERROR sqlprint;
int main()
{
EXEC SQL BEGIN DECLARE SECTION;
char *fname = "/tmp/foo";
EXEC SQL END DECLARE SECTION;
EXEC SQL CONNECT TO test;
/* produces expected file "/tmp/foo" */
EXEC SQL COPY foo TO :fname WITH DELIMITER ',';
printf("copy to /tmp/foo : sqlca.sqlcode = %ld", sqlca.sqlcode);
/* goes nowhere (?) */
EXEC SQL COPY foo TO STDOUT WITH DELIMITER ',';
printf("copy to STDOUT : sqlca.sqlcode = %ld\n", sqlca.sqlcode);
EXEC SQL DISCONNECT;
return 0;
}
--
Edmund Bacon <ebacon@onesystem.com>
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: pgsql-interfaces@postgresql.org
Cc: ebacon@onesystem.com
Subject: Re: ECPG and COPY TO STDOUT
In-Reply-To: <1080847364.13873.14.camel@elb_lx.onesystem.ca>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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