X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 23B1D52894 for ; Mon, 20 Jun 2005 12:21:47 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 67358-07 for ; Mon, 20 Jun 2005 15:21:42 +0000 (GMT) Received: from hotmail.com (bay103-f22.bay103.hotmail.com [65.54.174.32]) by svr1.postgresql.org (Postfix) with ESMTP id 874FE5284B for ; Mon, 20 Jun 2005 12:21:41 -0300 (ADT) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Mon, 20 Jun 2005 08:21:41 -0700 Message-ID: Received: from 65.54.174.202 by by103fd.bay103.hotmail.msn.com with HTTP; Mon, 20 Jun 2005 15:21:40 GMT X-Originating-IP: [65.54.174.202] X-Originating-Email: [sejh79@hotmail.com] X-Sender: sejh79@hotmail.com Reply-To: simon.hewitt@greenhill-ymca.org From: "Simon Hewitt" To: pgsql-php@postgresql.org Subject: FW: pg_put_line() Frustration Date: Mon, 20 Jun 2005 15:21:40 +0000 Mime-Version: 1.0 Content-Type: text/plain; format=flowed X-OriginalArrivalTime: 20 Jun 2005 15:21:41.0031 (UTC) FILETIME=[C257AB70:01C575AB] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.829 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, FROM_ENDS_IN_NUMS, MSGID_FROM_MTA_HEADER X-Spam-Level: * X-Archive-Number: 200506/18 X-Sequence-Number: 3177 >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