以scott用户登陆
SQL> create or replace function isExist(eid number) return boolean
2 as
3 c number;
4 begin
5 select count(*) into c from emp where empno=eid;
6 if c=1 then
7 return true;
8 else
9 return false;
10 end if;
11 exception
12 when value_error then
13 DBMS_output.put_line('输入有误');
14 end;
15 /
Function created
SQL>
SQL> create or replace procedure updateEmpSal(eid number)
2 is
3 begin
4 if (isExist(eid)) then
5 update emp set sal=sal+1000 where empno=eid;
6 else
7 dbms_output.put_line('没找到');
8 end if;
9 exception
10 when value_error then
11 DBMS_output.put_line('输入有误');
12 end;
13 /
Procedure created当执行execute updateEmpSal('sdsd');时应该输出:输入有误,但为什么输出的确实
ORA-06502: PL/SQL: 数字或值错误 : 字符到数值的转换错误
ORA-06512: 在line 2
SQL> create or replace function isExist(eid number) return boolean
2 as
3 c number;
4 begin
5 select count(*) into c from emp where empno=eid;
6 if c=1 then
7 return true;
8 else
9 return false;
10 end if;
11 exception
12 when value_error then
13 DBMS_output.put_line('输入有误');
14 end;
15 /
Function created
SQL>
SQL> create or replace procedure updateEmpSal(eid number)
2 is
3 begin
4 if (isExist(eid)) then
5 update emp set sal=sal+1000 where empno=eid;
6 else
7 dbms_output.put_line('没找到');
8 end if;
9 exception
10 when value_error then
11 DBMS_output.put_line('输入有误');
12 end;
13 /
Procedure created当执行execute updateEmpSal('sdsd');时应该输出:输入有误,但为什么输出的确实
ORA-06502: PL/SQL: 数字或值错误 : 字符到数值的转换错误
ORA-06512: 在line 2
解决方案 »
- oracle 9i pl/sql不小心drop一张240G的表,一执行就停止,表能恢复吗?
- 各位大侠帮帮忙,求方法 ,着急,在线等
- 关于rownum=1的疑问
- oracle 高分查询,请大虾教我
- 求教:根据表A,中Name列的值,显示表B中,在a.name里的属性的值,两表建关联.
- 用toad如何做存储过程的单步调试
- 这样的统计如何写?
- Oracle 9 for linux的补丁包哪里有下载?google上搜到的很多都不能下载了.
- 请问在PLSQL中执行一个ORACLE的存储过程应该怎么写,在线等……
- 这样需要如何写sql
- 一道Oracle面试题,急求解,一起讨论啊? 要求通用,可以继续加分!
- 用PL/SQL Developer 怎么创建用户阿
==============
execute updateEmpSal('sdsd');
=========oracle 在做语法检查时,不能将参数 'sdsd' 转换成 number 类型,还未执行过程主体就出错了。
exception
10 when value_error then
11 DBMS_output.put_line('输入有误');
捕获异常了嘛????? ...为什么DBMS_output.put_line('输入有误');没执行
调用语句输入的参数就是错误的。
c number;
begin
select count(*) into c from emp where empno = eid;
if c = 1 then
return true;
else
return false;
end if;
exception
when value_error then
DBMS_output.put_line('输入有误');
end;
create or replace procedure updateEmpSal(number eid) is
begin
if (isExist(eid)) then
update emp set sal = sal + 1000 where empno = eid;
else
dbms_output.put_line('没找到');
end if;
exception
when value_error then
DBMS_output.put_line('输入有误');
end;
execute updateEmpSal(数字);