Hi,
I'm having trouble getting my head round how you use a CASE statement to provide conditions for a WHERE clause.
i have this...
I have now read that
So I'm totaly lost over how I convert the above logic into a valid CASE statement.
Perhaps I shouldn't be using CASE ?
All help understanding how I add logic and selectable parts of a where statements based on the value of input parameters is appreciated.
cheers,
1DMF
"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
MIME::Lite TLS Email Encryption - Perl v0.02 beta
I'm having trouble getting my head round how you use a CASE statement to provide conditions for a WHERE clause.
i have this...
Code:
WHERE (Ins_Lnk Is Null) AND
CASE @SType
WHEN 'Paid' THEN "(Status <> 'NPW') AND "
WHEN 'UnPaid' THEN "(Status <> 'NPW') AND "
WHEN 'ClawBack' THEN "(Clawback_Date IS NOT NULL) AND "
END
CASE @LDate
WHEN 'NULL' THEN "(Lender_Date IS NULL) AND "
WHEN 'NOT NULL' THEN "(Lender_Date IS NOT NULL) AND "
END
(Adv_MemNo <> 'TEST_ACC')
ORDER BY CompanyName ASC
I have now read that
It's important to understand that in SQL, CASE is an expression and not an executable "control-of-flow" statement.
So I'm totaly lost over how I convert the above logic into a valid CASE statement.
Perhaps I shouldn't be using CASE ?
All help understanding how I add logic and selectable parts of a where statements based on the value of input parameters is appreciated.
cheers,
1DMF
"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
MIME::Lite TLS Email Encryption - Perl v0.02 beta