943,923 Members | Top Members by Rank

Ad:
  • Oracle Discussion Thread
  • Marked Solved
  • Views: 824
  • Oracle RSS
Aug 20th, 2009
0

UPDATE Problem

Expand Post »
Hi,

I have a table which I want to update thus:

If d_date is has a value and b_date is 30 or more then set d_date as the min value already in d_date. I know that the WHERE EXISTS clause is wrong but I don't know how to make this work.


Oracle Syntax (Toggle Plain Text)
  1. UPDATE TABLE
  2. SET d_date =
  3. (
  4. SELECT MIN(d_date)
  5. FROM TABLE
  6. )
  7. WHERE EXISTS
  8. (
  9. SELECT FLOOR( MONTHS_BETWEEN (SYSDATE, b_date) / 12 )
  10. FROM agents
  11. WHERE FLOOR( MONTHS_BETWEEN (SYSDATE, b_date) / 12 ) >=30
  12. )
  13. AND d_date IS NOT NULL
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
Roybut is offline Offline
26 posts
since Oct 2008
Aug 21st, 2009
0

Re: UPDATE Problem

Doh! I sorted it out myself:

Oracle Syntax (Toggle Plain Text)
  1. UPDATE TABLE
  2. SET d_date =
  3. (
  4. SELECT MIN(d_date)
  5. FROM TABLE
  6. )
  7. WHERE
  8. FLOOR( MONTHS_BETWEEN (SYSDATE, b_date) / 12 ) >=30
  9. AND d_date IS NOT NULL

I was making it more complicated than it was.
Last edited by Roybut; Aug 21st, 2009 at 9:57 am.
Reputation Points: 10
Solved Threads: 0
Light Poster
Roybut is offline Offline
26 posts
since Oct 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Oracle Forum Timeline: Help wit PLSQL
Next Thread in Oracle Forum Timeline: Sqldeveloper





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC