How long has it been possible to DEFINE TEMP-TABLE ... LIKE

Posted by slacroixak on 22-Sep-2017 08:17

I'm glad to ind this out:     (still 11.6)

I recall that in the past we would avoid the LIKE option to define temp-table (or variables) so a .r file would not be db-bound.   I just notice (or managed ot forget before) that it is no longer a problem.

I mean I can now very well do this:

DEFINE TEMP-TABLE ttyo NO-UNDO LIKE customer.
MESSAGE "yes it works" SKIP
    "NUM-DBS" NUM-DBS
    VIEW-AS ALERT-BOX INFO BUTTONS OK.

that would cause this if I run it not being connected to a DB:

Unknown or ambiguous table <myDbTable>. (545)

but if I compile a .r file, then it can be run fine.

Can someone remind me when this great feature was introduced?

/S

Posted by jankeir on 22-Sep-2017 10:12

Probably for your API not to change every time the schema is updated. If the API is exposed to the outside world that could be really important.

All Replies

Posted by George Potemkin on 22-Sep-2017 08:27

Tested with V8.3A: "yes it works NUM-DBS 0"

Posted by slacroixak on 22-Sep-2017 08:38

Hmmm, what was the reason of this practice then?

BTW George, I imagine you did the test with a fresh session without any obscure db-bound persistent proc still running that would post-pone a disconnection.  Correct?

Posted by George Potemkin on 22-Sep-2017 08:49

I rerun the test with a fresh session (from Progress Editor): "yes it works NUM-DBS 0"

Tested with 8.3A, 9.1B, 10.0A (from my collection of antiquities).

RCODE-INFO:FILE-NAME = "test.r".
MESSAGE RCODE-INFO:DB-REFERENCES VIEW-AS ALERT-BOX.

It returns the empty string.

Posted by Peter Judge on 22-Sep-2017 09:26

I *believe* that it’s always been possible, since the introduction of temp-tables. I think it was part of the intended behaviour from the beginning

Posted by slacroixak on 22-Sep-2017 10:02

So was the aim of that practice limited to the ability to compile business logic without being connected to the database?

Am I missing something?

Posted by Peter Judge on 22-Sep-2017 10:12

I imagine it was so that you could define a TT quickly :) and take default values from the DB schema.

Posted by jankeir on 22-Sep-2017 10:12

Probably for your API not to change every time the schema is updated. If the API is exposed to the outside world that could be really important.

Posted by slacroixak on 22-Sep-2017 10:33

Makes sense indeed  :)  Thank you Jankeir

Unit tests can quickly reveal this kind change of API signature

Now, with this practice it is not easy to track in code that some fields are ignored for the sake of keeping given signatures.

Perhaps it would make sense to implement a new 'EXCEPT' option to amend the LIKE and LIKE-SEQUENTIAL options of the DEFINE TEMP-TABLE Statement.    (Thinking of the interest of Progress.com on the API's topic for OE12...)

Posted by Robin Brown on 22-Sep-2017 10:36

I believe that several releases back, you needed to use RCODE-INFORMATION on the temp-table definition in order to store the 'LIKE' schema in the r-code so you didn't have to be connected at runtime.   This option is now obsolete, and we always store the LIKE schema in the r-code.  I can't remember when this changed.

Posted by George Potemkin on 22-Sep-2017 10:50

RCODE-INFORMATION was added in V7 if I recall correctly. Test with 7.3C01 as of Thu Oct 12 1995 shown the same result as with other Progress versions - RCODE-INFORMATION is not required.

This thread is closed