Unix Technical Forum

Merge - ora-00904 - Invalid Identifier.

This is a discussion on Merge - ora-00904 - Invalid Identifier. within the Oracle Miscellaneous forums, part of the Oracle Database category; --> Hi Folks, I'm pretty new no Oracle and SQL and have been trying to learn as I go. Can ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database > Oracle Miscellaneous

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-08-2008, 12:39 PM
robert.mcauley@eurocarparts.com
 
Posts: n/a
Default Merge - ora-00904 - Invalid Identifier.

Hi Folks, I'm pretty new no Oracle and SQL and have been trying to
learn as I go. Can someone please help?
I have to "UPSERT" tables on a monthly basis from text files from a
data supplier.

I plan to replace each text file into staging table, Create a trigger
on the staging table to "MERGE" the data onto a final table. I have
had to do it this way as sqlldr will not alllow merge.

I've been trying to get the merge working on it's own before inclusion
in a trigger but am getting ORA-00904 - Invalid Identifier. I have
checked and re-checked and cannot spot the error. Any clues anyone?

MERGE INTO "LOAD_TEST_T"
USING (SELECT * from "LOAD_TEST_IN")
ON ("LOAD_TEST_T"."PZ"="LOAD_TEST_IN"."PZ")
WHEN MATCHED THEN
UPDATE
SET "LOAD_TEST_T"."TEXT"="LOAD_TEST_IN"."TEXT"
WHEN NOT MATCHED THEN
INSERT
("LOAD_TEST_T"."PZ", "LOAD_TEST_T"."TEXT")
VALUES
("LOAD_TEST_IN"."PZ", "LOAD_TEST_IN"."TEXT");





I'll be extremely embarrassed if it's a typo.........

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-08-2008, 12:39 PM
Maxim Demenko
 
Posts: n/a
Default Re: Merge - ora-00904 - Invalid Identifier.

robert.mcauley@eurocarparts.com schrieb:
> Hi Folks, I'm pretty new no Oracle and SQL and have been trying to
> learn as I go. Can someone please help?
> I have to "UPSERT" tables on a monthly basis from text files from a
> data supplier.
>
> I plan to replace each text file into staging table, Create a trigger
> on the staging table to "MERGE" the data onto a final table. I have
> had to do it this way as sqlldr will not alllow merge.
>
> I've been trying to get the merge working on it's own before inclusion
> in a trigger but am getting ORA-00904 - Invalid Identifier. I have
> checked and re-checked and cannot spot the error. Any clues anyone?
>
> MERGE INTO "LOAD_TEST_T"
> USING (SELECT * from "LOAD_TEST_IN")
> ON ("LOAD_TEST_T"."PZ"="LOAD_TEST_IN"."PZ")
> WHEN MATCHED THEN
> UPDATE
> SET "LOAD_TEST_T"."TEXT"="LOAD_TEST_IN"."TEXT"
> WHEN NOT MATCHED THEN
> INSERT
> ("LOAD_TEST_T"."PZ", "LOAD_TEST_T"."TEXT")
> VALUES
> ("LOAD_TEST_IN"."PZ", "LOAD_TEST_IN"."TEXT");
>
>
>
>
>
> I'll be extremely embarrassed if it's a typo.........
>


Try it like this

MERGE INTO "LOAD_TEST_T"
USING (SELECT * from "LOAD_TEST_IN") LOAD_TEST_IN
ON ("LOAD_TEST_T"."PZ"="LOAD_TEST_IN"."PZ")
WHEN MATCHED THEN
UPDATE
SET "LOAD_TEST_T"."TEXT"="LOAD_TEST_IN"."TEXT"
WHEN NOT MATCHED THEN
INSERT
("LOAD_TEST_T"."PZ", "LOAD_TEST_T"."TEXT")
VALUES
("LOAD_TEST_IN"."PZ", "LOAD_TEST_IN"."TEXT");


or even more simply:

MERGE INTO "LOAD_TEST_T"
USING LOAD_TEST_IN
ON ("LOAD_TEST_T"."PZ"="LOAD_TEST_IN"."PZ")
WHEN MATCHED THEN
UPDATE
SET "LOAD_TEST_T"."TEXT"="LOAD_TEST_IN"."TEXT"
WHEN NOT MATCHED THEN
INSERT
("LOAD_TEST_T"."PZ", "LOAD_TEST_T"."TEXT")
VALUES
("LOAD_TEST_IN"."PZ", "LOAD_TEST_IN"."TEXT");


Best regards

Maxim
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 07:15 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com