Previous Topic

Next Topic

UpdateFileMode

Changes critical file mode attributes such as the level of transaction control.

Short Name

PUTFIL()

Type

Low-level function

Declaration

COUNT UpdateFileMode(COUNT filno, COUNT mode)

Description

When creating or opening a file, the value of filmod sets the attributes for the file. Some of these attributes are permanent, assigned during the creation of the file. Others are temporary, assigned only while the file is open. UpdateFileMode() changes these attributes after the file has been opened or created.

filno specifies the file to be changed. This file must be currently open in ctEXCLUSIVE mode. filmod is the new file mode attribute. It must be perfectly formed, as it will replace the current file mode for this file.

Note: Use this function with caution! It is possible to damage a file if you are not careful. For instance, changing a data file from transaction processing to no transaction processing make automatic recovery unavailable. See the discussion on File Modes in the c-tree Plus Programmer’s Reference Guide.

Some examples of changes that might make sense would be to add or delete ctCHECKLOCK, or to turn on one of the transaction modes for a data file, or to switch between ctPREIMG and ctTRNLOG for an index.

Return

Value

Symbolic Constant

Explanation

0

NO_ERROR

No error occurred.

48

FMOD_ERR

Cannot switch between fixed and variable length records.

62

LERR_ERR

File must be opened in ctEXCLUSIVE mode to modify.

99

TTYP_ERR

Cannot switch an index to transaction processing.

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

Example

COUNT     filno;

if (UpdateFileMode(filno,ctTRNLOG))
    printf("\nFile Mode Error %d",uerr_cod);

Limitations

filno must be opened in an ctEXCLUSIVE mode. No check is made to determine if the change being made will damage the file.