setting BTEQ Import attribute dynamically

Tools

setting BTEQ Import attribute dynamically

I am having a situation where I have to load some data from a txt file via BTEQ, but the problem is that the file file location and name is dynamic and is always available in a table.

I just want to know that is it possible to have some sort of select statement in .IMPORT

I think this could be a very generic issue and somebody out there would have faced the same problem. So any suggestions that could help me.

Regards.
3 REPLIES

Re: setting BTEQ Import attribute dynamically

If you are doing it from Unix/Linux, you can do it in two stages.

first bteq to get the filename and path from the control table

bteq <<-END

.login......

.set ....... (turn of title dashess etc ..)

.export file=filename.txt;

SELECT TRIM(FILENAME) (TITLE '') FROM CTLTBL;

.quit;
END

FILENAME=$(cat filename.txt)

This bteq can import file ...

bteq <<-END

.import file = ${FILENAME}

END

Re: setting BTEQ Import attribute dynamically

Thanks for the reply.
But we are using windows.
Teradata Employee

Re: setting BTEQ Import attribute dynamically

EXPORT a ".IMPORT" statement to a temp file and .RUN that, e.g.

.set format off
.export report file=importcmd.txt
SELECT '.IMPORT DATA FILE='||FILENAME (TITLE '') FROM CTLTBL;
.export reset
.run file=importcmd.txt