sinat_28941375
sinat_28941375
2016-01-12 09:49

ORA-00957---重复的列名

  • oracle

帮忙看看为什么会报这个错:
CREATE OR REPLACE PROCEDURE PRO_SBSJHZ2 Authid Current_User IS

V_SQL VARCHAR2(20000);

CURSOR CURSOR_1 IS SELECT DISTINCT T.Khxmbm,T.khxmmc FROM VW_SBSJHZ2 T ORDER BY T.Khxmbm;

BEGIN

  V_SQL := 'SELECT JGMC ';

  FOR V_khxmmc IN CURSOR_1

  LOOP

    V_SQL := V_SQL || ',sum(case khxmmc when ''' ||  V_khxmmc.Khxmmc || '''then tjsl else 0 end) as '
    ||V_khxmmc.Khxmmc;

  END LOOP;

  V_SQL := V_SQL || ' FROM VW_SBSJHZ2  group by JGMC';

  DBMS_OUTPUT.PUT_LINE('1---'||V_SQL);

  V_SQL := 'CREATE OR REPLACE VIEW RESULT_SJSB  AS '||  V_SQL;

  EXECUTE IMMEDIATE V_SQL;


END;

图片说明

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答