Using ATTACHTABLE_SUB (Functions/Subroutines/Programs)

ATTACHTABLE_SUB

ATTACHTABLE_SUB( volumeName, tableList, options )

Using ATTACHTABLE_SUB

ATTACHTABLE_SUB attaches tables, making them available for subsequent processing. The subroutine can attach all available tables on a volume, or a selected list only. A table is available to ATTACHTABLE_SUB if it belongs to the current application or if it is global.

You can use a table alias (Qfile) to attach a table that belongs to another application. However, if the second application has a password, the alias definition (in the SYSALIAS table) must include the password. Add it to the second attribute of the definition. For example:

SYSALIAS

SAMPLE,MYPASSWORD

SAMPLE_CUSTOMERS

For more information about creating an alias for a table, see "Creating an alias (synonym) for a table" in Chapter 22 of the Advanced Revelation User's Guide.

If a table is qualified with a user name, you can attach it by including the appropriate user prefix. For details, see "Table names and users (qualified table names)" in Chapter 22 of the Advanced Revelation User's Guide.

volumeName

The name of a valid volume, either a volume defined using the SetVolume window, or the name of an operating system path where there are Advanced Revelation tables. If tableList is null, all qualifying tables on the volume are attached. If no volumeName is provided, the default data volume is assumed.

tableList

An array (@FM-delimited) of tables to attach. If this parameter is null, all qualifying tables on the volume are attached. By default, the subroutine attaches the dictionary, the data portion of the table, and any indexes (the !file). To attach only one portion of the file, use these prefixes on the table name:

Prefix Meaning
DICT. Attach only the dictionary portion of the table.
DATA.

Attach only the data portion of the file, not the dictionary. (This also attaches the !file if the table is indexed.)

If there are two tables of the same name, but one belongs to the current application and the other is global, the table belonging to the application is attached. You can attach the table REVMEDIA, but only if you are in the SYSPROG application.

options

OptionMeaning
A (announce). Posts a message in the status line if the file being attached was previously attached from another volume.

Values returned

If an error has occured, the system variable status( ) is set to 1, otherwise status( ) is zero. Specific errors are returned in @file.error. Multiple errors are delimited with @RM. Possible values are:

ErrorMeaning
W504 Invalid table name, or attempt to attach a table from another application without the proper password.
109 Invalid volume name.

Example of ATTACHTABLE_SUB

/* attaches a list of tables */

volume = "SAMPLE"

tableList = ""

tableList<1> = "SAMPLE_CUSTOMERS" /* data, dict, and index */

tableList<2> = "DATA.CAR_PARTS" /* data and index only */

tableList<3> = "DICT.CAR_ORDERS" /* dict only */

options = "A" /* Announce option */

call ATTACHTABLE_SUB(volume, tablelist, options )

if len( status() ) then

call fsmsg() /* display messages */

end

  • kb/kb_articles/kb0054.txt
  • Last modified: 2024/01/30 13:36
  • by 127.0.0.1