From: | "Simon Hewitt" <sejh79(at)hotmail(dot)com> |
---|---|
To: | pgsql-php(at)postgresql(dot)org |
Subject: | FW: pg_put_line() Frustration |
Date: | 2005-06-20 15:21:40 |
Message-ID: | BAY103-F222BCD3B11F8F037B7E672D5E90@phx.gbl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-php |
>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
From | Date | Subject | |
---|---|---|---|
Next Message | Raul Secan | 2005-06-23 08:18:45 | varchar error |
Previous Message | Christopher Kings-Lynne | 2005-06-20 14:36:00 | Re: pg_put_line() Frustration |