Re: load data infile @File

Sergei Golubchik <[email protected]> Wed, 27 Oct 2004 18:22:23 +0200
Newsgroups gmane.comp.db.mysql.bugs
Message-ID <[email protected]>
Hi!

On Oct 26, Kaleta Stanley, Ing. wrote:
> 
> Hi,
> 
> it seems variable can't be used anywhere,
> even if it could be expected::
> 
> set @File=concat('/somepath/',@loaddate);
> set @File=concat(@File,'.txt');
> 
> load data infile @File
> INTO TABLE t
> FIELDS TERMINATED BY ' '
> OPTIONALLY ENCLOSED BY '"'
> (r,l,C1,C2,C3)
> ;
> 
> ERROR 1064: You have an error in your SQL syntax.  Check the manual
> that corresponds to your MySQL server version for the right syntax to
> use near '@File
> INTO TABLE t
> FIELDS TERMINATED BY ' '
> OPTIONALLY ENCL

According to the manual a syntax is

`LOAD DATA INFILE' Syntax
-------------------------
     LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'FILE_NAME.txt'
         [REPLACE | IGNORE]
         INTO TABLE TBL_NAME
...

and

User Variables
==============
User variables may be used where expressions are allowed.  ...

So, it is expected that you cannot user variable instead of filename in
LOAD DATA. If you would be possible, the syntax would be

    LOAD DATA ... expression

Regards,
Sergei

-- 
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /   Sergei Golubchik <[email protected]>
 / /|_/ / // /\ \/ /_/ / /__  MySQL AB, Senior Software Developer
/_/  /_/\_, /___/\___\_\___/  Osnabrueck, Germany
       <___/  www.mysql.com

-- 
MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs
To unsubscribe:    http://lists.mysql.com/[email protected]