Bug #61984 vars not allowed in load data infile
Submitted: 26 Jul 2011 12:56 Modified: 26 Aug 2011 23:23
Reporter: stephen bond Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: General Severity:S4 (Feature request)
Version: OS:Any
Assigned to: CPU Architecture:Any
Tags: LOAD DATA INFILE, set variable

[26 Jul 2011 12:56] stephen bond
Description:
I would like to be able to set variables in a load data statement eg

set @prevacc='';set @dum1=0;
load data infile 'g:/Temp/T111.csv'
into table T2011
fields terminated by ',' optionally enclosed by '"' lines terminated by '\n' ignore 1 lines
(  @acc, @ym1,
)
set ym=concat(substring(@ym1,1,4),'-',substring(@ym1,5,6),'-01'),
@dum1= (case when @acc~=@prevacc then @dum1+1 else @dum1 end),
id=@dum1,
@prevacc=@acc;

this would allow me to replace a 40 char acc field with an integer id on loading.

How to repeat:
$ head EX111.csv
ACCOUNTID,YEARMONTH
4584F6B1A21791A6642970C89BB56A0C,200310
45888F52CCF759C2D34469B68E678FE9,200310
45890CE042D08F7D4812AE55E9B825A2,200310
458B0C83928E47B7163EF9FB7C929F6B,200310
458F323548FA74193C2857B009CC3D46,200310
[26 Jul 2011 13:14] MySQL Verification Team
Check for duplicate: http://bugs.mysql.com/bug.php?id=39115. Thanks.
[26 Aug 2011 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[26 Aug 2011 23:23] MySQL Verification Team
Duplicate of http://bugs.mysql.com/bug.php?id=39115.
[12 Jan 2016 0:43] Josh Klein
As mentioned, this and other bugs are duplicates of http://bugs.mysql.com/bug.php?id=39115. Unfortunately this bug was never addressed. It was marked 'Verified' 2 days after it was posted.

Clearly this is still a problem as other bugs wouldn't keep being opened for the same issue and duplicated to that one.

The status 'Verified' on http://bugs.mysql.com/bug.php?id=39115 needs to be corrected to reflect that this feature was never implemented. Failing that, it'll never show up on the in the developers' backlog and this cycle will continue.