Skip to main content

I'm posting this to alert anyone who's got large multivalued attributes they may want to sum in AQL.

A friend of mine logged a case recently where a correlative using the S() function would hang when the file has any items where the attribute in question has more than 32,768 values. Engineering confirmed that this is an AQL limitation because it's using a 16-bit signed variable to track the value count. This variable is used in many places in AQL, and it would be a huge task to rearchitect.

In the course of debugging this, Engineering came up with a workaround by using CALL in the correlative. This not only removed the 32,768-value limit, but it is also MUCH faster.

Example of the correlative that hangs (using multivalued attribute 9 in the example):

008 A;S(9)

Example of the correlative that works (again using multivalued attribute 9 in the example):

008 call bp sumbal

Might be a good idea to fully path the subroutine being called. Example of a subroutine in an account called "orders" in a file call "pgms":

008 call orders,pgms, sumbal

Subroutine being called from the correlative:

subroutine sumbal(rval)
values = access(3)<9>
valMax = dcount(values,@vm)
rval = 0
for x = 1 to valMax
  rval += values<1,x>
next
return



------------------------------
Brian S. Cram
Principal Technical Support Engineer
Rocket Software
------------------------------

I'm posting this to alert anyone who's got large multivalued attributes they may want to sum in AQL.

A friend of mine logged a case recently where a correlative using the S() function would hang when the file has any items where the attribute in question has more than 32,768 values. Engineering confirmed that this is an AQL limitation because it's using a 16-bit signed variable to track the value count. This variable is used in many places in AQL, and it would be a huge task to rearchitect.

In the course of debugging this, Engineering came up with a workaround by using CALL in the correlative. This not only removed the 32,768-value limit, but it is also MUCH faster.

Example of the correlative that hangs (using multivalued attribute 9 in the example):

008 A;S(9)

Example of the correlative that works (again using multivalued attribute 9 in the example):

008 call bp sumbal

Might be a good idea to fully path the subroutine being called. Example of a subroutine in an account called "orders" in a file call "pgms":

008 call orders,pgms, sumbal

Subroutine being called from the correlative:

subroutine sumbal(rval)
values = access(3)<9>
valMax = dcount(values,@vm)
rval = 0
for x = 1 to valMax
  rval += values<1,x>
next
return



------------------------------
Brian S. Cram
Principal Technical Support Engineer
Rocket Software
------------------------------

Hi Brian,
would the following work for all cases?
Regards,
Warwick

subroutine sumbal(rval)
values = access(3)<9>
rval = len(values) - count(values,@vm)
return



------------------------------
Warwick Dreher
Warwick Dreher
Croydon AU
------------------------------

Hi Brian,
would the following work for all cases?
Regards,
Warwick

subroutine sumbal(rval)
values = access(3)<9>
rval = len(values) - count(values,@vm)
return



------------------------------
Warwick Dreher
Warwick Dreher
Croydon AU
------------------------------

That would give you the length of the actual variable without the value marks. Not sure what use that is to you as it will NOT give you the sum of all the values:

009 13]26

len(values)-count(values,@vm) = 4

sum(values) = 39



------------------------------
Brian S. Cram
Principal Technical Support Engineer
Rocket Software
------------------------------