It’s the simple things in life…
Sometimes programming (and textbooks) makes me laugh (after I finish crying). Especially when I read this line in my SQL textbook:
“Oracle’s query language has structure…but they are basically the normal rules of careful English speech and can be readily understood. SQL…is an astonishingly capable tool…using it does not require an programming experience.”
So, all of you non-programmers out there. It seems then that (according to my textbook) you should all, with extreme clarity and speed, know EXACTLY what this query does:
UPDATE PARTICIPANT
SET renewal_date = (
TO_DATE(
TO_CHAR((
SELECT ADD_MONTHS((
SELECT DECODE(’1′,
(SELECT SIGN((
TO_DATE(TO_CHAR(PARTICIPANT.renewal_date, ‘MM/DD/YYYY’), ‘MM/DD/YYYY’)
) – (
TO_DATE(TO_CHAR(SYSDATE, ‘MM/DD/YYYY’), ‘MM/DD/YYYY’)
)) AS greater_equal_less FROM dual
), PARTICIPANT.renewal_date, SYSDATE
) AS the_date FROM PARTICIPANT WHERE userid = ‘testName’
), 12) AS the_future FROM dual
), ‘MM/DD/YYYY’
), ‘MM/DD/YYYY’)
)
WHERE userid = ‘testName’;
Right? I mean, if SQL is so easy to understand that it’s just like speaking English to the computer, then I don’t even need to tell you what this does, right?
It’s overly optimistic statements in introductions to complex programming language textbooks like that that make middle and upper management who take basic classes believe that programming is “easy” and “quick” and that you should be able to construct the above SQL in about 15 minutes. It took me a little over an hour and a half (with a few breaks). Granted, I have only been using SQL for TWO YEARS so I guess I’m just a noob…
By the way, if someone knows the “right” way to do what I am trying to do above (in oracle) please let me know…
Oh, and all the query does is adds 12 months to the renewal date of a member. If their renewal date is in the past, it just adds 12 months to today’s date.
Posted in computers, programming, work | No Comments »

