String attribute overflowing
No edit summary
(Automatically adding template at the end of the page.)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
If you MDrivenServer log contains errors like
If your MDriven Server log contains errors like:
  String or binary data would be truncated
  String or binary data would be truncated
You have OCL code or a part of your system in general that puts a too long text into a attribute and then tries to save it.
You have OCL code, or a part of your system generally puts too-long text into an attribute and then tries to save it.


The rest of the message might be like
The rest of the message might be like this:
  @errorinfo=S_OutgoingEmail.SS_OutgoingEma... (length=1153) (System.String) (DbType: String)
  @errorinfo=S_OutgoingEmail.SS_OutgoingEma... (length=1153) (System.String) (DbType: String)
In this example, the problem is that the serverside email action gets an exception and tries to write that error message to a too short string attribute.
In this example, the problem is that the serverside email action gets an exception and tries to write that error message to a too-short string attribute.


You have two options, and you should probably use both;
You have two options, and you should probably use both:
# Make the string attribute longer to capture what you want to store
# Make the string attribute longer to capture what you want to store
# Include code that makes sure you don't overflow the attribute
# Include code that makes sure you don't overflow the attribute
Use the following OCL to always ensure that you never try to write a too long string.
Use the following OCL to ensure that you never try to write a too-long string:
  <attribute>.subString(1,<attribute>.maxLength-1)
  <attribute>.subString(1,<attribute>.maxLength-1)
For the example above;
For the example above:
  self.errorinfo.subString(1,self.errorinfo.maxLength-1)
  self.errorinfo.subString(1,self.errorinfo.maxLength-1)
See also: [[OCLOperators maxLength|maxLength]]
See also: [[OCLOperators maxLength|maxLength]]
[[Category:Error messages]]
[[Category:Error messages]]
{{Edited|July|12|2024}}

Latest revision as of 15:47, 10 February 2024

If your MDriven Server log contains errors like:

String or binary data would be truncated

You have OCL code, or a part of your system generally puts too-long text into an attribute and then tries to save it.

The rest of the message might be like this:

@errorinfo=S_OutgoingEmail.SS_OutgoingEma... (length=1153) (System.String) (DbType: String)

In this example, the problem is that the serverside email action gets an exception and tries to write that error message to a too-short string attribute.

You have two options, and you should probably use both:

  1. Make the string attribute longer to capture what you want to store
  2. Include code that makes sure you don't overflow the attribute

Use the following OCL to ensure that you never try to write a too-long string:

<attribute>.subString(1,<attribute>.maxLength-1)

For the example above:

self.errorinfo.subString(1,self.errorinfo.maxLength-1)

See also: maxLength

This page was edited 96 days ago on 02/10/2024. What links here