Nodirali Akbarov
Nodirali Akbarov

Reputation: 1

ERROR at line 6: PL/SQL: SQL Statement ignored

I am getting an error at line 6: PL/SQL: SQL Statement ignored.

The line with "select count(*) into ecount" gives the error.

Could anyone help me?

My code:

   create or replace function empcount(department in table_employee.dept_name%type)
   return integer
   as 
   ecount integer;
   begin
   select count(*) into ecount
   from table_employee 
   where table_employee.dept_name=deparment and salary>500000;
   return ecount;
   end;

Upvotes: 0

Views: 125

Answers (1)

Littlefoot
Littlefoot

Reputation: 143103

What is obvious is this: department vs. deparment:

create or replace function empcount(department in table_employee.dept_name%type)
                                    ^^^^^^^^^^
                                    vvvvvvvvv
 where table_employee.dept_name    =deparment and salary>500000;

Apart from that, should be OK:

SQL> create or replace function empcount
  2    (department in table_employee.dept_name%type)
  3    return integer
  4  as
  5    ecount integer;
  6  begin
  7    select count(*) into ecount
  8      from table_employee
  9      where table_employee.dept_name = department      --> fixed
 10        and salary > 50000;
 11    return ecount;
 12  end;
 13  /

Function created.

SQL> select empcount(20) from dual;

EMPCOUNT(20)
------------
           2

SQL>

Upvotes: 2

Related Questions