pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
how to use COPY within plperl
3+ messages / 2 participants
[nested] [flat]

* how to use COPY within plperl
@ 2004-11-08 08:59  Marek Lewczuk <newsy@lewczuk.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Marek Lewczuk @ 2004-11-08 08:59 UTC (permalink / raw)
  To: Lista dyskusyjna pgsql-general <pgsql-general@postgresql.org>; pgsql-sql

Hello,
I need to use COPY (instead of INSERT) within plperl function. I know 
that COPY will work if data will be taken from file - however I need to 
use STDIN. I tried this:
spi_exec_query("COPY sometable (field1, field2) FROM 
stdin;"."\n"."sometext"."\t"."sometext"."\n"."\.")

But it didn't work. Thanks in advance.

 



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

* Re: how to use COPY within plperl
@ 2004-11-08 19:04  Goutam Paruchuri <gparuchuri@oneil.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Goutam Paruchuri @ 2004-11-08 19:04 UTC (permalink / raw)
  To: Marek Lewczuk <newsy@lewczuk.com>; Lista dyskusyjna pgsql-general <pgsql-general@postgresql.org>; pgsql-sql

Why can you not use simple insert statements (sql insert).
Copy is meant to transfer large amount of data from text files to
databases and vice versa.

- Goutam

 

> -----Original Message-----
> From: pgsql-general-owner@postgresql.org 
> [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Marek Lewczuk
> Sent: Monday, November 08, 2004 3:59 AM
> To: Lista dyskusyjna pgsql-general; Lista dyskusyjna pgsql-sql
> Subject: [GENERAL] how to use COPY within plperl
> 
> 
> Hello,
> I need to use COPY (instead of INSERT) within plperl 
> function. I know that COPY will work if data will be taken 
> from file - however I need to use STDIN. I tried this:
> spi_exec_query("COPY sometable (field1, field2) FROM
> stdin;"."\n"."sometext"."\t"."sometext"."\n"."\.")
> 
> But it didn't work. Thanks in advance.
> 
>  
> 
> ---------------------------(end of 
> broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index 
> scan if your
>       joining column's datatypes do not match
> 


Confidentiality Notice
The information contained in this e-mail is confidential and intended for use only by the person(s) or organization listed in the address. If you have received this communication in error, please contact the sender at O'Neil & Associates, Inc., immediately. Any copying, dissemination, or distribution of this communication, other than by the intended recipient, is strictly prohibited.




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

* Re: how to use COPY within plperl
@ 2004-11-08 19:14  Marek Lewczuk <newsy@lewczuk.com>
  parent: Goutam Paruchuri <gparuchuri@oneil.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Marek Lewczuk @ 2004-11-08 19:14 UTC (permalink / raw)
  To: Goutam Paruchuri <gparuchuri@oneil.com>; +Cc: Lista dyskusyjna pgsql-general <pgsql-general@postgresql.org>; pgsql-sql

Goutam Paruchuri wrote:
> Why can you not use simple insert statements (sql insert).
> Copy is meant to transfer large amount of data from text files to
> databases and vice versa.
"Insert" is much slower if there are many (hundreds, thousands) data to 
be inserted - and in my case there will be thousands of inserts made by 
plperl. I can make a file with the data (and load using COPY), but it 
would be better to use copy from stdin.

Thanks

ML

 



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


end of thread, other threads:[~2004-11-08 19:14 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-11-08 08:59 how to use COPY within plperl Marek Lewczuk <newsy@lewczuk.com>
2004-11-08 19:04 Re: how to use COPY within plperl Goutam Paruchuri <gparuchuri@oneil.com>
2004-11-08 19:14 ` Marek Lewczuk <newsy@lewczuk.com>

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