user2755209
user2755209

Reputation: 85

For Files in .... mysql update

I have a batch process that looks like this:

for /F %%a in (Files_april.txt) do (BlaBla_filedecryptionv3.exe -i FullRefresh_%%a.afi -k keys.txt -l customer_layout.txt -o customer_%%a.txt -t d -d \124)
mysql -q -h beast --port=3310 -u jxxxx --password="xxxx" di < load_april.sql
mysql -q -h beast --port=3310 -u xxxxx --password="xxxx" di < exportapril.sql > april.txt

I was wondering if it is possible to take the same idea of the %%a that I used to decrypt the files in a mysql qry.

The load_april.sql looks like:

    load data local infile 'W:\\New DLP\\customer_20140331_0.txt' into table  di.dlp_monthly_201404
fields terminated by '|'
lines terminated by '\r\n';
    load data local infile 'W:\\New DLP\\customer_20140331_1.txt' into table  di.dlp_monthly_201404
fields terminated by '|'
lines terminated by '\r\n';

Where the "20140331_0" and "20140331_1" are what I want replaced so it would be something like this:

load data local infile 'W:\\New DLP\\customer_%%a.txt' into table  di.dlp_monthly_201404
    fields terminated by '|'
    lines terminated by '\r\n';

Is this possible? Any help would be great.

Upvotes: 0

Views: 32

Answers (1)

Jules
Jules

Reputation: 15199

You can include an sql query directly on the mysql command line, rather than loading it from a file. The resulting file would look something like:

for /F %%a [...]
   mysql [...] -e "load data local infile 'path\\%%a.txt' into [...]"
   [...]

Where [...] needs to be expanded according to your needs.

Upvotes: 1

Related Questions