Temporary table scope

viriatoviriato Member Posts: 105
Can someone please tell me the scope of a temporary table?

For example: If I read a file into a temporary file through a dataport and then execute another dataport where I will need to do some comparison with this data, will this data still exist in the temporary table, what I the scope of the temporary table.

Thanks and hope everyone is enjoying their weekend.

Comments

  • garakgarak Member Posts: 3,263
    Your basic question is answered here -> viewtopic.php?f=23&t=31159
    Do you make it right, it works too!
  • viriatoviriato Member Posts: 105
    Thanks. Is the scope then within just the object where the temp table is created?
  • garakgarak Member Posts: 3,263
    1. you can use the tempTable only in the created object self.
    2. But, if you send the TempTable to a function of a other form (for example to modify there the datas) and this function has as parameter a recordparameter and the VAR Flag is there activated (Call by Reference), the recordparametertable is there also temporary (because you doesn't "copy" the variable, you work on the same alloc. memoryblock)

    For more infos read also the Development Manuals.

    Regard
    Do you make it right, it works too!
  • viriatoviriato Member Posts: 105
    Thanks.
  • garakgarak Member Posts: 3,263
    Please and good luck
    Do you make it right, it works too!
  • bbrownbbrown Member Posts: 3,268
    One way to access a temp table between two objects is to create the temp table within a single-instance codeunit. Then reference the codeunit from either object. You'll need functions in the codeunit to handle table.
    There are no bugs - only undocumented features.
  • DenSterDenSter Member Posts: 8,304
    Are local variables in a single instance codeunit accessible after a single call to a function?
  • bbrownbbrown Member Posts: 3,268
    DenSter wrote:
    Are local variables in a single instance codeunit accessible after a single call to a function?

    Not sure I understand your question. Then again it's been a long day. In my example the temp table is a global.
    There are no bugs - only undocumented features.
  • jlandeenjlandeen Member Posts: 524
    When using a single instance codeunit the values should be available after any call to the codeunit. The first time the codeunit is created or used it's instantiated in memory. You can then have functions or code that read, write or modify data in a temporary table that is a global variable in that Single Instance codeunit.

    One thing to watch out for when working with temporary variables is that there is no ClearAll used. That function can clear all variables within a codeunit.
    Jeff Landeen - Sr. Consultant
    Epimatic Corp.

    http://www.epimatic.com
  • DenSterDenSter Member Posts: 8,304
    bbrown wrote:
    DenSter wrote:
    Are local variables in a single instance codeunit accessible after a single call to a function?

    Not sure I understand your question. Then again it's been a long day. In my example the temp table is a global.
    I know how globals work in a single instance codeunit, and that you can access them from another object. I've never played around with local variables in a single instance codeunit, and this thread peaked my interest. When you run a function in a regular codeunit, the codeunit itself is destroyed when the scope is finished, so the local variables in the function do as well. What I am wondering is when you call a function in a single instance codeunit, and that function uses a local variable, will that be destroyed at the end of the function, or will its value be retained for a consecutive call to the same function.

    It's easy to test, I was just wondering.
  • bbrownbbrown Member Posts: 3,268
    I believe it may. That's why I define the temp table as a global. The functions are just to handle the table. They take parameters but have no local variables.
    There are no bugs - only undocumented features.
  • jlandeenjlandeen Member Posts: 524
    Ahh ok now I see where you were coming from DenSter. If the variables are global then yes they are still destroyed/garbage collected after the function executes. Only the global variables can be persisted between function calls as I've seen it.
    Jeff Landeen - Sr. Consultant
    Epimatic Corp.

    http://www.epimatic.com
  • bbrownbbrown Member Posts: 3,268
    That's right. The functions are only there to set and retrieve the global values.
    There are no bugs - only undocumented features.
Sign In or Register to comment.