File export from BTEQ

General
Enthusiast

File export from BTEQ

How to creat a new fresh export file after running the bteq script. Don't want to manually delete the existing file and not willing to append the new record to the existing one.

.EXPORT report File = directory_path/XYZ.txt

this will append output record every time the script will run...I don't want this.

Thanks,

Banerjee

4 REPLIES
Junior Supporter

Re: File export from BTEQ

HI.

.OS rm -f directory_path/XYZ.txt;

.EXPORT report File = directory_path/XYZ.txt;

...

HTH.

Cheers.

Carlos.

Enthusiast

Re: File export from BTEQ

Thanks man..this will work..but my requirement was not to delete the entire file and just empty the file content.

I think this will be more appropriate..since I dont know whether the .EXPORT command with some option can handle this or not.

cat /dev/null > directory_path/XYZ.txt

Thanks,

Banerjee

Teradata Employee

Re: File export from BTEQ

Much appropriate way of doing this is to check the file if it exists. 

-- If condition to check if the files exists; If it does then remove it.

.OS IF [ -f directlry_Path/XYX.txt]; then

.OS rm -f directory_path/XYZ.txt; 

fi;

NOTE: BTEQ doesn't support multi line OS commands. This is how you would use it in bteq

.OS IF [ -f directlry_Path/XYX.txt];  then rm -f directory_path/XYZ.txt; fi;

Re: File export from BTEQ

Wow!! superb, this may help me alot, thanks for it.