title: I need to declare a variable in oracle view
body: <p>Basically I have a view  which is having below query as a part of view .</p>
  
  <pre><code>SELECT site_id ch_site_id 
    FROM bfg_router_pi_details 
   WHERE last_modified_date &gt; (SELECT MAX (last_time_stamp) 
                                 FROM saa_bfg_feed_ctl)
  </code></pre>
  
  <p>Now in this query bfg_router_pi_details  is a view in  another  database and saa_bfg_feed_ctl  is a table in same database from we are firing this query.</p>
  
  <p>Now when This query is fired like above using inner query in where clause, it takes 2 hours to finish as it is going over the db link. however if i replace the inner query with the actual date value it takes 2 minutes. so I am trying to see if there is any way that I can define a variable in view and assign the last time stamp value to that variable and then replace that variable in the  where clause of the query so that execution become s faster. hope you understood the problem in hand. </p>