Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
155 views
in Technique[技术] by (71.8m points)

sql - Failed to create view

CREATE OR REPLACE VIEW ALL_INTERRUPTED_DATA AS
select
    trigger_info_A.b1,
    trigger_info_A.b2,
    trigger_info_A.B3TEXT,
    trigger_info_A.elem,
    trigger_info_B.b1,
    trigger_info_B.b2,
    trigger_info_B.B3TEXT,
    trigger_info_B.elem,
    oms_source.source_code,
    energization_info.b1,
    energization_info.b2,
    energization_info.b3text,
    to_char(energization_info.deenergized_date,'DD-MM-YYYY Hh24:MI:SS'),
    to_char(energization_info.energized_date,'DD-MM-YYYY Hh24:MI:SS'),
    oms_source.connected_customer,
    trigger_info_A.comments
from
    energization_info,
    trigger_info trigger_info_A,
    trigger_info trigger_info_B,
    oms_source
where
    (
        energization_info.trigger_number = trigger_info_A.trigger_number
    )
    and (
        energization_info.ENERGIZED_TRIGGER_NUMBER = trigger_info_B.trigger_number
    )
    and (
        energization_info.b1 = oms_source.B1NAME
        and energization_info.b2 = oms_source.B2NAME
        and energization_info.b3 = oms_source.B3NAME
    ) WITH READ ONLY;

trigger_info_B.b1,trigger_info_B.b2,trigger_info_B.B3TEXT,trigger_info_B.elem,

ERROR at line 3: ORA-00957: duplicate column name

question from:https://stackoverflow.com/questions/66057076/failed-to-create-view

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I can see the duplicate names in the select clause.

Example:

trigger_info_A.b1
trigger_info_B.b1

While creating the view, each columns in select must have different name/alias.

Try to find such duplicate names of columns and give them different names using alias.

Example:

trigger_info_A.b1 as A_b1
trigger_info_B.b1 as B_b1

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...