Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
904 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;
question from:https://stackoverflow.com/questions/65600021/error-at-line-6-pl-sql-sql-statement-ignored

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

1 Answer

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...