pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Simon Hewitt <sejh79@hotmail.com>
To: pgsql-php@postgresql.org
Subject: FW: pg_put_line() Frustration
Date: Mon, 20 Jun 2005 15:21:40 +0000
Message-ID: <BAY103-F222BCD3B11F8F037B7E672D5E90@phx.gbl> (raw)

>It's PostgreSQL or Postgres, not Postgre.

Apologies - combination of Monday and lazy fingers

>  if(!pg_put_line($dbc, "\\N"))

>The last line above attempts to add a row with a single NULL value, so you 
>get an error about missing data for the other columns.  What's the purpose 
>of that line?

:$ - The purpose of this line is to send the NULL value as laid out in the 
comments of pg_copy_from and not pg_put_line... Apologies - my mistake

The code is now working by correcting the NULL value. The code is now

  $sql = "COPY table_2 (f1, f2, f3, f4) FROM STDIN DELIMITER AS '\t'";
  pg_query($dbc, $sql);
  $sql = $data1."\t".$data2."\t".implode("\t", $data)."\n";
  pg_put_line($dbc, $sql);
  if(!pg_put_line($dbc, "\\N"))
  {
    pg_end_copy($dbc);
    $error_message('Could not enter details');
  }
  else
  {
     pg_end_copy($dbc);
     unset($data);
  }

In response to Chris Kings response, the reason that I am using put_line as 
opposed to copy_from is because I want to limit the fields that are being 
entered. In the example above I am now entering data only into 4 fields.

Apologies for abusing the lists time - promise to drink some caffeine before 
posting next time. Hope the example is at least semi useful to someone

Thanks again

Simon





view thread (4+ messages)

Message-ID: <BAY103-F222BCD3B11F8F037B7E672D5E90@phx.gbl>
Permalink:  ../BAY103-F222BCD3B11F8F037B7E672D5E90@phx.gbl/
Also on:    postgresql.org/message-id/BAY103-F222BCD3B11F8F037B7E672D5E90@phx.gbl

 · 

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: sejh79@hotmail.com
  Subject: Re: FW: pg_put_line() Frustration
  In-Reply-To: <BAY103-F222BCD3B11F8F037B7E672D5E90@phx.gbl>
  References: <BAY103-F222BCD3B11F8F037B7E672D5E90@phx.gbl>

* 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