title: Oracle db: How to update with the results of a function?
body: <p>I have a table that looks like this one:</p>
  
  <pre><code>id1 | id2 | start_date | end_data
  </code></pre>
  
  <p>where id1, id2 and start_data shape the primary key.
  Bellow you can see an example:</p>
  
  <pre><code>- 5624 |    JK  |   16/06/2017  |   20/06/2017
  - 5624 |    JK  |   20/06/2017  |   22/06/2017
  - 5624 |    JK  |   27/09/2017  |   01/10/2017
  - 5624 |    JK  |   09/10/2017  |   (null)
  - . . .
  </code></pre>
  
  <p>So I want to update the start_date with the value of end_data of the previous column.</p>
  
  <pre><code>- 5624 |    JK  |   16/06/2017  |   20/06/2017
  - 5624 |    JK  |   20/06/2017  |   22/06/2017
  - 5624 |    JK  |   22/06/2017  |   01/10/2017
  - 5624 |    JK  |   01/10/2017  |   (null)
  - . . .
  </code></pre>
  
  <p>I will delete the primary key temporarily.</p>
  
  <p>I try to use the LAG function and I get:</p>
  
  <pre><code>- id1 | id2 | start_date | end_data | LAG
  __________________________________________
  - 5624 |    JK  |   16/06/2017  |   20/06/2017 | (null)
  - 5624 |    JK  |   20/06/2017  |   22/06/2017 | 20/06/2017
  - 5624 |    JK  |   27/09/2017  |   01/10/2017 | 22/06/2017
  - 5624 |    JK  |   02/10/2017  |   (null)     | 01/10/2017 
  - . . .
  </code></pre>
  
  <p>How can I use the result of LAG function to update every row with his value in start_date column? Do you guys think that I can use a different approach to reach my target?</p>