TooMuchCoffee
Programmer
Hello all,
I'm working with Visual FoxPro 6. I've learned that I have have to do my SQL statements inside a program because if I use the view or query generator, the various joins get messed up or the field length of my IIF statements are too long. Anyway.
Here is a sample SQL (program?) that I'd like to convert some of the IIF statemnts:
So that's a pretty ugly IIF statement. I haven't programmed in VFP in years and my skills are lacking. I'm looking for a resource that shows how to use a CASE statement inside of a SQL query that's in a VFP 6 program.
I keep trying something like this:
... but I can't get the syntax correct. Any ideas?
Thx.
AWS
I'm working with Visual FoxPro 6. I've learned that I have have to do my SQL statements inside a program because if I use the view or query generator, the various joins get messed up or the field length of my IIF statements are too long. Anyway.
Here is a sample SQL (program?) that I'd like to convert some of the IIF statemnts:
Code:
CREATE SQL VIEW vewBase AS SELECT _MFD.empno AS ID,;
...;
IIF((EMPTY(_MFD.CTDate).AND.CTOD(_MFD.chdate)<CTOD('01/01/2012')).OR.(EMPTY(_MFD.CTDate).AND.CTOD('12/31/2013')-CTOD(_MFD.becamemgr)=>365.25),IIF((CTOD('12/31/2013')-CTOD(_MFD.CHDate))/365.25>=3 AND Job $ '45'.AND.YEAR(CTOD(_MFD.becamemgr))<=2012,3,IIF((CTOD('12/31/2013')-CTOD(_MFD.CHDate))/365.25>=2,2,1)),0) AS EligWks;
So that's a pretty ugly IIF statement. I haven't programmed in VFP in years and my skills are lacking. I'm looking for a resource that shows how to use a CASE statement inside of a SQL query that's in a VFP 6 program.
I keep trying something like this:
Code:
CREATE SQL VIEW vewBase AS SELECT _MFD.empno AS ID,;
[indent][/indent]...;
[indent]DO CASE[/indent]
[indent]CASE <field> = <some value> <do some action>;[/indent]
[indent]CASE <field> = <some value> <do some action>;[/indent]
[indent]ENDCASE AS <somefieldname>;[/indent]
FROM...
... but I can't get the syntax correct. Any ideas?
Thx.
AWS