Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to read date field from table in BTEQ on UNIX

Status
Not open for further replies.

aka2007

IS-IT--Management
Apr 18, 2007
1
0
0
US
Hi,

I have following bteq script to export some data on Unix enviornment. run_date I am getting from teradata Control date table:

.export report file ='export_file_name'

Select ****
FROM *,*,*,*,control_table
WHERE
cust_date between Control_table.run_date -2 and control_table.run_date
;

.export reset

update control_Table
set run_date = run_date +2;
.quit;

I want to attach Control_table.run_date to the export file name so my export file command would look like:

.export report file ='Control_table.run_date.export_file_name'

file name I would like to be for example: 20070418.export_file_name

Any solution?
AKA

 
you need two bteq scripts inside your Unix shell script :

# Prepare the tmp.sh script and get the run_date value
bteq << first
.logon ??
.export report file ='tmp.sh'
SELECT 'export run_date=' || (run_date (format '??'))
FROM control_table
;
.export reset
.quit 0
first

# Execute the tmp.sh script wich sets the run_date variable
chmod +x tmp.sh
tmp.sh
rm tmp.sh

# Execute your export script
bteq << second
.logon ??
.export report file ='${run_date}.export_file_name'
...
.quit;
second

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top