Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Function with select in it (with 1 variable)

OdigitriumSep 22 2018 — edited Sep 23 2018

For example, in the current query need's to be able to substitute sydate by variable.

I would like to call the function something like: get_empnos2('10-sep-18')

CREATE OR REPLACE FUNCTION get_empnos2

  RETURN SYS_REFCURSOR

IS

  l_rc SYS_REFCURSOR;

BEGIN

  OPEN l_rc

   FOR select

    next_day(sysday - (level - 1) * 7, 'SUN' ) + 1 - 14 BEGIN_OF_WEEK

   ,next_day(sysday - (level - 1) * 7, 'SUN' )         END_OF_WEEK

from dual

connect by level <= 3;

  RETURN l_rc;

END;

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 20 2018
Added on Sep 22 2018
5 comments
300 views