STATUS statement
Syntax
STATUS dynamic.array FROM file.variable{THEN statements [ELSE statements] | ELSE statements}
Description
Use the STATUS statement to determine the status of an open file. The STATUS statement returns the file status as a dynamic array and assigns it to dynamic.array.
The following table lists the values of the dynamic array returned by the STATUS statement:
Field | Stored Value | Description |
---|---|---|
1 | Current® position in the file | Offset in bytes from beginning of the file. |
2 | End of file reached | 1 if EOF, 0 if not. |
3 | Error accessing file | 1 if error, 0 if not. |
4 | Number of bytes available to read | |
5 | File mode | Permissions (convert to octal). Windows. This is the UNIX owner-group-other format as converted from the full Windows ACL format by the C run-time libraries. |
6 | File size | In bytes. |
7 | Number of hard links | 0 if no links. Windows. The value is always 1 on non-NTFS partitions, > 0 on NTFS partitions. |
8 | User ID of owner | UNIX. The
number assigned in /etc/passwd. Windows. It is a pseudo user ID based on the user name and domain of the user. |
9 | Group ID of owner | UNIX. The
number assigned in /etc/passwd. Windows. It is always 0. |
10 | I-node number | Unique ID of file on file system; on Windows the value is the Pelican internal version of the i-node for a file. For dynamic files, the i-node number is the number of the directory holding the components of the dynamic file. |
11 | Device on which i-node resides | Number of device. The value is an internally calculated value on Windows. |
12 | Device for special character or block | Number of device. The value is the drive number of the disk containing the file on Windows. |
13 | Time of last access | Time in internal format. |
14 | Date of last access | Date in internal format. |
15 | Time of last modification | Time in internal format. |
16 | Date of last modification | Date in internal format. |
17 | Time and date of last status change | Time and date in internal format. On Windows it is the time the file was created. |
18 | Date of last status change | Date in internal format. On Windows it is the date the file was created. |
19 | Number of bytes left in output queue (applicable to terminals only) | |
20 | Operating system filename | The internal path name used to access the file. |
21 | File type | For file types 1-19, 25, or 30. |
22 | InfoSphere® DataStage® file modulo | For file types 2-18 only. |
23 | InfoSphere DataStage file separation | For file types 2-18 only. |
24 | Part numbers of part files belonging to a distributed file | Multi-valued list. If file is a part file, this field contains the part number, and field 25 is empty. |
25 | Path names of part files belonging to a distributed file | Multi-valued list. If file is a part file, this field is empty. |
26 | Filenames of part files belonging to a distributed file | Multi-valued list. If file is a part file, this field is empty. |
27 | Full path name | The full path name of the file. On Windows, the value begins with the UNC share name, if available; if not, the drive letter. |
28 | Integer from 1 through 7 | SQL file privileges: 1 write-only 2 read-only 3 read/write 4 delete-only 5 delete/write 6 delete/read 7 delete/read/write |
29 | 1 if this is an SQL table, 0 if not. If the file is a view, the STATUS statement fails. (No information on a per-column basis is returned.) | |
30 | User name | User name of the owner of the file. |
file.variable specifies an open file. If file.variable evaluates to the null value, the STATUS statement fails and the program terminates with a run-time error message.
If the STATUS array is assigned to dynamic.array, the THEN statements are executed and the ELSE statements are ignored. If no THEN statements are present, program execution continues with the next statement. If the attempt to assign the array fails, the ELSE statements are executed; any THEN statements are ignored.
Example
OPENSEQ '/etc/passwd' TO test THEN PRINT "File
Opened" ELSE ABORT
STATUS stat FROM test THEN PRINT stat
field5 = stat<5,1,1>
field6 = stat<6,1,1>
field8 = stat<8,1,1>
PRINT "permissions:": field5
PRINT "filesize:": field6
PRINT "userid:": field8
CLOSESEQ test
This is the program output:
File Opened
0F0F0F4164F33188F4164F1F0F2F2303F 0F6856F59264F6590F42496F6588F42496F6588
F0F/etc/passwdF0F0F0
permissions:33188
filesize:4164
userid:0