Search code examples
stored-proceduresoracle11g

can we use datatype of %rowtype , in oracle procedure ,for out parameter


create or replace 
procedure find_emp_info (
    p_emp_info out emp%rowtype,
    p_empno in emp.empno%type default 7839
) 
is 
p_emp_info emp%rowtype;
begin 
    select *   into emp_info 
    from emp 
    where empno =p_empno;
exception 
when no_data_fount then 
    dbms_output.put_line( 'enter employee number not exists');
when others then 
    dbms_output.put_line('ERROR OCCURS ') ;
    RAISE_APPLICATION_ERROR (-20003,SQLCODE||CHR(10)||sqlerrm);
end find_emp_info  ;
/

PLS-00410: duplicate fields in RECORD,TABLE or argument list are not permitted

why am getting this error in above code


Solution

  • There are two errors as @Alex mentioned you declare a local the variable p_emp_info which can be removed.

    The exception you are using is no_data_fount which must be no_data_found.

    create or replace 
    procedure find_emp_info (
        p_emp_info out emp%rowtype,
        p_empno in emp.empno%type default 7839
    ) 
    is 
    begin 
        select *   into p_emp_info 
        from emp 
        where empno =p_empno;
    exception 
    when no_data_found then 
        dbms_output.put_line( 'enter employee number not exists');
    when others then 
        dbms_output.put_line('ERROR OCCURS ') ;
        RAISE_APPLICATION_ERROR (-20003,SQLCODE||CHR(10)||sqlerrm);
    end find_emp_info  ;
    /