Jump to content
Sign in to follow this  
krayna

FireDac with Postgres and Prepare()

Recommended Posts

When I use FireDac with PostgresSQL and call "myQuery.Prepare()", I often have the problem that I have to define the param data type. Is it possible to have the data type of a parameter assigned automatically?

qryWork.SQL.Text := 'select distinct(field1) from config c where c.field1 = :Name'; 
qryWork.Prepare();  // Here, I get the error, that data type of parameter 'Name' is unknown

The same code with Firebird was never a problem. Is there a setting for this? And why can Firebird (or the FB driver) handle this and Postgres can not?

 

Edited by krayna

Share this post


Link to post

You can set the datatype before prepare qryWork.Params[0].DataType:=ft...... the data type of field1.

Edited by Lajos Juhász

Share this post


Link to post

Yes, I know this, but with Firebird it was no problem even if I didn´t set the data type before calling prepare. It´s a big project and I would have to change a lot of code for this. I just wondered why this was never an issue with Firebird and now it´s a problem with PostgreSQL.

Share this post


Link to post
25 minutes ago, krayna said:

Yes, I know this, but with Firebird it was no problem even if I didn´t set the data type before calling prepare. It´s a big project and I would have to change a lot of code for this. I just wondered why this was never an issue with Firebird and now it´s a problem with PostgreSQL.

 

FireDAC is very strict. When I have moved projects from BDE and DBX that involved a lot of changes.

Share this post


Link to post
On 11/13/2024 at 5:04 AM, krayna said:

Yes, I know this, but with Firebird it was no problem even if I didn´t set the data type before calling prepare. It´s a big project and I would have to change a lot of code for this. I just wondered why this was never an issue with Firebird and now it´s a problem with PostgreSQL.

What is the data type of field1? Can you share the schema of the config table?

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
Sign in to follow this  

×