title: Using variables in cursor declaration query in oracle
body: <p>Is there a way to use a variable in cursor declaration sql ?
  Example-</p>
  
  <pre><code>create or replace PROCEDURE PRD (IN_VAR  IN VARCHAR2)
  IS
  
    V_V1 TABLE.DATE_COL%TYPE;
  
     /* Cursor decleration */
     CURSOR CUR_DUMMY
     IS
          SELECT COL1,COL2,COL3 
            FROM TABLE 
               WHERE DATE_COL BETWEEN V_V1 
                      AND V_V1+1;
  
  BEGIN
     FOR REC  IN CUR_DUMMY
     LOOP
  
      SELECT TO_DATE(TO_CHAR(sysdate, 'DD-MON-YY') ||' '||(SELECT TO_CHAR(DAY_BEGIN,'HH24:MI:SS') FROM TABLE2),'DD-MON-YY HH24:MI:SS') INTO  V_V1 from DUAL;   
  
  --  other stuffs
      END LOOP;
  END;
  </code></pre>
  
  <p>Here the cursor doesn't fetch the required records.
  Can I assign the V_V1 value somewhere before the cursor declaration?
  Though I can get dates in the cursor sql itself but there will be redundant select query. Is there a better way ?   </p>