Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.3k views
Welcome To Ask or Share your Answers For Others

1 Answer

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...