MySQL Forums
Forum List  »  Newbie

Re: Using a Parameter in Load Data Infile Command (Instead of direct filename)
Posted by: Jay Alverson
Date: July 29, 2009 09:53AM

Dhaval Sheth Wrote:
-------------------------------------------------------

> mysql -u root -p -e "set
> @col_value:='filename.txt'; source test.sql;"
>
> Thanks,
> Dhaval

In DOS/command interpreter you can use the FOR command to execute repetitive
commands that will loop thru a SET of filenames...

for %f in (filename1.txt, filename2.txt, filename3.txt) do echo mysql -u root -p -e "set @col_value:='%f'; source test.sql;"

will give you:

J:\Temporary>for %f in (filename1.txt, filename2.txt, filename3.txt) do echo mysql -u root -p -e "set @col_value:='%f'; source test.sql;"

J:\Temporary>echo mysql -u root -p -e "set @col_value:='filename1.txt'; source test.sql;"
mysql -u root -p -e "set @col_value:='filename1.txt'; source test.sql;"

J:\Temporary>echo mysql -u root -p -e "set @col_value:='filename2.txt'; source test.sql;"
mysql -u root -p -e "set @col_value:='filename2.txt'; source test.sql;"

J:\Temporary>echo mysql -u root -p -e "set @col_value:='filename3.txt'; source test.sql;"
mysql -u root -p -e "set @col_value:='filename3.txt'; source test.sql;"

J:\Temporary>

Just get rid of the ECHO command.

You can use FOR in a .bat file, just change the %f to %%f.

Is that what you mean ?

The help file for the command interpreter can be found on my PC at:

C:\WINDOWS\hh.exe C:\WINDOWS\Help\ntcmds.chm::/ntcmds.htm

>

Thanks, Jay

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.