Author: Ed Leafe, ed@leafe.com
Posted: 1999-08-17 at 09:12:08
On 8/17/99 8:24 AM, Wolfe Stephen S Civ GS-11 supposedly said:
> To that end I'll expose some of my raggedy ol' SQL code for your
>inspection and fruitful critique.
I'll try to be gentle. ;-)
> WHERE Staff.hosp = ?OCEobj.hosp;
> AND Staff.Squadron = ?THIS.Squadron;
> AND Staff.Off_Sym = ?THIS.OfficeSymbol;
I would be wary of using "This." is a view parameter. It forces the
view to only be used from within a method of a particular class.
Referring to a particular object name is also problematic, for the same
reason. Instead, I would write those lines:
WHERE Staff.hosp = ?vp_hosp;
AND Staff.Squadron = ?vp_Squadron;
AND Staff.Off_Sym = ?vp_OfficeSymbol;
and then in the method where the view is opened/requeried, define the
view parameter memvars from the corresponding props:
LOCAL vp_hosp, vp_Squadron, vp_OfficeSymbol
vp_hosp = OCEobj.hosp
vp_Squadron = This.Squadron
vp_OfficeSymbol = This.OfficeSymbol
USE MyView
This way, the view isn't tightly coupled with that particular object
in that particular context, but can be re-used in other situations.
> AND Lifesupp.pals_exp >= ?THIS.RPTT1;
> AND Lifesupp.pals_exp <= ?THIS.RPTT2;
Same thing applies here. If you create view parameter variables, you
can define them conditionally based upon your initial IF statement. Then
you only need one copy of the SQL to handle both situations.
___/
/
__/
/
____/
Ed Leafe