Fastexport: a variable as name of my file
Teradata Teradata Discussion Forums Teradata.com Discussion Forum
Visit Teradata.com
Home       Guidelines    Member List
Welcome Guest ( Login | Register )
        


This online forum is for user-to-user discussions of Teradata products, and is not an official customer support channel for Teradata. If you require direct assistance, please contact Teradata support.


Fastexport: a variable as name of my file Expand / Collapse
Author
Message
Posted 6/10/2008 5:41:13 AM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 6/16/2008 11:49:56 AM
Posts: 17, Visits: 68
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!
Post #11792
Posted 6/10/2008 6:24:24 AM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 6/16/2008 11:49:56 AM
Posts: 17, Visits: 68
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
Post #11793
Posted 6/10/2008 9:07:21 AM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 6/16/2008 11:49:56 AM
Posts: 17, Visits: 68
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
Post #11794
Posted 6/12/2008 1:47:17 PM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Today @ 9:31:30 PM
Posts: 427, Visits: 403

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

Post #11830
Posted 6/16/2008 11:53:50 AM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 6/16/2008 11:49:56 AM
Posts: 17, Visits: 68
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 ++
Post #11889
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 ( 0 guests, 0 members, 0 anonymous members )
No members currently viewing this topic.


All times are GMT -5:00, Time now is 10:04pm

Powered By InstantForum.NET v4.1.4 © 2008
Execution: 0.063. 7 queries. Compression Disabled.