[fpc-pascal] Create dynamic SQL according to available params

Graeme Geldenhuys mailinglists at geldenhuys.co.uk
Thu Apr 7 14:20:08 CEST 2016


On 2016-04-07 13:00, Luiz Americo Pereira Camara wrote:
> If there's not in pascal, someone knows such templating in another
> languages? The hard part is getting a flexible and functional syntax

I have written such code for the tiOPF project, but it should be quick
to detach any tiOPF dependencies. The code is well unit tested too (see
the tiCriteria_TST.pas unit). The unit test code is also good for usage
examples.

It can't handle all complex cases, but is fairly good. It also has an
option to inject any SQL as-is, in case you need a complex WHERE clause.

 http://geldenhuys.co.uk/tiopf/ticriteria/index.html

In summary, you use the TtiCriteria class to add your desired criteria,
then call tiCriteriaAsSQL(...) which will generate the SQL WHERE clause
string for you.

tiOPF is available on SourceForge or Github:
   https://sourceforge.net/p/tiopf/code/ci/tiopf2/tree/

tiCriteria.pas lives in the Core/ directory.


Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp



More information about the fpc-pascal mailing list