I use LOAD DATA INFILE a lot with mySql. After go...
# sql
m
I use LOAD DATA INFILE a lot with mySql. After googling a bit (after failing my attempts at tryin CF) and finding bupkus I am here.. Can something like this statement be done via CF? Yes, I could use cffile or java.io.file, just exploring other options because this cleans up the garbage data from on older 16bit program nicely and no sense porting if I don't have to .
LOAD DATA INFILE 'E:\\dataroot\\orders\\import_orderdtl_nc.txt'
INTO TABLE _tmp_orderdtl
CHARACTER SET latin1
FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"'
IGNORE 1 LINES
(RecNo,Customer,Orderno,Item,ItemType,@OrderDate,qty, Mult,Bkord,Description,SalesTax,@Listprice,@SugRetail,@Price,@Amount,@Cost,orderStatus,Freighttype,@Freightamount,@Actualfreightcost)
SET
#dates
OrderDate=date_add(str_to_date(@OrderDate,'%c/%e/%Y'),interval -99 YEAR),
#numbers (with commas potentially)
Price=(replace(@Price,',','') + 0.0),
Amount=(replace(@Amount,',','') + 0.0),
Cost=(replace(@Cost,',','') + 0.0),
Listprice=(replace(@Listprice,',','') + 0.0),
SugRetail=(replace(@SugRetail,',','') + 0.0),
Freightamount=(replace(@Freightamount,',','') + 0.0),
Actualfreightcost=(replace(@Actualfreightcost,',','') + 0.0)
;
z
that file path in on the db server?
m
yes
z
shoudl work then
m
it works fine my mysql workbench, but I am trying to port it into a cfquery. It has been failing there. Of cource my sample attempt was a bit simpler
At this point now, its just a "good to know", I went the java.io.filereader and linenumber reader route for this and its peppy enough with < 50MB files.