Home » SQL & PL/SQL » SQL & PL/SQL » Merge (oracle 9i)
Merge [message #364528] Tue, 09 December 2008 00:20 Go to next message
sowmyaa
Messages: 26
Registered: November 2008
Junior Member
Hi,
I have a doubt in the Merge statement.

MERGE INTO T_S1 THS
USING (SELECT MIN(A.ASUP_ID),MAX(A.SUP_ID),B.DC_SNO,B.DC_ML
FROM T_TET2 A JOIN T_T1 B ON (A.DC_ID = B.DC_ID)
WHERE DC_TYPE = 'xxxx'GROUP BY B.DC_SNO, B.DC_ML) DRVDTBL
ON (THS.DVC_SNO =DRVDTBL.DVC_SNO AND THS.DVC_ML =DRVDTBL.DVC_ML)
WHEN MATCHED
THEN UPDATE SET THS.MIN_ASUP = CASE
WHEN THS.MIN_ASUP > DRVDTBL.MIN_ASUP THEN DRVDTBL.MIN_ASUP THEN DRVDTBL.MIN_ASUP
ELSE THS.MIN_ASUP

WHEN NOT MACTHED
THEN INSERT VALUES (DRVDTBL.MIN_ASUP,DRVDTBL.MAX_ASUP,DRVDTBL.DC_SNO,DRVDTBL.DC_ML);

Expalnation is:
1.I want to check it for "when matched condition" (select * from T_S1 union select * from DRVDTBL) which should be inserted to the table T_s1?

Thanks,
Sowmya
Re: Merge [message #364530 is a reply to message #364528] Tue, 09 December 2008 00:30 Go to previous message
Michel Cadot
Messages: 65155
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
From your previous post:
Michel Cadot wrote on Fri, 05 December 2008 12:19
From time to time I'm tired and disheartened to repeat the same thing, but if you encourage me I can post it.

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) and use code tags.
Use the "Preview Message" button to verify.

Regards
Michel


Previous Topic: delete cascade
Next Topic: Request for a specefic date?
Goto Forum:
  


Current Time: Thu Aug 24 02:00:30 CDT 2017

Total time taken to generate the page: 0.05058 seconds