Jump to content

FireDac Select with parameter, how to renew

Recommended Posts


I have searched for 'simple' stuff in using FireDac but havn't found the answer to the following, which would save me lots of keying ...


I have a datamodule with a fdQuery & Datasource, and the fdQuery has the following:

'Select * from tTable  where Company = :pC order by oOrderName' - so a parameter is created in the query.


If in my code I want to set the query to different values do I have to do the select statement again in it's entirety, like:

dm.fdc.Open( 'Select * from tTable  where Company = :pC order by oOrderName', [ 'Debenhams'] );

Or can I simply specify the new parameter value like:

dm.fdc.Open( '', [ 'Woolworths' );

Share this post

Link to post

This should work:

dm.fdc.Param.ParamByName('pC').asString := 'Woolworth';


Share this post

Link to post



This was a question I had in mind for a long time. I used to use, like ergeka

and, even, closing the query before (old BDE comportment)





So, today, I make a little test and :classic_huh: Firedac is really an amazing thing


dm.fdc.Open,('',[ 'Woolworths' ]);

works. One only line versus 2 (three in my case) and shorter than this ParambyName stuff. 

I certainly use this for now 😉 

By the way I test also this query

Select * from tTable  where Company = ? order by oOrderName 

a no named parameter. It works too 👍

Share this post

Link to post

Many thanks, both - I will certainly use these methods. The shorter version Serge mentioned I saw in a YouTube on Tips & Tricks by Dmitry Arefiev CodeRage 9.

Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now