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


writing stock letters from a databse

writing stock letters from a databse

writing stock letters from a databse


I have a sql statement that extracts from our system all the names , addresses and dates of tenancy for a client.
Based upon that tenancy date , I have to write a letter to him informing of certain events.
ie if tenancy is 4.5 years old , in next six months they are due a kitchen refurb.

we have the wording of the letter in a database field , and based upon the timescale a different worded letter is sent.

how can I link the length of time from a sql statement

ie select DOT , (trunc(sysdate) - TRUNC(DOT)) as days from x

x can be banded from 0-30 , 31-60 , 61-180 , 181+

days as a guide to which text should be returned .



RE: writing stock letters from a databse

I'm not 100% sure what you are asking here but I'll give it a shot and please correct me
if I'm wrong. It sounds like you need to use the case statement

when trunc(sysdate) - TRUNC(DOT) > 180 then 0
when trunc(sysdate) - TRUNC(DOT) between 61 and 180 then 1
when trunc(sysdate) - TRUNC(DOT) between 31 and 60 then 2
etc ....

end letter_type
from your_table

In order to understand recursion, you must first understand recursion.

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