Thread: COPY problem

COPY problem

From
Varun Kacholia
Date:
hi,
  I am using the Pg.pm module to interact with the db from perl.
Using it i am facing a wierd problem in using the "COPY from" command.
The command works when used from the psql prompt but gives the following
error when called using perl.

 ERROR:  parser: parse error at or near ".9"

This rules the possibility that it is unable to open the file or something
like that.As far as parsing goes , shudnt it be same when called from
the psql prompt and  perl.

A sample line from the file
1<tab>192.168.9.65<tab>485171<tab>/lib/<tab>ld-2.2.5.so<tab>15<tab>Sep 4 2001    0<tab>1<tab>word\n
(where tab is replaced by actual <tab>)

the table looks like is :
int2   varchar         int        varchar      varchar      int2    varchar     int2  int2  varchar
(for the respective fields above)

the call from perl looks like
$result=$conn->exec("COPY dbmisc FROM \'/copypages/filename\'");

I think it is giving error in parsing "192.168.9.65" .
Cant understand y this error is not given when called from psql prompt?
I am using the pgsql-7.2 (from redhat 7.3) with Redhat 7.2 (is it due to this?).
Please help
--
------
Varun
Why do the people who know the least know it the loudest?


Re: COPY problem

From
Tom Lane
Date:
Varun Kacholia <varunk@cse.iitb.ac.in> writes:
> The command works when used from the psql prompt but gives the following
> error when called using perl.

>  ERROR:  parser: parse error at or near ".9"

This sure looks like the contents of the data file are being fed to the
main SQL parser (and not the COPY code at all).  Perhaps Perl is doing
some sort of weird interpolation on your command string?

            regards, tom lane