Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Need to read date field from table in BTEQ on UNIX

Need to read date field from table in BTEQ on UNIX

Need to read date field from table in BTEQ on UNIX


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
cust_date between Control_table.run_date -2 and control_table.run_date

.export reset

update control_Table
set run_date = run_date +2;

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?

RE: Need to read date field from table in BTEQ on UNIX

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

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

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close