SDAC 4.50 DefaultExpression error

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
RandySill
Posts: 14
Joined: Sat 21 Oct 2006 11:42

SDAC 4.50 DefaultExpression error

Post by RandySill » Thu 19 Jun 2008 14:18

The latest 4.50 releases (0.34 and 0.35) as well as 4.35 have a defect using DefaultExpression to populate data fields on Append. If TMSQuery fields have a default expression and you execute the method Append, you immediately get an error "Invalid Field 'False', Invalid Field P...". For some reason, the component is trying to do a “SELECT False, False, P, 0, True” statement during the append statement with all the default values of any fields that have one.

Any one else experience this issue?

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Fri 20 Jun 2008 08:22

You should quote default expression values if you do not want them to be requested from the server. For example, 'True' instead of True, 'P' instead of P, etc. But there is no need to quote numbers.
In the next build of SDAC we are planning to add recognizing unquoted True/False values in DefaultExpression.

RandySill
Posts: 14
Joined: Sat 21 Oct 2006 11:42

Post by RandySill » Fri 20 Jun 2008 11:49

That's not the behavior of 4.10 and previous. When I set the DefaultExpression value of a string field to a quoted value such as 'P', the quotes are getting added to the data field. If I quote a boolean field with 'False' or 'True', I get an error that 'False' is not a valid boolean value for field 'IsCompany'. Is SDAC now fetching default values from the server to pre-populate in an Append? I currently don't have default values at the server and this will be quite an extensive change to upgrade if this is now normal behavior. What version did this change take place?

RandySill
Posts: 14
Joined: Sat 21 Oct 2006 11:42

Post by RandySill » Fri 20 Jun 2008 12:19

Ok, I re-upgraded to 4.50.0.35 and see how DefaultExpression is now used. This behavior now makes SDAC different than standard DataSet components in the way DefaultExpression values are handled. It also makes another round trip to SQL Server for an append. I can see some nice capability in using a feature like this, but if it were me, I would have made it an alternate property or possibly an option. I will have to change thousands of values to be compliant with this new change which makes this a breaking upgrade. Is there any way to disable this method of fetch? I must now change every instance of boolean defaults (True and False) to 1 and 0 as these are the SQL values.

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Fri 20 Jun 2008 12:55

You should change the DefaultExpressionOldBehavior variable to True somewhere in your program to return the old behavior with default expressions.

RandySill
Posts: 14
Joined: Sat 21 Oct 2006 11:42

Post by RandySill » Fri 20 Jun 2008 13:12

Awesome! That's a life saver. Thanks for the reply.

Post Reply