Created
April 2, 2018 09:27
-
-
Save redknitin/8e89b1df835934901186d07ce5c7647d to your computer and use it in GitHub Desktop.
PL/SQL 'Table-valued function' to return list of dates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--PLSQL 'Table-valued function' | |
create type my_dt_type is object(dt date); | |
/ | |
create type my_dt_tab_type is table of my_dt_type; | |
/ | |
create or replace function get_all_dates(p_start IN DATE, p_end IN DATE) | |
return my_dt_tab_type pipelined is | |
begin | |
for i in 0..(p_end - p_start) | |
loop | |
pipe row(my_dt_type(p_start + i)); | |
end loop; | |
return; | |
end; | |
/ | |
select * from table(get_all_dates('1-JAN-2018', '7-JAN-2018')); | |
/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment