17,377
社区成员
发帖
与我相关
我的任务
分享
-- 给你写个示例
SQL> set serverout on ;
SQL>
SQL> declare
2 subtype type_test is pls_integer range 0 .. 100;
3 a type_test ;
4 b type_test ;
5 begin
6 begin
7 a := 10 ;
8 dbms_output.put_line(' 10 success');
9 exception
10 when others then
11 dbms_output.put_line(' 10 error');
12 end;
13 begin
14 b := -100;
15 dbms_output.put_line(' -100 success');
16 exception
17 when others then
18 dbms_output.put_line(' -100 error');
19 end ;
20 begin
21 b := 101;
22 dbms_output.put_line(' 101 success');
23 exception
24 when others then
25 dbms_output.put_line(' 101 error');
26 end ;
27
28 end ;
29 /
10 success
-100 error
101 error
PL/SQL procedure successfully completed
SQL>