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!

ORA-00904: invalid identifier What is wrong here?

Erhan_torontoJul 14 2013 — edited Jul 14 2013

I have two tables inside two different database with granted access to two users. I put two tables and also my query to get the result like below but I am getting error. Please help. Thanks

I want to see the result like this:

Alter table Target_table modify BOOK_ID Varchar2 (4);

Alter table Target_table add ISBN_10 Varchar2(13), null;

Alter table Target_table drop TITLE;

Tables and quesries:

GRADE_CONVERSION table in sarigul@database

LETTER_GRADEGRADE_POINTMAX_GRADEMIN_GRADE

ds

.24456
as.25454
fr.2641
hy.27459
kl.23456

GRADE_CONVERSION table in erhan@database

GRADE_POINTGRADE_POINT MAX_GRADEMIN_GRADECREATED_BY CREATED_DATE CREATED_BYMODIFIED_DATE
GR.12235YES12/09/2013 00:00:00ERHAN03/09/2012 00:00:00
GR.1235YES12/09/2013 00:00:00ERHAN03/09/2012 00:00:00
TR.12235YES12/09/2013 00:00:00ERHAN03/09/2012 00:00:00
SR.12235YES12/09/2013 00:00:00ERHAN03/09/2012 00:00:00
YR.137235YES12/09/2013 00:00:00ERHAN03/09/2012 00:00:00
GR.132835YES12/09/2013 00:00:00ERHAN03/09/2012 00:00:00
JR.132935YES12/09/2013 00:00:00ERHAN03/09/2012 00:00:00
KR.1242355YES12/09/2013 00:00:00ERHAN03/09/2012 00:00:00
LR.142356YES12/09/2013 00:00:00ERHAN03/09/2012 00:00:00
MR.1923YES12/09/2013 00:00:00ERHAN03/09/2012 00:00:00
QR.15235YES12/09/2013 00:00:00ERHAN03/09/2012 00:00:00
AR.17215YES12/09/2013 00:00:00ERHAN03/09/2012 00:00:00
BR.13275YES12/09/2013 00:00:00ERHAN03/09/2012 00:00:00
CR.12265YES12/09/2013 00:00:00ERHAN03/09/2012 00:00:00
XR.14255YES12/09/2013 00:00:00ERHAN03/09/2012 00:00:00

select case when column_name_s is null and column_name_t is not null

            then 'alter table target_table drop ' || column_name_t || ';'

            when column_name_s is not null and column_name_t is null

            then 'alter table target_table add ' || column_name_s || ' ' || data_type_s || ';'

            else 'alter table target_table modify ' || column_name_t || ' ' || data_type_s || ';'

       end alterations

  from (select s.coulmn_name column_name_s,t.coulmn_name column_name_t,

               s.data_type data_type_s,t.data_type data_type_t

          from (select column_id,column_name,data_type

                  from all_tab_cols@database

                 where owner = 'erhan'

                   and table_name = 'GRADE_CONVERSION'

               ) s

               full outer join

               (select column_id,column_name,data_type

                  from all_tab_cols@database

                 where owner = 'sarigul'

                   and table_name = 'GRADE_CONVERSION'

               ) s

            on s.LETTER_GRADE = t.LETTER_GRADE                        

       )

result: ORA-00904: "T"."LETTER_GRADE": invalid identifier

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 11 2013
Added on Jul 14 2013
20 comments
5,680 views