create or replace procedure p_inout
(v_emp_lname in varchar2(25))
as
v_first_name varchar2(20);
begin
select first_name into v_first_name
from employees
where last_name=v_emp_lname;
dbms_output.put_line(v_first_name);
end;
我到了 错误(2,25):PLS-00103:遇到符号“(”当需要以下之一时:= =。),@%默认字符符号“:=”代替“(”继续。
答案 0 :(得分:1)
参数参数的类型(如varchar2)没有大小属性,因此将“varchar2(25)”替换为“varchar2”。
请参阅Oracle docs参数用法。具体做法是:
**Parameter Datatypes**
The datatype of a formal parameter consists of one of the following:
An unconstrained type name, such as NUMBER or VARCHAR2.
A type that is constrained using the %TYPE or %ROWTYPE attributes
答案 1 :(得分:1)
To fetch more than more record you have to use cursor. The code above needs some modification to fetch more than one record.
create or replace procedure p_inout
(v_emp_lname in varchar2)
as
v_first_name varchar2(20);
begin
for rec in (select first_name
from employees
where last_name=v_emp_lname)
loop
dbms_output.put_line('First name/s'||' '||rec.first_name);
end loop;
end;