title: PLSQL : Apply IN operator check conditionally
body: <p>User inputs numbers (1,2,3 etc). My requirement is if the User input number is present in a database table
  then only those records should be retrieved. <strong>If User has NOT entered data then ALL the records from the table should be retrieved</strong>.</p>
  
  <p>User input numbers are stored in <code>table type</code> and relevant code is below.</p>
  
  <p><code>CREATE OR REPLACE TYPE ACCNT_NUMBER_TYPE AS TABLE OF NUMBER;</code> //ACCNT_NUMBER_TYPE will have values 1,2,3 etc.</p>
  
  <p>Below is my procedure.</p>
  
  <pre><code>CREATE OR REPLACE PACKAGE BODY pr_retrieve_data as
  PROCEDURE FETCH_MYTABLE_DETAILS() is
  
  FOR indx in (select column1,
                      column2
               from   SOMEOTHERTABLE SOT
               WHERE  SOT.ACCNT_NUMBER IN (SELECT * FROM TABLE(L_ACCNT_NUMBER)))
  LOOP
  
  ...
  -- Around 300 lines of code goes here
  
  END LOOP;
  
  end FETCH_MYTABLE_DETAILS;
  end pr_retrieve_data;
  </code></pre>
  
  <p>The problem I am facing is, I am not able to write logic for the case where User has not input data. In this 
  case I am supposed to retrieve all the records. <em>But, as per the above FOR loop if the User has not input data
  then it will NOT fetch any records.</em></p>
  
  <p>I could write another FOR loop by putting condition if User data is <code>null</code>. But, there will be repetition of 300 lines of 
  code. This will increate maintenace.</p>
  
  <p><em>How can I tweek the FOR loop such that if User enters data then only that record is retrieved and when User 
  does not enter data then ALL the records are retrieved?</em></p>