Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

update statement getting ORA-00904 invalid identifier

user515689Feb 7 2012 — edited Feb 7 2012
I am getting this ORA error when I try to conduct an update statement from a column value in one table to a like-named column in another table.

For instance, in my select, shown below, this query runs like a champ, returning all of my records
SELECT 
b.ID, 
b.ZIP, a.ZIP,
a.NAME, 
a.LOCATION
FROM TBL_ARCHIVE a
INNER JOIN TBL_UAT b ON 
a.ID = b.ID
WHERE 
b.ID > 470000  And b.ID <470100;
However, if I try to run an update statement with any of the following, I get this error. It seems so strange to me that I'd get an error using the same columns in the update statement, but would return the desired results effectively from the select statement!

one version of UPDATE
UPDATE TBL_ARCHIVE a
SET a.ZIP = TBL_UAT.ZIP
WHERE TBL_UAT.ID = a.ID;
and another
UPDATE TBL_ARCHIVE 
SET a.ZIP  =
(SELECT b.ZIP 
FROM TBL_UAT b
WHERE b.ID <472500 And b.ID >471000)
FROM TBL_ARCHIVE a
WHERE a.ID = b.ID)
WHERE ID IN
(SELECT ID 
FROM TBL_UAT b
WHERE b.ID  <472500 And b.ID >471000
);
^ - this one produces a SQL not properly ended. Error ORA-00933: SQL command not properly ended.

I'm really unsure though, how what I thought was a fairly basic update statement wouldn't work. I'm using Oracle 11g but through either Toad or SQL Plus. I've gotten these same errors in both.
Though MS Access runs slow as snails, I can manage to run the update statement successfully with it, a thousand records or so at a time. Problem is, I've got about 300K records needing updating.

I've looked around for similar problems but haven't found one where someone wasn't either using a reserved word for a column, which I'm not, I don't believe, or a problem that really dealt with this error in the context of an update statement.
But I'd welcome any enlightenment on this.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 6 2012
Added on Feb 7 2012
12 comments
10,319 views