Fastexport: a variable as name of my file

Database
Enthusiast

Fastexport: a variable as name of my file

Hello everyone,

I'm using Teradata FastExport tool.

in my script on this line:

.export outfile Folder/file_$filename mode record format text;

I'd like to use a variable as the name of the file i'm going to export.

In this script i'm getting the value of my $filename trough this:
filename=`cat $CHAIN1/file1.txt | awk -F";" '{print $2}'`

Well, i'm getting the correct value in the variable 'filename' but this value isn't set as part of the name of my file.

Do you know the syntax to proceed correctly ??

Thank you much!
4 REPLIES
Enthusiast

Re: Fastexport: a variable as name of my file

Well finally I got the answer.

You need to define a variable in the .profile . and to give the 'cat' value to it
Then display the $variable in the name of your file and it's ok.

But I got another question, how can you display the current date in the name of file ?

Thx
Enthusiast

Re: Fastexport: a variable as name of my file

Well, maybe my question is not very accurate.

I'd like my exported file to be called using the current date.
I tried to define a variable in the profile such as : dat_var=date '+ %m/%d/%y-%H:%M:%S'

But while trying in my fexp : .export outfile $FOLDER/$dat_var ; it doesn't work

How to include the current date in the name of my exported file ?

Thanks
Enthusiast

Re: Fastexport: a variable as name of my file


You may want to avoid using '/' and ':' in the date as certain filesystems will treat them as special characters.

Also try putting the variables in the shell script and not in the .profile where it's visible to any process...

#!/usr/bin/ksh

export dat_var=$(date '+%m-%d-%y-%H.%M.%S')

fexp <<-END

.......
.export outfile $FOLDER/$dat_var;
....

END

Enthusiast

Re: Fastexport: a variable as name of my file

Hello.

Thank you for the answer Joe even if It didn't work.

I come to offer the working answer.

It was very simple finally.

FIL_NAM=`date +'%Y%m%d'`;

.export outfile $FOLDER/$FIL_NAM mode record format text;

and the name of the exported become the current_date.

Your faithfully ++