Re: COPY TABLE TO

From: "Paulo Scardine" <paulos(at)cimed(dot)ind(dot)br>
To: "Paul Punett" <paul(dot)punett(at)shazamteam(dot)com>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: COPY TABLE TO
Date: 2003-12-22 15:32:36
Message-ID: 012101c3c8a0$d36e7560$6101a8c0@wxppaulos
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

SELECT x, y
(SELECT 1 AS ord, COUNT(*) as x, NULL AS y FROM tablex
UNION
SELECT 2, x, y FROM tablex)

May be you will have to do some explicit casting depending on the field
types.

--
Paulo Scardine

----- Original Message -----
From: "Paul Punett" <paul(dot)punett(at)shazamteam(dot)com>
To: <pgsql-hackers(at)postgresql(dot)org>
Sent: Monday, December 22, 2003 8:35 AM
Subject: [HACKERS] COPY TABLE TO

> Hi,
>
> I need to write a tab separated text file such that the first row contains
> number of records in the table.
> I insert first row with '0' (zero) as first column & rest columns NULL.
> Then at the end of writing records to table I do a select into Variable
> count(*) from table.
> & update the first record with the count returned.
> Unfortunately after the update the first row becomes the last row & hence
> COPY TO FileName sends the count as the last record.
>
> I need count as the first record? Any suggestions please ?
> The documentation says indexing does not affect copy order.
>
> I am developing on C++ with PostGre on windows. I need to port to Linux
> later. Any suggestions on linking C++ code to PostGre (queries &
functions)
>
> Thanks
> Paul
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2003-12-22 15:39:51 Re: [COMMITTERS] pgsql-server/doc/src/sgml Tag: REL7_4_STABLE r ...
Previous Message Marc G. Fournier 2003-12-22 15:27:20 Re: [COMMITTERS] pgsql-server/doc/src/sgml Tag: REL7_4_STABLE