2

I'm trying to create a temp-table which is exactly like an already existing table in the database. How do I add each row to the temp table?

DEFINE TEMP-TABLE o_ttProducts.

FOR EACH Product:
    /*Add current row to the o_ttProducts temp table*/
END.
sander
  • 1,426
  • 4
  • 19
  • 46

1 Answers1

5
DEFINE TEMP-TABLE o_ttProducts no-undo like Product.

FOR EACH Product
    no-lock:
    /*Add current row to the o_ttProducts temp table*/
    create o_ttProducts.
    buffer-copy Product to o_ttProducts.
END.
idspispopd
  • 404
  • 3
  • 10
  • 1
    Great answer. It might be helpful to include a link to the documentation of BUFFER-COPY to it though, as it's quite a powerful command. https://documentation.progress.com/output/ua/OpenEdge_latest/index.html#page/dvref/buffer-copy-statement.html – jdpjamesp Sep 24 '18 at 10:56
  • 2
    I didn't want to go into too much detail for a simple question, but of course you are right that it is important to read the documentation of BUFFER-COPY before using it. IMO the most important point about BUFFER-COPY is also mentioned there: "At run time, BUFFER-COPY: *Creates a target record if none already exists ...". Might cause some bugs if you don't keep that in mind. – idspispopd Sep 25 '18 at 07:13