Request for help on how to capture the source file name as a column using MLOAD?

Tools & Utilities
Visitor

Request for help on how to capture the source file name as a column using MLOAD?

Hi Team, 

 

Could anyone please let me know if we can capture the filename as a column using MLOAD? Is so, could you please help me with the syntax?

 

Cheers, 

B

4 REPLIES
Junior Contributor

Re: Request for help on how to capture the source file name as a column using MLOAD?

Where do you get the filename from?

 

If it's assigned to a variable using .ACCEPT or .SET you can use it in the DML:

.ACCEPT filename FROM ...
INSERT ... (... &filename ...)

 

 

 

Visitor

Re: Request for help on how to capture the source file name as a column using MLOAD?

Hi dnoeth, 

 

Appreciate your help!

 

 

We receive a tab delimited file every day and we keep them on our local drive.  So, we would like to store the data from these files to a Teradata table along with the name of the file as a column value.

 

Junior Contributor

Re: Request for help on how to capture the source file name as a column using MLOAD?

Then write the daily file name to a text fle and use ACCEPT.
New Member

Re: Request for help on how to capture the source file name as a column using MLOAD?

SyntaxEditor Code Snippet

in config: S: <NEW_IFILE>=DIR_path/filename.txt=

SyntaxEditor Code Snippet
in mload: INSERT INTO table1(col1,filename_col
)VALUES(col1,SUBSTR('<NEW_IFILE>',35,2) as filename_col
);

SyntaxEditor Code Snippet
.IMPORT INFILE <NEW_IFILE>  -- <NEW_IFILE> is from config