1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Temp-table Scope Clarification

Discussion in 'Development' started by Scott Dawson, Oct 11, 2017.

  1. Scott Dawson

    Scott Dawson New Member

    Hi Everyone,

    Openedge 11.6
    Windows 10

    I have defined a TEMP-TABLE in a procedure which I am populating with some data then passing as an INPUT parameter to and external procedure (.p).

    My questions is, if I empty the TEMP-TABLE in the second procedure will this have any effect on the content of the TEMP-TABLE in the calling procedure?

    Thanks in advance,

    Scott.
     
  2.  
  3. Cringer

    Cringer ProgressTalk.com Moderator Staff Member

    Best way to be sure is to test it in some noddy code.
     
  4. KrisM

    KrisM Member

    By default temp-tables are passed by-value, which means that the external procedure receives a copy of the temp-table.
    Emptying the copy does not impact the original.
    You can change this by adding 'by-reference' in the run statement.
    This will make the external procedure use the original temp-table.
     
  5. tamhas

    tamhas ProgressTalk.com Sponsor

    You need to look carefully at the various ways of passing temp-tables. Passing as a copy means clean separation, but it also means the overhead of making a copy. Passing by reference just passes a handle and so is much more performant, but means you do not have the separation. Whether or not you should have separation should be well defined by the nature of the procedures involved.

    Note that the best answer is not to pass it at all. Put it in a class and provide methods for populating it, manipulating it, and reading it. This kind of isolation is one of the things OO is good at!
     
  6. Scott Dawson

    Scott Dawson New Member

    Thanks for all the answers. I need the separation so going down that route.

    Thanks again,

    Scott.
     

Share This Page