Skip to content

Instantly share code, notes, and snippets.

@redknitin
Created April 2, 2018 09:27
Show Gist options
  • Save redknitin/8e89b1df835934901186d07ce5c7647d to your computer and use it in GitHub Desktop.
Save redknitin/8e89b1df835934901186d07ce5c7647d to your computer and use it in GitHub Desktop.
PL/SQL 'Table-valued function' to return list of dates
--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