我是一个刚开始学习PL/SQL的菜鸟,写了一段代码
set serveroutput on format wrapped
create or replace procedure count_num
(in_sex in teachers.sex%type)
as
out_num number;
begin
if in_sex='m' then
select count(sex) into out_num
from teachers
where sex='m';
dbms_output.put_line('number of male teachers:'||out_num);
else
select count(sex) into out_num
from teachers
where sex='f';
dbms_output.put_line('number of female teachers:'||out_num);
end if;
end count_num;编译没有错误,但是执行时总报如下错误:
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'COUNT_NUM'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored请高手指点
set serveroutput on format wrapped
create or replace procedure count_num
(in_sex in teachers.sex%type)
as
out_num number;
begin
if in_sex='m' then
select count(sex) into out_num
from teachers
where sex='m';
dbms_output.put_line('number of male teachers:'||out_num);
else
select count(sex) into out_num
from teachers
where sex='f';
dbms_output.put_line('number of female teachers:'||out_num);
end if;
end count_num;编译没有错误,但是执行时总报如下错误:
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'COUNT_NUM'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored请高手指点
解决方案 »
- 项目签到时间不正常
- 如何抛出触发事件里的异常信息?
- 建job时报错 ORA-01008 并非所有变量都已绑定
- win7(64)plsql连接的时候提示‘ORA-12154:TNS:无法解析指定的连接标志符’;的解决方法
- 请教一下oracle存储过程中拆分字符串的函数?
- 一个真有趣的错误!!!!
- Oracle问题,急。。。。。在线等
- 关于表数据太大的问题,高分求解
- 请问我要在SQL*PLUS上修改一条输错的命令,应该怎样操作????谢谢,谢谢
- ****设置一个批次允许最大执行的时间****
- 使用 create table xxx as 时,怎么转换 varchar2(10) 为 number(10)
- select * from v$datafile;查询到的5个文件中,哪个是控制文件?
SQL> drop table teachers;Table droppedSQL>
SQL> create table teachers(sex varchar2(100));Table createdSQL>
SQL> create or replace procedure count_num(in_sex in teachers.sex%type) as
2 out_num number;
3 begin
4 if in_sex = 'm' then
5 select count(sex) into out_num from teachers where sex = 'm';
6 dbms_output.put_line('number of male teachers:' || out_num);
7 else
8 select count(sex) into out_num from teachers where sex = 'f';
9 dbms_output.put_line('number of female teachers:' || out_num);
10 end if;
11 end count_num;
12 /Procedure createdSQL> insert into teachers values('m');1 row insertedSQL> commit;Commit completeSQL> set serveroutput on;
SQL> select count_num('m') from dual;select count_num('m') from dualORA-00904: "COUNT_NUM": 标识符无效SQL> begin
2 count_num('m');
3 end;
4 /number of male teachers:1PL/SQL procedure successfully completedSQL>
count_num('m');
end;
--sql窗口