First, I think you are probably correct - I don't think
you need the semi-colon terminating the command when
you're submitting your command via DBI.  So try
removing the ";" that you have after the "(ID)".

Second, this is just a shot-in-the-dark (because I really
don't know what the problem is) but since you are using
qq to enclose the sqlcommands string, you shouldn't need to
escape the double quotes nor the single quotes - I'm not
sure about escaping the backslashes in "\r\n".  Try it
like this:

   my @sqlcommands=(qq{
      load data local infile "orders.txt"
           into table orders
           fields terminated by  ";"
           optionally enclosed by '"'
           lines terminated by "\r\n"
           (ID)
   });

HTH.
-- 
Hardy Merrill
Red Hat, Inc.

W. Bauer [EMAIL PROTECTED] wrote:
> Dear all
> 
> I have a problem using special characters in the Perl DBI. The following
> SQL code works without problem with mysql:
> 
>       load data local infile "orders.txt"
>           into table orders
>           fields terminated by ";" optionally enclosed by '"'
>           lines terminated by "\r\n"
>           (ID);
> 
> 
> When I try to execute it from perl as follows,
> 
>       my @sqlcommands=(qq{load data local infile \"orders.txt\"
>           into table orders
>           fields terminated by  \";\"
>           optionally enclosed by \'\"\'
>           lines terminated by \"\\r\\n\"
>           (ID);});
> 
>       foreach (@sqlcommands){
>        my $temp = $_;
>        $sth = $dbh->prepare($temp);
>        $sth->execute() or die "Couldn't execute statement: " . $sth->errstr;
>       }
> I get the following error message:
> 
> DBD::mysql::st execute failed: The used command is not allowed with
> this MySQL version. 
> 
> I guess this problem is related to the field terminated by ";" part of the command. 
> How do I need to specify the command?
> 
> Best regards, Wolfgang Bauer

Reply via email to