FILE |
File is used to declare all the tables that can be used in a routine.
[ Local ] File decl_fic [ , decl_fic ]
|
Element |
Description |
Restrictions |
|
decl_fic |
fichier [where_cl]
|
In one Filecommand, these descriptions may be mixed for different files. |
|
fichier |
Identification of a file in
one |
class indicates the
abbreviation for a |
|
string |
Character string constant containing the name of the file. |
The file must be accessible. |
|
expr_c |
Char type expression whose result is the name of the file. |
None. |
|
liste_variable |
List of nom_de_variable separated by the character ',' indicating fields in the file. |
None. |
|
where_cl |
See Where instruction |
None. |
|
order_cl |
See Order By instruction |
None. |
# Declaration of the HISTORIQUE with the abbreviation defined in # the parameters, and the CLIENT file with the abbreviation CLI.File HISTORIQUE, CLIENT [CLI]
# Use of 2 account files from 2 accounting departments COMPTA1 # and COMPTA2 are application names, mach1 is the name of a # table server.File "mach1@COMPTA1.COMPTES" [CPT1], "COMPTA2.COMPTES" [CPT2]
# Declaration of one file twice with different abbreviations. # There may be 2 current records therefore for one # file, so that for example it can make file links for itself.File COMPTES [CPT1], COMPTES [CPT2]
# Declaration of a file from the client stationFile "#@C:\x3\lan\Fra"
# Declaration of files identified respectively by an # abbreviation (the file TOTO must therefore already be open), # the name of an application (GESCOM), a pathname and a # character string type expressionFile [TOTO], "GESCOM.CLIENTS", "/usr/adonix/table1", = FIC_SAISI
# Declaration of 13 files already open.File [A1],[A2],[A3],[A4],[A5],[A6],[A7],[A8],[A9],[AA],[AB],[AC],[AD]
# PRODUIT file opened with a scan command using a # pseudo-key and a selection of records.Local File PRODUIT [PRO] Where [PRO]CLE >= "fzzz"
& Order By Key A = [PRO]TRICA Desc # Calculation of the size of files in the current directory belonging # to the adonix group (under Unix).File (D,L,P,G,T) From System "ls -l" As [SYS] Where [SYS]G = "adonix"
For [SYS] : [L]TAILLE += val([F:SYS]T) : Next# Directory listing (client under DOS)
File (NOMFIC) From System "@dir/b/o:n" As [DOS]
For [DOS] : infbox [F:SYS]NOMFIC : Next # In a sub-programme, opening a file already opened # should be avoided (saving time and the number of files open).If clalev( [F:CLIF] ) = 0: Local File CLIFAC : Endif
File is used to declare the tables used in read only mode in a routine. Opening tables in write mode is reserved for the Trbegin instruction.
A file may be identified by:
· name
· the name of a server followed by '@' followed by an application followed by '.' and the filename
· the abbreviation with which it has already been opened
· a list of fields and a system command (if it is a System type).
The client station is conventionally indicated by the server #.
If the name is given, a search for the file is first performed in the current application, then if unsuccessful, in the successive reference applications.
The abbreviation used during operations on this file will be as given in the parameters unless specified in the command. File.
The syntax File class is used to redeclare a file previously opened by File; which means that the current record is not lost.
A System type file is a temporary, sequential file, the result of the execution of the unix command included in the parameter. It is accessible like any indexed sequential file, but in read-only. Only the Curr, First, Last, Next and Prev read modes are possible, with no key specified. Read loops may be used by For.
The Where clause is defined in the same way as for other files. The Order by clause is forbidden. There is no key as such, and it is impossible to specify one. The ascending scan command corresponds to the way in which the screen display is shown.
During a read (using Read), Adonix stops at the first end of line character found (internal code 10) used as a record separator. Each record is 'broken down' into as many fields as there are shown in the Filesyntax, with the space (or tab or several spaces) used as a field separator (internal code 32). No account is therefore taken of the [S]adxirs and [S]adxifs variables.
The file fields are created using the Char type, 255 characters long. If too many names are given in the syntax, the 'unwanted' fields are ignored in read mode; if there are not enough, excess information is ignored.
After a read (by Read or For), the [S]fstat variable is updated as usual.
The Where clause is used to restrict access to file records for which the expression given has been verified. It should be stated that this expression (except when it is a file field) is evaluated when the table is opened (unlike earlier versions). The list of operators and functions that can be used in the expression is limited. Refer to the specific documentation on this clause for more details.
The
Order By clause is used to define (or redefine) a file scan index. If it
exists, only the key included in
this clause may be used. Refer to the specific documentation on this clause for
more details.
The instruction File creates variable classes [F] and [G] and updates the variables [S]fileabre and [S]filename.
File updates the list of tables open and replaces those with others defined in the instruction. The table that is first in the command becomes the default table. This may be altered by the Default instruction. File.
The maximum number of tables that may be opened simultaneously is limited by the adonix variable [S]adxmto. The value of this variable is normally set by one of the routines called APL.ini run when the application starts up; there is nothing to stop its value being modified in a routine. It must always be less than 50 however.
A File command closes all the tables opened by an earlier File (or Trbegin) command. You are therefore strongly advised to use Local File to open the tables in a sub-programme if you do not want to change the list of open tables on return to the calling routine.
The Local File instruction is used to open files locally for a routine or sub-programme and thus temporarily. This declaration does not close files previously opened by a File or Local File command, but adds to the list of open tables. The first table opened in this way will become the new default table. After the Close Local File command (or the end of the sub-programme) the list of tables is as it was before the instruction, as are the current records.
A locality level is attached to each Local file. It is therefore possible, using Local File and the same abbreviation, to reopen a file already opened elsewhere, but this cannot be done in the same programme.
It is possible to open a file with Local File à l'intérieur d'une transaction. Ce fichier sera automatiquement refermé à la fin de la transaction, mais jamais avant.
Il est théoriquement possible d'ouvrir un fichier par File within a transaction, but files opened in write mode by Trbegin will no longer be accessible – even if they are not physically closed before the end of the transaction.
When using the syntax File nom_d'OBJet, Adonix looks for a file of this name in the accessible applications, and if unsuccessful, tries to find an entry of the same name in the file table. The server name may be omitted when the application is a reference application for the current application.
Opening a table takes a certain amount of time in the database. Thus only essential files shall be opened, and files already opened shall not be reopened.
Temporary files created for a File command (sort file or System file) are stored in the /tmp directory, unless the environment variable TMPDIR contains the name of another directory. Their names are randomly generated. They are only accessible from the current procedure and are physically deleted at the end of their use or at the end of the procedure.
To delete from memory tables opened by File or Local File, use Close File and Close Local File. But from within a transaction, these tables will only truly be closed at the end of the transaction (Commit or Rollback).
One
file may be opened several times (with several different locality levels),
using a new Where clause each time. It is not added to the previous ones, but
is attached to a locality level and thus deleted at the end of the
sub-programme. Thus:
File
FIC1 Where LIBELL = 4 : # a text type field
Call SBPRG
Read [FIC1]LIBELL First : Infbox num$(LIBELL) : # will display 4
...
Subprog SBPRG
Local File FIC1 Where LIBELL <> 4 : # The opposite condition
Read [FIC1]LIBELL Last : Infbox num$(LIBELL) : # will display 255
If the file is reopened with the syntax File [abv] the Where clauses will be added and the second read will fail.
The nbrecord function gives the number of records in the table given in the parameter (it must be opened).
In Oracle, a table cannot – a priori – be opened from a database other than the current database. There may also be Oracle-specific access authorisation problems.
|
Error |
Description |
|
ERMODE (10) |
The file name is not alphanumeric. |
|
TROFIC (29) |
Too many files opened at once. |
|
PAFIC (20) |
File not found. |
|
ERCLAS ( 7) |
Abbreviation not found. |
|
ERREOP (28) |
One table opened twice. |
|
ERACCE (27) |
File access error (unix rights). |
TRBEGIN - WHERE - ORDER - ADXMTO - CLALEV - DEFAULT - CLOSE - FILTER - FOR - LINK - NBRECORD - FILEABRE - FILENAME
CONTENTS
|
|