User bio
404 bio not found
Member since Feb 23, 2017

If I was asked to do this the one change I would do/have done in the past is implement the class method with sql code vs object code.  Whether you are using a storage strategy based on CacheSQLStorage or CacheStorage when you open an object all of the properties that are stored in the global are "swizzled" into memory and allocated a memory location so that later on when you do you have the value.  In your specific question, you want the total of all charges from the parent.  I would do something like


&sql(select sum(Amount) into :Total FROM FreightChargesDetail where Freight=:currentID)

in truth when I have done this I've actually not used a class method at all but rather in my SQLComputeCode I would do something like

  New ParentId,Total Set ParentId={%%ID} &SQL(SELECT SUM(Amount) into :Total FROM FreightChargesDetail where Freight=:ParentId) Set {*}=$Get(Total)}, SqlComputed, Transient ];

A couple of reasons.

  • I do not see a reason to expose an interface/classmethod that gets the total as it's already satisfied by the property definition.
  • I do not believe SQLCompute code is implemented inside of a procedure  so any local variable should be New'ed so that do not flow out of the stack.
Stephen has no followers yet.
Stephen has not followed anybody yet.
Global Masters badges: