Creating Temporary Tables/Views
Use the CREATE TABLE command to create a temporary table. Use the CREATE VIEW command to create a temporary view. You can also use the INTERSECT, JOIN, PROJECT, SUBTRACT, UNION, ATTACH, and SATTACH commands to create temporary tables. The main difference between using the original command to create a table or view and creating a temporary table/view is the TEMPORARY parameter in the command syntax. When created, the temporary table/view is written to the temporary scratch files.
Creating Temporary Tables in Memory
Use the CREATE TABLE command to create a temporary table in memory. You can also use the INTERSECT, JOIN, PROJECT, SUBTRACT, and UNION commands to create a temporary table in memory. The main difference between using the original command to create a table and creating an in-memory temporary table is the INMEMORY parameter in the command syntax. When created, an in-memory temporary table is stored in memory. R:BASE initially allocates 32,000 bytes for each in-memory table, where as the table grows, the space will increase as needed. R:BASE currently limits a database to ten (10) in-memory tables. If any keys are built for an in-memory table, the key data will be written to the temporary scratch files.
Table Settings
Within the R:BASE Data Designer, there are settings under "Table", that will save a temporary or in-memory table as a regular permanent table. The setting can also be used to save any existing table as a temporary/in-memory table.
Removing Temporary Tables/Views
You can use the DROP command to remove a temporary table or view. This is important when you are creating temporary tables or views as you should always DROP the table or view before creating it. This technically only affects the user running the program. To avoid this error message, use the following technique:
Example 01:
SET ERROR MESSAGE 2038 OFF
DROP TABLE temptablename
SET ERROR MESSAGE 2038 ON
Example 02:
SET ERROR MESSAGE 677 OFF
DROP VIEW tempviewname
SET ERROR MESSAGE 677 ON
In addition to the DROP command, you can simply DISCONNECT and CONNECT the database to remove any temporary tables/views. Temporary tables/views along with temporary System Tables are removed when the database is disconnected.
Using Forms, Labels or Reports based upon Temporary Tables/Views
You may define all required temporary tables/views for Forms as "On Before Design Action" before designing a form and "On Before Start" EEP before using (EDIT USING, ENTER USING, BROWSE USING) the form.
You may define all required temporary tables/views for Reports as "On Before Design ..." action before designing a report/sub-report and "On Before Generate ..." action.
You may define all required temporary tables/views for Labels as "On Before Design ..." action before designing a label and "On Before Generate ..." action.
A command file, such as TempTables.RMD, can also be used to pre-define all required temporary tables/views.
Notes:
•In regards to temporary tables in the database, always DISCONNECT and then CONNECT before using the AUTOCHK, PACK or RELOAD commands.
•When creating a temporary table/view, the following temporary System Tables are also created:
•SYSTMP_COMMENTS
•SYSTMP_CONSTRAINTS
•SYSTMP_DEFAULTS
•SYSTMP_RULES
•SYSTMP_SERVERS
•SYSTMP_TRIGGERS
•SYSTMP_VIEWS
•Temporary tables/views were first introduced in R:BASE 6.1 (July 1997).