Which mode of opening is required when REWRITE is used?
-
INPUT
-
OUTPUT
-
I-O
-
EXTEND
-
All of the above
-
None of the above
The REWRITE statement updates existing records in a file, which requires the file to be open in input-output (I-O) mode to read and modify the record. Other modes like INPUT or OUTPUT do not allow updates. Opening in INPUT allows only reading, whereas OUTPUT is for writing new files.
To understand which mode of opening is required when the REWRITE statement is used, let's go through each option:
Option A) INPUT - This option is incorrect because the INPUT mode is used for reading data from a file, not for rewriting existing data.
Option B) OUTPUT - This option is incorrect because the OUTPUT mode is used for writing data to a file, not for rewriting existing data.
Option C) I-O - This option is correct because the I-O mode (Input-Output) is used when you want to both read and rewrite existing data in a file. The REWRITE statement is used specifically to rewrite existing records within a file.
Option D) EXTEND - This option is incorrect because the EXTEND mode is used to add new records to the end of a file, not for rewriting existing data.
Option E) All of the above - This option is incorrect because not all of the above options are required when using the REWRITE statement. Only the I-O mode is required.
Option F) None of the above - This option is incorrect because the correct answer is option C, I-O.
Therefore, the correct answer is option C, I-O. This option is correct because the I-O mode is required when using the REWRITE statement to rewrite existing records in a file.