Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

OpenISAM

Open all the ISAM files.

Short Name

OPNISAM()

Type

ISAM function

Declaration

COUNT OpenISAM(pTEXT filnam)

Description

OpenISAM() opens the parameter file, whose name is pointed to by filnam, and opens the data and index files specified in the parameter file. Application programs using the ISAM level functions must make a call to InitISAM() or OpenISAM() before any other c-tree functions are used. If any one of these three functions has been called, then CloseISAM() must be called before anyone of them can be invoked again. In part, this implies that no more than one ISAM parameter file may be active at one time. However, the incremental ISAM functions allow for more flexibility in file manipulations and are highly recommended.

Using virtual files, the parameter file may contain more files than available file descriptors. c-tree automatically manages the open and close of virtual files.

Although it is not recommended, it is possible to use incremental ISAM file opens and opens along with a parameter file. Increase the value of the second parameter in the parameter file, (idxs), by the total number of files used by the incremental routines. For example, if the incremental routines open two additional data files, each with five indexes, then the idxs parameter in the ISAM parameter file should be increased by 12.

Note: This function supports EXCLUSIVE file opens. For more information, please refer to Multi-user File Mode.

Return

OpenISAM() returns an error code from the table below. On a successful open when a differently named file matches the file ID of an open file, the error return will be NO_ERROR (0) but sysiocod will be set to MFID_COD (-586). If the files are detected to actually be different, then the file ID is changed as discussed above and sysiocod is not set to MFID_COD.

Value

Symbolic Constant

Explanation

0

NO_ERROR

Successful open of ISAM files.

10

SPAC_ERR

Not enough space for file structures and buffers.

11

SPRM_ERR

Illegal parameters in first record of parameter file.

12

FNOP_ERR

Could not open file. Check isam_fil for the specific file number.

13

FUNK_ERR

Unknown file type.

14

FCRP_ERR

File found corrupt at open.

20

KMIN_ERR

Key length too large for node size.

21

DREC_ERR

Record length is too small. File is not opened.

43

FVER_ERR

Current c-tree configuration specified in ctoptn.h is incompatible with existing file.

45

KLEN_ERR

Key length exceeds MAXLEN parameter in ctopt2.h.

102

INOD_ERR

Could not open ISAM parameter file.

103

IGIN_ERR

Could not read first record of ISAM parameter file.

104

IFIL_ERR

Too many files specified. Increase ctMAXFIL in ctoptn.h and rebuild library.

106

IDRI_ERR

Could not read data file description record in parameter file.

107

IDRK_ERR

Too many index files for one data file. Increase MAX_DAT_KEY parameter in ctoptn.h, (and rebuild the library), or increase the ctsrvr.cfg keyword.

108

IMKY_ERR

keyno for index member is out of sequence. keyno must equal the host index keyno plus the member number.

109

IKRS_ERR

Too many key segments. Increase MAX_KEY_SEG parameter in ctoptn.h.

110

ISRC_ERR

Could not read key segment description record in parameter file.

111

IKRI_ERR

Could not read index file description record in parameter file.

115

ISLN_ERR

Key segments do not equal key length.

117

IMRI_ERR

Could not read index member record.

125

IINT_ERR

c-tree already initialized. Call CloseISAM() before recalling OpenISAM().

182

IKSR_ERR

No room for r-tree temporary files. Increase ctMAXFIL in ctoptn.h and rebuild library.

See c-tree Error Codes for a complete listing of valid c-tree error values.

Example

TEXT isam_par[64];


printf("\nEnter ISAM parameter file name: ");

scanf("%63s",isam_par);

if (OpenISAM(isam_par))

printf("\nCould not open ISAM.");

else

ProcessData()


if (CloseISAM())

printf("\nCould not close ISAM.");

Limitations

It is not possible to open some of the files specified in the parameter file and create others. They must all be created by CreateISAM(). However, the incremental ISAM functions permit on the fly opening and closing of ISAM files. If you are adding a new index file to an established set of ISAM files, you should:

  • Update the parameter file to include the new index.
  • Use the rebuild utility to create and build the new index file. Respond no when asked to force rebuild.
  • Call OpenISAM() to actually use the files.

See also

CloseISAM(), InitISAM(), CreateISAM(), CreateIFile(), OpenIFile(), OpenISAMXtd() and ISAM Parameters in the c-tree Programmer’s Reference Guide, which describes the parameter file contents.

TOCIndex