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


Teradata SQL help

Teradata SQL help

Teradata SQL help

I am in a odd situation. Following is my query running against the dataset as show below:

Select name from table_name
where (send_yn='Y' or send_yn='N') and (last_chnage_dt = date -1)
and (last_change_dt > sent_system_dt OR sent_system_dt is null)

Users via front end manipulates send_yn (by marking it Y and N) and in doing so last_change_dt also gets update for current time and date. This SQL is wrapped within a unix shell script. Once a user marks a record Y or N all records belonging this person with flag Y (name) will be extracted via this SQL and sent to another system. So the trigger is marking Y or N. Once the records are sent sent_system_dt gets update with current time and stamp. My SQL will only work for the records that are marked a day prior (last_change_dt = date -1).

For some reason if this unix script fails to run for a day...i will be in a jam because now date-1 will not yield any records since date-1 will not return anything. How to fix this SQL to take care of issues that arise if unix shell script fails to run for certain day or two.

Name        send_yn    last_change_dt        sent_system_dt
joe smith    N        2012-03-06 10:35:33    2011-10-19 05:00:15
joe smith    N        2012-03-06 10:21:11    2011-10-19 05:00:46
joe smith    Y        2011-10-18 14:03:55    2011-10-19 05:00:15
Tom smith    N        2012-03-05 10:35:33    2011-10-19 05:00:00

Based on above data and running my SQL today i.e. 03/07/12   i get:

Joe Smith

But what is Unix script failed to run this morning ...how can a make sure that Joe Smith gets picked up during tomorrow  run i.e. 3/8/12 ?



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