MySQL Forums
Forum List  »  Newbie

Using a Parameter in Load Data Infile Command (Instead of direct filename)
Posted by: Dhaval Sheth
Date: July 27, 2009 06:15AM

Hello,

I was wondering if we can have a parameter passed to the load data infile command rather than direct file name

Something like:

load data infile @input_file_name into table tab_name
fields terminated by '|'
lines terminated by '\n'
ignore 1 lines
(@dummy1, @dummy2)
set col1 = trim(@dummy1),
col2 = trim(@dummy2); show warnings;

and @input_file_name = 'c:/test/file1.txt'



I have tried following things but with no luck:


1.
set @input_file_name = 'c:/test/file1.txt';
load data infile @input_file_name into table tab_name....


2.set @input_file_name = 'file1.txt';
select @input_file_name;
load data infile concat('c:/test/',@input_app_file_name) into table....

What I want is my file1.txt or maybe entire path 'c:/test/file1.txt' should be given as parameter to load data infile.


Please let me know other possibilities.

Thanks,
Dhaval

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.