load data infile @File
am 26.10.2004 12:11:42 von Stanley
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
select version();
+------------+
| version() |
+------------+
| 4.0.21-log |
+------------+
--
MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs
To unsubscribe: http://lists.mysql.com/bugs?unsub=gcdmb-bugs@m.gmane.org
Re: load data infile @File
am 27.10.2004 18:22:23 von Sergei Golubchik
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
/ /|_/ / // /\ \/ /_/ / /__ 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/bugs?unsub=gcdmb-bugs@m.gmane.org