Options

How can I rectifie C/AL stack error

ajaybabuChajaybabuCh Member Posts: 208
Hi

While I am executing the follwoing

SQLString1 and SQLString2 of length 1024

ADORecSet.Open('SELECT '+SQLString1+SQLString2+' FROM '+ FORMAT(SQLTableID),ADO);

It throws me the error

There is not sufficient space in C/AL stack memory to execute this task.

There are two many simultaneous activities, due to the way recursive function calls is used in the programs. The problem can be solved temporarly by shutting down some of the open activities(but the function still cannot be executed)

how can i rectifie this error.
Ajay

Comments

  • ajaybabuChajaybabuCh Member Posts: 208
    can anybody give me an idea
    Ajay
  • garakgarak Member Posts: 3,263
    whats the stringlenght of the sql command :?:
    Do you make it right, it works too!
  • ta5ta5 Member Posts: 1,164
    Do you get the same error if this command is executed without any other commands (e.g. in a test code unit)? This way we can avoid some side effects.

    Thomas
  • Saint-SageSaint-Sage Member Posts: 92
    This sounds like you are either getting too many records from your query to hold in memory (HUGE recordset), or your error is being generated somewhere else in your code. I have only had this error when I set up a recursion with no ending.


    I.E. Codeunit A calls Codeunit A, over, and over, and over again...


    You should do some test by either restricting your query to a single record, I.E. WHERE keyname = 'xxx', or check over your report/codeunit/form and look for calls to itself, or another codeunit that will call the original.

    I.E. Codeunit A calls Codeunit B which then calls Codeunit A.

    No one loves you like the one who created you...
  • ajaybabuChajaybabuCh Member Posts: 208
    I am not running any recursive procedures.

    I am generating the sql string dynamically , instead of hardcoding it

    i have two string with 1024 of length

    if try to execute like this

    ADORecSet.Open('SELECT '+SQLSTRING1+SQLSTRING2+ ' FROM '+FORMAT(SQLTABLEID),ADO).

    I am getting stack overflow error.
    Ajay
  • ta5ta5 Member Posts: 1,164
    Does it work with shorter sql strings (shorter than 254)?
    Of course this is not the solution, but we get closer to the problem =P~
    Thomas
  • matteo_montanarimatteo_montanari Member Posts: 189
    ta5 wrote:
    Does it work with shorter sql strings (shorter than 254)?
    Of course this is not the solution, but we get closer to the problem =P~
    Thomas

    Hi

    Try a temporary variable text length 1024

    tmp := 'SELECT '+SQLSTRING1;
    tmp := tmp + SQLSTRING2;
    tmp := tmp + ' FROM '+FORMAT(SQLTABLEID);

    ADORecSet.Open(tmp ,ADO).

    Matteo
    Reno Sistemi Navision Developer
  • ajaybabuChajaybabuCh Member Posts: 208
    the problem here is if it exceeds like 20000 characters

    its throwing the stack overflow error.

    not with 1024 characters.
    Ajay
Sign In or Register to comment.