你已经证明什么工作表(不用于演示的FS.
模式前缀)编译OK:
create table fs_holiday(ho_date date);
create or replace
function total_weekdays(fromdate in date, todate in date)
return number
as totaldays number := 0;
dates number := 0;
BEGIN
select to_number(count(dates)) into totaldays from
(select to_char(fromdate + level -1, 'dd/mm/YYYY DY') as dates
from dual connect by level <= todate - fromdate +1
minus
select to_char(ho_date, 'dd/mm/YYYY DY') as dates
from fs_holiday
) where not regexp_like(dates,'SUN|SAT');
return totaldays;
END;
/
Function TOTAL_WEEKDAYS compiled
如果您在对象查看器中打开该函数,然后单击SQL选项卡,则会显示没有结尾的斜杠。
添加斜线回,然后编译它然后给你看到的错误,
Error(15,1): PLS-00103: Encountered the symbol "/" The symbol "/" was ignored.
在对象浏览器环境下,你不应该有斜线。在工作表中,为in SQL*Plus,SQL开发人员:
... treats PL/SQL subprograms in the same manner as SQL commands, except that a semicolon (;) or a blank line does not terminate and execute a block. Terminate PL/SQL subprograms by entering a period (.) by itself on a new line. You can also terminate and execute a PL/SQL subprogram by entering a slash (/) by itself on a new line.
所以在工作表中的斜杠是必要的分隔(命名)块的结尾,并确定create
声明的全部。
在对象浏览器,你只看到该对象的代码,所以没有必要有斜杠分隔符,一切都在SQL窗口被视为对象源代码的一部分。
同样,如果你在user_source
数据字典视图看,有没有存放斜杠线。
select line, text from user_source where name = 'TOTAL_WEEKDAYS' order by line;
LINE TEXT
---------- --------------------------------------------------------------------------------
1 function total_weekdays(fromdate in date, todate in date)
2 return number
3 as totaldays number := 0;
4 dates number := 0;
5 BEGIN
6 select to_number(count(dates)) into totaldays from
7 (select to_char(fromdate + level -1, 'dd/mm/YYYY DY') as dates
8 from dual connect by level <= todate - fromdate +1
9 minus
10 select to_char(ho_date, 'dd/mm/YYYY DY') as dates
11 from fs_holiday
12 ) where not regexp_like(dates,'SUN|SAT');
13 return totaldays;
14 END;
14 rows selected.
它是客户端语句处理的一部分,而不是函数的一部分。
如果你是在对象浏览器,那么你不能创建在同一个SQL窗口中的第二个对象。这是您正在查看的对象的源代码。
如果要在脚本中一次创建多个对象,请使用工作表(右键单击连接并选择“打开SQL Worksheet”),将所有代码放入,然后作为脚本运行(F5) 。如果您想使用对象视图,然后展开连接,请右键单击“包”选项,然后选择“新建包”。
了解更多关于managing objects和SQL Worksheet。
我想,如果你使用的;那么你不需要/,它是两者之一。 –
这是在SQL工作表中还是在对象查看器中?如果后者删除了斜线。 –
您检查此链接的解释https://stackoverflow.com/questions/1079949/when-do-i-need-to-use-a-semicolon-vs-a-slash-in-oracle-sql –