Pavithra Rajamohan · Feb 10

What is the difference between "MAXSTRING" and "STRINGSTACK" error?


We have recently received the two following errors as part of a PDF extraction process and I am trying to figure what the difference is between the two errors?

1. ERROR <Ens>ErrException: <MAXSTRING>zGetReferralDocFromStream+30^UCLH.SIP.Operation.PBT.HTTP.V1.RefDocRequest.1 -- logged as '-' number - @' set file=object.%Get(i).file'

2. ERROR <Ens>ErrException: <STRINGSTACK>zGetReferralDocFromStream+30^UCLH.SIP.Operation.PBT.HTTP.V1.RefDocRequest.1 -- logged as '-' number - @' set file=object.%Get(i).file'

Can someone please explain what the difference is?


0 255
Discussion (4)1
Log in or sign up to continue

From the docs:

  • <STRINGSTACK> An expression is too long, there are too many expressions in an argument for a single command, or an expression contains many very long strings. Simplify the expression.
  • <MAXSTRING> There has been an attempt to specify or create a data string longer than the implementation allows. The maximum string size is 3,641,144 characters. Attempting to concatenate strings that would result in a string exceeding this maximum string size results in a <MAXSTRING> error.

MAXSTRING is always related to maximum length of 3,641,144 characters for one string (assuming long strings are enabled). STRINGSTACK can be raised in several different circumstances, including a lot of small strings, recursion and so on.

Increasing bbsiz may help avoid STRINGSTACK error, but not MAXSTRING.

In your case use streams by replacing:

set file=object.%Get(i).file


set file=object.%Get(i).%Get("file",,"stream")

Great reply, Eduard, very thorough!

Eduard, can't the MAXSTRING one also mean that you've exceeded a specified MAXLEN parameter on a string? Like if I have a Property LastName As %String (MAXLEN = 30) and you try to save the object with a 50 character last name, doesn't that also give a "MAXSTRING" error?

No. %Save never throws an exception, just returns a %Status variable. In your scenario it would return an error indicating validation failure on LastName.

Class User.Person Extends %Persistent

Property LastName As %String(MAXLEN = 30);

/// do ##class(User.Person).Test()
ClassMethod Test()
    set obj = ..%New()
    set obj.LastName = $j("", 50)
    set sc = obj.%Save()    
    w $System.Status.GetErrorText(sc)

Results in:

ERROR #7201: Datatype value ' ' length longer than MAXLEN allowed of 30
  > ERROR #5802: Datatype validation failed on property 'User.Person:LastName', with value equal to " "