Home » SQL & PL/SQL » SQL & PL/SQL » update select query (oracle 10g)
update select query [message #411351] Fri, 03 July 2009 03:43 Go to next message
rajasekhar857
Messages: 500
Registered: December 2008
Senior Member
hi,
how to write the below query using update select format

UPDATE EMRENCOUNTERDETAILS SET AGE_IN_MONTHS = MONTHS_BETWEEN(PATIENT_DOB, CREATED_DATE ) FROM EMRENCOUNTERDETAILS A
INNER JOIN EMRPATIENTSMASTER B ON A.PATIENT_ID = B.PATIENT_ID
WHERE AGE_IN_MONTHS IS NULL AND IS_SAVE_FOR_LATER = 0
/
Re: update select query [message #411357 is a reply to message #411351] Fri, 03 July 2009 03:55 Go to previous messageGo to next message
Michel Cadot
Messages: 68643
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter), use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).

Regards
Michel
Re: update select query [message #411358 is a reply to message #411351] Fri, 03 July 2009 04:02 Go to previous messageGo to next message
ashoka_bl
Messages: 398
Registered: November 2006
Location: Bangalore
Senior Member

As usual (From all your previous posts) we(I) haven't understood anything, We don't have anything except one UNFORMATTED UPDATE STATEMENT,

After 200+ messages..still you doesn't post the message with formatting...

Are you looking something like this ??

UPDATE (
  SELECT *
  FROM test
  WHERE table_name NOT LIKE '%A%')
SET extent_management = 'Unknown'
WHERE table_name NOT LIKE '%A%';
Re: update select query [message #411359 is a reply to message #411351] Fri, 03 July 2009 04:03 Go to previous messageGo to next message
bonker
Messages: 402
Registered: July 2005
Senior Member
I did not understand what you mean by update using select format but I assume you mean to use something like this

 update (select col1,col2 from tbl1, tbl2 where ..)  set col = col2 


but bear in mind the table from where you update should be key preserved otherwise you will get ORA-01779 error
Re: update select query [message #411448 is a reply to message #411351] Fri, 03 July 2009 15:23 Go to previous message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>how to write the below query using update select format

You need to help us by following the Posting Guidelines as stated below.
http://www.orafaq.com/forum/t/88153/0/
Go to the URL above click the link "Posting Guidelines"
Go to the section labeled "Practice" & do as directed.

Post DDL for tables.
Post DML for test data.

Post expected/desired results.
Previous Topic: Weak and Strongly Typed Reference Cursors
Next Topic: Faster way to update large amount of data
Goto Forum:
  


Current Time: Tue Apr 23 16:52:14 CDT 2024