What you've shown compiles OK in a worksheet (without the FS.
schema prefix for the demo):
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
If you open the function in the object viewer and click on the SQL tab then it is shown without the trailing slash.
Adding the slash back in and then compiling does then give the error you're seeing,
Error(15,1): PLS-00103: Encountered the symbol "/" The symbol "/" was ignored.
In the object viewer context you should not have the slash. In the worksheet, as in SQL*Plus, SQL Developer:
... 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.
So in the worksheet the slash is necessary to delimit the end of the (named) block and identify the entirety of the create
statement.
In the object viewer you are only seeing the code for that object, so there is no need to have that slash delimiter, and everything in the SQL window is treated as part of the object source code.
Similarly if you look in the user_source
data dictionary view, there is no line stored for the slash.
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.
It is part of the client's statement handling, not part of the function.
If you are in the object viewer then you can't create a second object in the same SQL window. That is the source code for the object you are viewing.
If you want to create multiple objects at once in a script then use a worksheet (right-click your connection and choose 'Open SQL Worksheet'), put all your code in, and then run as a script (F5). If you want to use the object view then expand your connection, right-click on the 'Packages' option, and choose 'New Package'.
Read more about managing objects and the SQL Worksheet.