FW: pg_put_line() Frustration
am 20.06.2005 17:21:40 von Simon Hewitt>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
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster