[Solved] Setting a query parameter  

  RSS

sdaberle
New Member
Joined: 3 months  ago
Posts: 3
8 August 2017 17:18  

Greetings. I attended the ColumbusEgg4Delphi webinar and was impressed. I'm starting to look at incorporating it into my applications and I have a newbie question: how would I incorporate setting a query parameter into the ColumbusModule attached to a dataset?

Example: suppose I want to count the records (or derive some other aggregate function) satisfying a particular condition (similar to the CalcCaliforniaPersons example given in the ColumbusPrimer example) but I don't want to just loop through the dataset one record at a time -- there may be many many records. Ordinarily I would build a query like SELECT COUNT(*) FROM MyDataSet WHERE ConditionValue = :Value; and then set ParamByName('Value').Value as desired. But ColumbusModule doesn't know whether my DataSet is a query and so has no way of setting a parameter value.

I could typecast the DataSet in my ColumbusModule as a query type, but that would mean goodbye to loose coupling. It looks to me like my best approach may be to define a procedure in the ColumbusModule -- call it SetConditionValue -- and link it to a procedure in my data module or form that operates on the query. Am I on the right track? Or should I be triggering this through a Listener? 


ReplyQuoteLikeReport
Daniele Teti
Eminent Member
Joined: 8 months  ago
Posts: 46
4 September 2017 22:54  

Sorry for the delay. Did you solve the problem?

 

DT

Daniele Teti
CEO & CTO @ bit Time Professionals
Embarcadero MVP
Books Author


ReplyQuoteLikeReport
sdaberle
New Member
Joined: 3 months  ago
Posts: 3
23 October 2017 20:30  

Thanks for responding! I have approached this in different ways depending on context. 

In most cases, where there is one parameter with one value, I use a generic SetKeyValue procedure, available through a separate utility unit, that works on both Table and Query datasets. That way my Columbus unit doesn't need to know its dataset type -- it just calls the procedure and goes from there. 

In cases where the query is more complex, perhaps with multiple key/parameter values, I usually devise a specific procedure to set these values in the unit that contains the dataset. I then pass this procedure as a parameter when creating the ColumbusModule object. 


ReplyQuoteLikeReport
sdaberle
New Member
Joined: 3 months  ago
Posts: 3
23 October 2017 20:30  

Thanks for responding! I have approached this in different ways depending on context. 

In most cases, where there is one parameter with one value, I use a generic SetKeyValue procedure, available through a separate utility unit, that works on both Table and Query datasets. That way my Columbus unit doesn't need to know its dataset type -- it just calls the procedure and goes from there. 

In cases where the query is more complex, perhaps with multiple key/parameter values, I usually devise a specific procedure to set these values in the unit that contains the dataset. I then pass this procedure as a parameter when creating the ColumbusModule object. 


ReplyQuoteLikeReport
  
Working

Please Login or Register