DefaultExpression not working with all fields

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
DDlopez
Posts: 10
Joined: Tue 25 Aug 2020 06:47

DefaultExpression not working with all fields

Post by DDlopez » Wed 24 Nov 2021 13:19

Hi you all,

We were using ODAC version 6.25 on Delphi 2006 . We purchased the latest version of ODAC 11.2.5 and we have migrated all our clients with little problem and now they are all working fine after a bit of fine-tuning.

But we have a problem that has struck us just now, related to DefaultExpression.

The problem is that we have one form (for now) where DefaultExpression only works in some fields, but not in all fields and when I insert a new record some of the fields that have DefaultExpression with values are empty (null) but the others work just fine.

We've compiled the project with ODAC version 6.25 and the problem is gone, so I assume that there is some kind of problem or configuration that I'm not aware of.

Can you help me?

Thanks in advance.

DDlopez
Posts: 10
Joined: Tue 25 Aug 2020 06:47

Re: DefaultExpression not working with all fields

Post by DDlopez » Thu 25 Nov 2021 12:25

Ok, I've been doing some testing and I think I narrowed the problem.

The property DefaultValues is True in the TOraquery where I'm having problems.

I tried changing to false, but now some fields are null because they don't have DefaultExpression nor Default Value in DB.

Is there a param to force the old behavior? Usually, you have one.

Thanks in advance.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: DefaultExpression not working with all fields

Post by MaximG » Sun 28 Nov 2021 19:08

Starting with ODAC 6.50, the default value of DefaultValues is False. We made the change to improve the performance of ODAC since with DefaultValues=Trues, an additional query is made to the data dictionary to retrieve the default values of fields. To revert the behavior, you need to set DefaultValues to True.

DDlopez
Posts: 10
Joined: Tue 25 Aug 2020 06:47

Re: DefaultExpression not working with all fields

Post by DDlopez » Mon 29 Nov 2021 06:55

Thank you!

But I think something more is different, because if I just change to false still is not working, but if I revert to ODAC 6.25 it works again.

I detail my case:
  • I have a TOraQuery with DefaultValues = True
  • I have some fields with DefaultExpression filled, in particular I have one field with DefaultExpression = S
  • This particular field in my database table is declared as Not Null, but has no DEFAULT value.
As explained in the documentation of DefaultValues with the latest ODAC it's working this way:
If True, the default values/expressions are requested from the server and assigned to the
DefaultExpression property of TField objects replacing already existent values.
But after testing it, I think it was working differently with ODAC 6.25. I think it replaced values in DefaultExpression but only if the values were NOT NULL.

Does this make any sense to you?

It would be very helpful to find a way to not make changes to our forms because we have more than 70 with DefaultValues = True that we have to check.

Could you check it again with my information, please?

Thank you

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: DefaultExpression not working with all fields

Post by MaximG » Mon 06 Dec 2021 08:44

Please, in order to investigate the issue, compose and send us a small sample, execution of which causes the mentioned problem. In addition, we will need DDL script to create DB objects used in this sample. For your convenience, please use the e-support form https://www.devart.com/company/contactform.html

DDlopez
Posts: 10
Joined: Tue 25 Aug 2020 06:47

Re: DefaultExpression not working with all fields

Post by DDlopez » Tue 07 Dec 2021 12:36

Thank you, but it was an urgent issue and we have fixed it manually in order to proceed.

We don't use DefaultValues = True in most forms, so maybe we don't have this problem again.

Thank you.

Post Reply