pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Christopher Kings-Lynne <chriskl@familyhealth.com.au>
To: simon.hewitt@greenhill-ymca.org
Cc: pgsql-php@postgresql.org
Subject: Re: pg_put_line() Frustration
Date: Mon, 20 Jun 2005 22:36:00 +0800
Message-ID: <42B6D450.50106@familyhealth.com.au> (raw)
In-Reply-To: <BAY103-F2DAC914A1FB677D5AFCC1D5E90@phx.gbl>
References: <BAY103-F2DAC914A1FB677D5AFCC1D5E90@phx.gbl>

Use pg_copy_to and pg_copy_from instead...

Chris

Simon Hewitt wrote:
> Hi all,
> 
> I am currently working on an application that will input multple lines 
> into a Postgre database. I am using the following code
> 
>  $sql = "COPY table_2 FROM STDIN DELIMITER AS '\t'";
>  pg_query($dbc, $sql);
>  $sql = $data1."\t".$data2."\t".implode("\t", 
> $data)."\ttrue\t05-05-2005\n";
>  pg_put_line($this->dbc, $sql);
>  if(!pg_put_line($dbc, "\\N"))
>  {
>    pg_end_copy($dbc);
>    $error_message('Could not enter details');
>  }
>  else
>  {
>     pg_end_copy($this->dbc);
>     unset($data);
>  }
> 
> This gives me an example line like
> 
> 57    BELF    254    0    10877    5138    0    0    true    05-05-2005
> 
> To go into a table with fields INT, CHAR(4) INT, INT, INT, INT, INT, 
> INT, BOOL, DATE
> 
> However, its not going in...
> 
> I'm getting an error
> 
> ERROR:  missing data for column "col2"
> 
> With no data being inserted.
> 
> If anyone could point out where I'm going wrong I'd be forever in their 
> debt
> 
> Thanks
> 
> Simon
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
> 
>               http://archives.postgresql.org



view thread (4+ messages)  latest in thread

Message-ID: <42B6D450.50106@familyhealth.com.au>
Permalink:  ../42B6D450.50106@familyhealth.com.au/
Also on:    postgresql.org/message-id/42B6D450.50106@familyhealth.com.au

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: chriskl@familyhealth.com.au, simon.hewitt@greenhill-ymca.org
  Subject: Re: pg_put_line() Frustration
  In-Reply-To: <42B6D450.50106@familyhealth.com.au>
  References: <BAY103-F2DAC914A1FB677D5AFCC1D5E90@phx.gbl> <42B6D450.50106@familyhealth.com.au>

* 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