Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: StrsTrim2Len not working with ParamByName


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 3 - Last Post: Sep 27, 2017 12:18 AM Last Post By: Bo Cito
Bo Cito

Posts: 3
Registered: 8/12/10
StrsTrim2Len not working with ParamByName  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 12, 2017 11:56 PM
Hi.

Using Delphi XE7 and Tokyo with Firebird 2.5 I've come to the conclusion that StrsTrim2Len has no impact whatsoever when doing updates/inserts with TFDQuery and ParamByName, which makes oversized strings raise an exception.

My questions are:
- Is this by design?
- Are there any other approaches than to truncate all strings in code like ParamByName('Field1').AsString := SomeVar.SubString(0, 50); with the added need to keep track of the field length also?

Regards,

Mikkel Andersen
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: StrsTrim2Len not working with ParamByName  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 18, 2017 9:30 PM   in response to: Bo Cito in response to: Bo Cito
- Is this by design?

This is a bug in FireDAC, which was resolved in Tokyo 10.2.

- Are there any other approaches than to truncate all strings in code like ParamByName('Field1').AsString := SomeVar.SubString(0, 50);

Either truncate strings in your code, either raise a DB column maximum length.

--
With best regards,
Dmitry
Bo Cito

Posts: 3
Registered: 8/12/10
Re: StrsTrim2Len not working with ParamByName  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 19, 2017 5:40 AM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
Dmitry Arefiev wrote:
- Is this by design?

This is a bug in FireDAC, which was resolved in Tokyo 10.2.

- Are there any other approaches than to truncate all strings in code like ParamByName('Field1').AsString := SomeVar.SubString(0, 50);

Either truncate strings in your code, either raise a DB column maximum length.

--
With best regards,
Dmitry

Thank you for your reply, Dmitry.

I've already tested ParamByName in Tokyo 10.2 Update 1 against Firebird 2.5, and it raises an exception, so what am I actually missing, if it's supposed to be fixed? Is it required to be Prepared before using ParamByName?

Regards,

Mikkel Andersen
Bo Cito

Posts: 3
Registered: 8/12/10
Re: StrsTrim2Len not working with ParamByName  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 27, 2017 12:18 AM   in response to: Bo Cito in response to: Bo Cito
Bo Cito wrote:
Dmitry Arefiev wrote:
- Is this by design?

This is a bug in FireDAC, which was resolved in Tokyo 10.2.

- Are there any other approaches than to truncate all strings in code like ParamByName('Field1').AsString := SomeVar.SubString(0, 50);

Either truncate strings in your code, either raise a DB column maximum length.

--
With best regards,
Dmitry

Thank you for your reply, Dmitry.

I've already tested ParamByName in Tokyo 10.2 Update 1 against Firebird 2.5, and it raises an exception, so what am I actually missing, if it's supposed to be fixed? Is it required to be Prepared before using ParamByName?

Regards,

Mikkel Andersen

I asked the same question on SO, and a user took the time to investigate it. Here's the results so far: https://stackoverflow.com/questions/46283578/delphi-firedac-strstrim2len-has-no-impact-on-parambyname

Regards,

Mikkel Andersen
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02