PLI Exception Handling (ON CONDTION)
来源:互联网 发布:开通淘宝网店需要1000 编辑:程序博客网 时间:2024/06/05 02:53
Exception Handling (ON CONDTION)
1. A CONDITION is the occurrence within a PL/I program that causes a program interrupt.
l In the absence of a program specifying an action, for most conditions the standard system action is to print a message, raise the ERROR condition and then terminate the PL/I program and return control to the OS.
l In PL/I the ON statement is used to specify action to be taken when any subsequent occurrence of a specified condition causes a program interrupt. e.g.
ON ENDFILE(SYSIN)
BEGIN;
PUT SKIP(3) LIST(TOTAL);
PUT PAGE LIST(‘NO OF RECORDS PROCESSED’,COUNT)
END_OF_FILE = ‘YES’;
END;
2. Status of conditions:
l Some conditions are always enabled unless explicitly disabled, others are disabled unless explicitly enabled.
l When a condition is enabled:
- Programmer defined action takes place
- System defined action takes place.
l The following conditions are always enabled: CONVERSION, FIXEDOVERFLOW, OVERFLOW, UNDERFLOW, ZERODIVIDE.
l The SIZE condition is disabled unless enabled by the programmer.
3. Changing the status of conditions (Enable or Disable)
(NOFIXEDOVERFLOW):CALC:SUM = A + B + C;
l Fixedoverflow condition is disabled.
l CALC is the label name.
l If it is desired to enable or disable condition execution in the entire program then specify the CONDITION prefix in the procedure statement.
e.g. (SIZE,NOFIXEDOVERFLOW):PROG1 : PROC OPTIONS(
4. Changing the ACTION taken.
l It is possible to specify more than one ON statements for the same condition in a program.
ON ENDFILE(SYSIN) CALL ERROR_RT;
..
..
ON ENDFILE(SYSIN) CALL NORMAL_END_OF_JOB;
l If after having supplied your own ON-unit for a condition, you wish to return to the standard system action for that on unit, simply specify another ON statement with the keyword SYSTEM.
5. Simulating conditions (主动触发异常,类似java中的throw exception)
l The programmer can simulate the occurrence of a condition through the use of the SIGNAL statement.
l Execution of the signal statement has the same affect as if the condition has actually occurred.
l If the signaled condition is not enabled the SIGNAL statement is treated as a NULL statement.
e.g.
ON ENDFILE(SYSIN) MORE_DATA = ‘NO’;
ON ENDPAGE(PRINTR)
BEGIN;
PUT PAGE LIST(‘’, ‘Weekly status report’, SUBSTR(TODAY,3,2) || ‘/’ ||
SUBSTR(TODAY,5,2) || ‘/’ || SUBSTR(TODAY,1,2), ‘PAGE’||PAGE_NUMBER );
PAGE_NUMBER = PAGE_NUMBER + 1;
END;
TODAY = DATE;
PAGE_NUMBER = 1;
OPEN FILE(PRINTR) PAGESIZE(45);
SIGNAL ENDPAGE(PRINTR);
MORE_DATA = YES;
GET LIST(DATA);
DO WHILE (MORE_DATA);
CALL PROCESS_DATA;
CALL PRINT_DATA;
GET LIST(DATA);
END;
6. Some useful Debugging tools:
PUT DATA: It causes all the variables known to the program at the point of the PUT statement to be outputed in the form of assignment statements. Since this is at the expense of considerable programming overhead, it should be used only for debugging. e.g.
ON ERROR
BEGIN;
ON ERROR SYSTEM ;
PUT DATA;
END;
- PLI Exception Handling (ON CONDTION)
- Notes on Exception Handling in Python
- Exception handling
- Exception Handling
- Exception Handling
- Exception Handling
- Exception Handling
- Exception Handling
- exception handling
- Exception Handling
- C# Exception Handling
- Exception Handling Rules
- Structured Exception Handling(SEH)
- Exception Handling in C#
- Vectored Exception Handling
- EAI Exception Handling Patterns
- Java exception handling
- Exception Handling in C#
- PLI Loop
- PLI Array
- PLI File Declarations
- PLI Stream I/O
- oracle 10g 入门
- PLI Exception Handling (ON CONDTION)
- 来点joke
- VC上的换肤控件
- C++文件操作浅谈
- 汉化ActiveReports 2.0界面
- 对互联网专业研究生的一点建议
- ddd
- 1~2岁的宝宝一周食谱
- 我的博客地址