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

Michael Van Canneyt michael at freepascal.org
Thu Apr 7 14:03:40 CEST 2016



On Thu, 7 Apr 2016, Luiz Americo Pereira Camara wrote:

> I enconter the following pattern frequently (simplified):
>
> SQL:
> Select * From Customers Where FieldX = 1
>
> Later i need a similar query that uses a different filter like
>
> Select * From Customers Where FieldX = 1 and FieldY = :paramy
>
> Is there any code that given a SQL Template would generate the second
> filter when paramy is available and keep blank when not available?
>
> Like
> Select * From Customers Where FieldX = 1 ${paramtemplate paramy}
>
> The param not necessarily have to be in TParams, in my case the param is
> both in a JSON object and in TParams

I have not found such code. I rolled my own.

Michael.



More information about the fpc-pascal mailing list