Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

plsql - 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;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...