Home > Archive > PHP with PostgreSQL > June 2005 > FW: pg_put_line() Frustration









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author FW: pg_put_line() Frustration
Simon Hewitt

2005-06-20, 11:24 am

>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('Coul
d 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

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com