首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >第6行出错: PL/ SQL :已忽略SQL语句

第6行出错: PL/ SQL :已忽略SQL语句
EN

Stack Overflow用户
提问于 2021-01-07 00:57:48
回答 1查看 48关注 0票数 0

我在第6行收到一个错误:PL/SQL: SQL Statement ignored

包含"select count(*) into ecount"的代码行给出了错误。

有人能帮帮我吗?

我的代码:

代码语言:javascript
复制
   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;
EN

回答 1

Stack Overflow用户

发布于 2021-01-07 02:28:30

显而易见的是:departmentdeparment

代码语言:javascript
复制
create or replace function empcount(department in table_employee.dept_name%type)
                                    ^^^^^^^^^^
                                    vvvvvvvvv
 where table_employee.dept_name    =deparment and salary>500000;

除此之外,应该还可以:

代码语言:javascript
复制
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>
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65600021

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档