Home » SQL & PL/SQL » SQL & PL/SQL » What is wrong with this sql code?
What is wrong with this sql code? [message #652617] Tue, 14 June 2016 15:14 Go to next message
anticristo
Messages: 1
Registered: June 2016
Junior Member
Hi!

I am trying to learn Oracle. I come from Access. The below code triggers the "Command not properly ended" error". What's is wrong with this? Thanks

UPDATE MUNICIPALITY A
SET A.COUNTY_ID = B.COUNTY_ID
FROM MUNICIPALITY A
INNER JOIN  XLSMUNICIPALITIES2 B
ON A.MUNICIPALITY_TYPE_ID = B.MUNICIPALITY_TYPE_ID AND A.MUNICIPALITY_NAME = B.MUNICIPALITY_NAME
WHERE A.COUNTY_ID IS NULL
Re: What is wrong with this sql code? [message #652618 is a reply to message #652617] Tue, 14 June 2016 15:26 Go to previous messageGo to next message
Michel Cadot
Messages: 68636
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Welcome to the forum.
Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Also always post your Oracle version, with 4 decimals, as solution depends on it.

Oracle does not support this syntax, you have to rewrite the query in a valid syntax for Oracle: UPDATE.
Something like:
UPDATE MUNICIPALITY A
SET A.COUNTY_ID = (SELECT B.COUNTY_ID
                   FROM XLSMUNICIPALITIES2 B
                   WHERE A.MUNICIPALITY_TYPE_ID = B.MUNICIPALITY_TYPE_ID 
                     AND A.MUNICIPALITY_NAME = B.MUNICIPALITY_NAME)
WHERE A.COUNTY_ID IS NULL
/
Re: What is wrong with this sql code? [message #652639 is a reply to message #652617] Wed, 15 June 2016 06:34 Go to previous messageGo to next message
EdStevens
Messages: 1376
Registered: September 2013
Senior Member
anticristo wrote on Tue, 14 June 2016 15:14
Hi!

I am trying to learn Oracle. I come from Access.



Then the first thing you need to do is realize that every database product (and I use the term "database" loosely when including Access) has their own variations and implementations of the SQL language. That is why they publish SQL Reference manuals. Oracle's is at https://docs.oracle.com/cd/E11882_01/server.112/e41084/toc.htm Depending on your level of involvement, you might want to bookmark the entire doc library portal, for 11g or 12c.
Re: What is wrong with this sql code? [message #652642 is a reply to message #652617] Wed, 15 June 2016 07:34 Go to previous message
EdStevens
Messages: 1376
Registered: September 2013
Senior Member
anticristo wrote on Tue, 14 June 2016 15:14
Hi!

I am trying to learn Oracle. I come from Access. The below code triggers the "Command not properly ended" error". What's is wrong with this? Thanks



https://community.oracle.com/thread/3940312?sr=inbox&ru=742234
Previous Topic: regexp replace
Next Topic: "ORA-22813: operand value exceeds system limits" on executing sql returning XMLTYPE data
Goto Forum:
  


Current Time: Tue Apr 16 08:38:28 CDT 2024