title: How to declare a function in a PLSQL block and call same in a select query?
body: <p>I have a code like this-:</p>
  
  <pre><code>DECLARE
  
    --BEGIN
    V_DATE DATE;
  
    FUNCTION GETDATE(NUM_DAYS NUMBER) RETURN DATE IS
        PRAGMA AUTONOMOUS_TRANSACTION; 
    BEGIN
        INSERT INTO LEAVE.GES_LEV_REQ_PURG_ERR VALUES (NUM_DAYS, NUM_DAYS, SYSDATE);
          COMMIT;
      RETURN(SYSDATE);
    END GETDATE;
  
  BEGIN
  
    --V_DATE := GETDATE(1);
    SELECT GETDATE(1) INTO V_DATE FROM DUAL;
    DBMS_OUTPUT.PUT_LINE(V_DATE);
  
  END;
  /
  </code></pre>
  
  <p>But this is throwing below error-</p>
  
  <pre><code>ORA-06550: line 17, column 10:
  PLS-00231: function 'GETDATE' may not be used in SQL
  ORA-06550: line 17, column 10:
  PL/SQL: ORA-00904: : invalid identifier
  ORA-06550: line 17, column 3:
  PL/SQL: SQL Statement ignored
  </code></pre>
  
  <p>While if I am calling that function without select query, it works fine.
  Please help.</p>