Procedure FindRec Parameters iStm_id, cTaxYear Local lnReturn, loMtx, loContext * Create a reference to the MTS object loMtx = Createobject("MTXAS.APPSERVER.1") loContext = loMtx.GetObjectContext() lnReturn = 0 Select Statemnt Locate For (stm_id == iStm_id) And (taxyear == cTaxYear) If Found() lnReturn = Statemnt.Id Endif loContext.SetComplete() Return lnReturn EndprocHowever, I would prefer to be more general than this.
Procedure FindRec Parameters cExpression, cTag Local lnReturn, loMtx, loContext * Create a reference to the MTS object loMtx = Createobject("MTXAS.APPSERVER.1") loContext = loMtx.GetObjectContext() lnReturn = 0 Select &&my genereric TABLE here Locate For ( cExpression ) If Found() lnReturn = &&<whatever should be returned, here> Endif loContext.SetComplete() Return lnReturn EndprocMy problem is to best use whatever index tags were available, so say the parameter cTag was optional
Procedure UpdateRec Parameters iMyId, cFldName, gValue Local loMtx, loContext, lSuccess * Create a reference to the MTS object loMtx = Createobject(“MTXAS.APPSERVER.1”) * Create a reference to the Context object loContext = loMtx.GetObjectContext() Select Statemnt If Seek(iMyId) Replace ( Alltrim(Upper(cFldName)) ) With gValue =Tableupdate(0,.T.,"statemnt") Endif * Commit the transaction if there is one * and tell MTS that we’re done using the component loContext.SetComplete() EndprocAre there any references on making a robust data layer? I'm not planning to change back ends etc, but I'd like to make a reasonably robust set of data access objects. Again, this is a small test project. I'm not looking to learn a framework, or anything. I want to understand how to do this task in fox. :)