chakkk309 commented on issue #27153:
URL: 
https://github.com/apache/shardingsphere/issues/27153#issuecomment-2505060330

   Hi, I checked these SQL statements on an Oracle database, and encountered 
the following error: `missing INTO keyword`
   
   
![image001](https://github.com/user-attachments/assets/74f6430b-35ef-4e26-859c-f91c52fd4f36)
   
   Additionally, I found some examples on the Oracle website, such as:
   
   <img width="859" alt="image" 
src="https://github.com/user-attachments/assets/6bd1f875-ea49-4da3-8cc9-f1c5e298c02f";>
   
   
   
   The correct SQL should look like this:
   
   ``` SQL
   MERGE INTO Products P                            
   USING Product_Changes S                         
   ON (P.PROD_ID = S.PROD_ID)                  
   WHEN MATCHED THEN
   UPDATE 
   SET P.PROD_LIST_PRICE = S.PROD_NEW_PRICE
   WHERE P.PROD_STATUS <> "OBSOLETE";        
   ```
   
   
   ```SQL
   MERGE INTO Products D2                          
   USING New_Product S                             
   ON (D2.PROD_ID = S.PROD_ID)                    
   WHEN NOT MATCHED THEN                          
   INSERT (PROD_ID, PROD_STATUS) VALUES (S.PROD_ID, S.PROD_NEW_STATUS);
   ```
   
   ```SQL
   MERGE INTO Products P                          
   USING New_Product S                          
   ON (1 = 0)                                    
   WHEN NOT MATCHED THEN                        
   INSERT (PROD_ID, PROD_STATUS) VALUES (S.PROD_ID, S.PROD_NEW_STATUS);
   ```
   
   ```SQL
   MERGE INTO Products D                             
   USING Product_Changes S                              
   ON (D.PROD_ID = S.PROD_ID)                        
   WHEN MATCHED THEN
   UPDATE SET D.PROD_LIST_PRICE = S.PROD_NEW_PRICE, D.PROD_STATUS = 
S.PROD_NEWSTATUS
   DELETE WHERE D.PROD_STATUS = "OBSOLETE"      
   WHEN NOT MATCHED THEN
   INSERT (PROD_ID, PROD_LIST_PRICE, PROD_STATUS)
   VALUES (S.PROD_ID, S.PROD_NEW_PRICE, S.PROD_NEW_STATUS);
   ```
   
   
   ```SQL
   MERGE INTO Products P                               
   USING Product_Changes S                             
   ON (P.PROD_ID = S.PROD_ID)                           
   WHEN MATCHED THEN UPDATE 
   SET P.PROD_LIST_PRICE = S.PROD_NEW_PRICE
   WHERE P.PROD_STATUS <> "OBSOLETE"                
   WHEN NOT MATCHED THEN
   INSERT (PROD_ID, PROD_STATUS, PROD_LIST_PRICE)  
   VALUES (S.PROD_ID, S.PROD_NEW_STATUS, S.PROD_NEW_PRICE)
   WHERE S.PROD_STATUS <> "OBSOLETE";           
   ```
   
   I tested these SQL statements, which are already supported by the PR 
https://github.com/apache/shardingsphere/pull/9361, 
https://github.com/apache/shardingsphere/pull/30452, and 
https://github.com/apache/shardingsphere/pull/28247, maybe we can close this 
issue.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to