SQL> CREATE OR REPLACE PROCEDURE TestProc AS
2 v_number number(2);
3 BEGIN
4 v_number := 100;
5 END;
Procedure created
SQL> execute TestProc();
begin TestProc(); end;
ORA-06502: PL/SQL: 数字或值错误 : number precision too large
ORA-06512: 在 "BOSS643.TESTPROC", line 4
ORA-06512: 在 line 2
针对上述问题,可以重新定义数值长度解决这个问题, v_number定义为3
SQL> CREATE OR REPLACE PROCEDURE TestProc AS
2 v_number number(3);
3 BEGIN
4 v_number := 100;
5 END;
Procedure created
SQL> execute TestProc();
PL/SQL procedure successfully completed
SQL> CREATE OR REPLACE PROCEDURE TestProc2 AS
2 v_str varchar2(10);
3 BEGIN
4 v_str := 'This is a test string';
5 END;
Procedure created
SQL> execute TestProc2();
begin TestProc2(); end;
ORA-06502: PL/SQL: 数字或值错误 : character string buffer too small
ORA-06512: 在 "BOSS643.TESTPROC2", line 4
ORA-06512: 在 line 2
重新定义varchar2长度
SQL> CREATE OR REPLACE PROCEDURE TestProc2 AS
2 v_str varchar2(512);
3 BEGIN
4 v_str := 'This is a test string';
5 END;
Procedure created
SQL> execute TestProc2();
PL/SQL procedure successfully completed