agora inbox for pgsql-interfaces@postgresql.org  
help / color / mirror / Atom feed
Postgresql 9.0.8 - ECPG - COPY FROM returning COUNT
3+ messages / 2 participants
[nested] [flat]

* Postgresql 9.0.8 - ECPG - COPY FROM returning COUNT
@ 2013-05-24 14:42  Rene Grün <rene.gruen@cslab.de>
  0 siblings, 1 reply; 3+ messages in thread

From: Rene Grün @ 2013-05-24 14:42 UTC (permalink / raw)
  To: pgsql-interfaces

Dear List,

I'm trying to copy an unknown amount of data  from a file to a table unsing a copy command.

This is working without any problems.

Now I want to get the number of copied rows.

In psql this is retuned as a text 'COPY XXX'

How can I get this in ECPG?

Using a prepared DELETE- or  INSERT- statement I can simply execute the statement INTO a var.

EXEC SQL BEGIN DECLARE SECTION;
	const char        *stmt_1 = "DELETE FROM my_table;";
	int		myVar;
EXEC SQL END DECLARE SECTION;

EXEC SQL PREPARE stmt_1 FROM :stmt_1;
EXECUTE stmt_1 INTO :myVar;

Var now contains the number of deleted rows.

But...

EXEC SQL BEGIN DECLARE SECTION;
	const char        *stmt_1 = "COPY my_table FROM '/tmp/file.data';";
	int		myVar;
EXEC SQL END DECLARE SECTION;

EXEC SQL PREPARE stmt_1 FROM :stmt_1;
EXECUTE stmt_1 INTO :myVar;

mvVar is always 0.

Any suggestions how to get the numer?



Mit freundlichen Grüßen aus Krefeld,
With best regards from Krefeld,

CS-Lab GmbH
i. A. René Grün

E-Mail: rgr@cslab.de
Fon:    +49 2151 72949-0
Fax:    +49 2151 72949-9
---
CS-Lab GmbH (Creativ Software Labor GmbH)
Römerstr. 15
D-47809 Krefeld
Geschäftsführer: Dieter Schmitz
Registergericht Krefeld, HRB 12257, USt.-ID: DE 263 834 180





-- 
Sent via pgsql-interfaces mailing list (pgsql-interfaces@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-interfaces



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Postgresql 9.0.8 - ECPG - COPY FROM returning COUNT
@ 2013-05-25 16:44  Michael Meskes <meskes@postgresql.org>
  parent: Rene Grün <rene.gruen@cslab.de>
  0 siblings, 0 replies; 3+ messages in thread

From: Michael Meskes @ 2013-05-25 16:44 UTC (permalink / raw)
  To: Rene Grün <rene.gruen@cslab.de>; +Cc: pgsql-interfaces

On Fri, May 24, 2013 at 04:42:21PM +0200, Rene Grün wrote:
> In psql this is retuned as a text 'COPY XXX'
> 
> How can I get this in ECPG?

sqlca.sqlerrd[2] is supposed to carry the "number of rows processed after an
INSERT, UPDATE or DELETE statement". Should work in your case, too.

> Mit freundlichen Grüßen aus Krefeld,
> With best regards from Krefeld,

Best regards from Moenchengladbach. :)

Explanation for the non-locals, it's like 10 miles between the two cities.

Michael
-- 
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
Jabber: michael.meskes at gmail dot com
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL


-- 
Sent via pgsql-interfaces mailing list (pgsql-interfaces@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-interfaces



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Postgresql 9.0.8 - ECPG - COPY FROM returning COUNT
@ 2013-05-27 07:13  Rene Grün <rene.gruen@cslab.de>
  0 siblings, 0 replies; 3+ messages in thread

From: Rene Grün @ 2013-05-27 07:13 UTC (permalink / raw)
  To: Michael Meskes <meskes@postgresql.org>; +Cc: pgsql-interfaces

It's working.

Thanks a lot.

Mit freundlichen Grüßen aus Krefeld,
With best regards from Krefeld,

CS-Lab GmbH
i. A. René Grün

E-Mail: rgr@cslab.de
Fon:    +49 2151 72949-0
Fax:    +49 2151 72949-9
---
CS-Lab GmbH (Creativ Software Labor GmbH)
Römerstr. 15
D-47809 Krefeld
Geschäftsführer: Dieter Schmitz
Registergericht Krefeld, HRB 12257, USt.-ID: DE 263 834 180



-----Ursprüngliche Nachricht-----
Von: Michael Meskes [mailto:meskes@postgresql.org] 
Gesendet: Samstag, 25. Mai 2013 18:45
An: Rene Grün
Cc: pgsql-interfaces@postgresql.org
Betreff: [ Spamverdacht ]Re: [INTERFACES] Postgresql 9.0.8 - ECPG - COPY FROM returning COUNT

On Fri, May 24, 2013 at 04:42:21PM +0200, Rene Grün wrote:
> In psql this is retuned as a text 'COPY XXX'
> 
> How can I get this in ECPG?

sqlca.sqlerrd[2] is supposed to carry the "number of rows processed after an INSERT, UPDATE or DELETE statement". Should work in your case, too.

> Mit freundlichen Grüßen aus Krefeld,
> With best regards from Krefeld,

Best regards from Moenchengladbach. :)

Explanation for the non-locals, it's like 10 miles between the two cities.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org) Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
Jabber: michael.meskes at gmail dot com
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL

-- 
Sent via pgsql-interfaces mailing list (pgsql-interfaces@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-interfaces


^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2013-05-27 07:13 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-05-24 14:42 Postgresql 9.0.8 - ECPG - COPY FROM returning COUNT Rene Grün <rene.gruen@cslab.de>
2013-05-25 16:44 ` Michael Meskes <meskes@postgresql.org>
2013-05-27 07:13 Re: Postgresql 9.0.8 - ECPG - COPY FROM returning COUNT Rene Grün <rene.gruen@cslab.de>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox