简体   繁体   中英

Can I use mysqlimport / LOAD DATA LOCAL INFILE inside stored procedure

I am using mysqlimport to get rows from a text file to a table easily like so:

mysqlimport -u root -p --local mytest employee.txt

Can I do this from a stored procedure? All attempts so far have failed I'm afraid this may only be available using command line? The objective is to have a job call a SP, this SP extracts rows from a text file (tab delimited), then the SP compares each row with an existing table, if found it will update, else insert.

Thanking you

Stored procedures execute on the server and do not have access to remote filesystems.

A rough equivalent of this is a call LOAD DATA INFILE :

LOAD DATA INFILE 'employee.txt' INTO TABLE mytest

This requires employee.txt to reside on your server. The --local option requires the mysqlimport client to bridge that data in.

Load Data INFILE doesnt work with stored proc. you would like to use perl script or else to do this

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM