2017-08-28 80 views
0

我是在一個完整的損失嚴重,我的問題是。早前我寫的精編的程序,但現在我發現,如果我走了確切的代碼(甚至從程序本身複製/粘貼),並嘗試再次運行它,SQL開發人員基本上是凍結它從不編譯。以前編譯的P/L SQL現在凍結在SQL Developer中

的SQL本身肯定是不乾淨的,我知道,我將它一點點比一個更好的程序員會更復雜,但是如果它編譯早期就應該重新編譯,不是嗎?下面是情況下可以幫助P/L SQL ...

create or replace PROCEDURE insert_comments AS 

v_blob BLOB; v_record number; 

BEGIN 


SELECT blob_content INTO v_blob from xlsx_files; 

for x in 
    (select id into v_record from 
     (SELECT to_number(id) id, name FROM 
      (WITH xlsx AS 
       (SELECT 
        ROW_NR, 
        COL_NR, 
        CASE CELL_TYPE 
         WHEN 'S' 
          THEN STRING_VAL 
         WHEN 'N' 
          THEN TO_CLOB(NUMBER_VAL) 
         WHEN 'D' 
          THEN TO_CLOB(TO_CHAR(DATE_VAL, 'DD-MON-YYYY')) 
         ELSE 
          TO_CLOB(FORMULA) 
        END CELL_VAL 
       FROM 
        (SELECT * FROM 
         TABLE(as_read_xlsx_clob.read(v_blob)) 
         --as_read_xlsx_clob is a function from the As_read_XLSX_CLOB package 
        ) 
       ) 
      /*The below statement works as a roundabout way of pivoting 
      the table. Since the data in the file may contain CLOBs, you 
      can't use the PIVOT function since CLOBs do not support 
      aggregation. I have commented out the original SQL that used 
      PIVOT*/ 
      SELECT id_table.id, name_table.name FROM 
       (SELECT row_nr, cell_val id FROM 
        (SELECT * FROM xlsx WHERE row_nr > 1) id_table 
        where id_table.col_nr=1 
       ) id_table 
       inner join 
       (SELECT row_nr, cell_val name FROM 
        (SELECT * 
        FROM xlsx 
         --PIVOT (MAX(TO_CHAR(CELL_VAL)) 
         FOR COL_NR IN (1 AS ROW_WID,2 AS NAME) 
         ) ad 
         WHERE row_nr >1 
        ) name_table 
        where name_table.col_nr = 2 
       ) name_table 
      ON id_table.row_nr = name_table.row_nr 
      ) 
     ) 
    ) 
loop 
    v_record := x.id; 
    INSERT INTO comment_test(id, name) 
     (SELECT to_number(id) id, name 
     FROM 
      (WITH xlsx AS 
       (SELECT 
        ROW_NR, 
        COL_NR, 
        CASE CELL_TYPE 
         WHEN 'S' 
          THEN STRING_VAL 
         WHEN 'N' 
          THEN TO_CLOB(NUMBER_VAL) 
         WHEN 'D' 
          THEN TO_CLOB(TO_CHAR(DATE_VAL, 'DD-MON-YYYY')) 
         ELSE TO_CLOB(FORMULA) 
        END CELL_VAL 
       FROM 
       (SELECT * FROM 
        TABLE(as_read_xlsx_clob.read(v_blob)) 
        --as_read_xlsx_clob is a function from the As_read_XLSX_CLOB package 
       ) 
      ) 
      /*The below statement works as a roundabout way of 
      pivoting the table. Since the data in the file may 
      contain CLOBs, you can't use the PIVOT function since 
      CLOBs do not support aggregation. I have commented out 
      the original SQL that used PIVOT*/ 
      SELECT id_table.id, name_table.name FROM 
       (SELECT row_nr, cell_val id FROM 
        (SELECT * FROM xlsx WHERE row_nr > 1) id_table 
       where id_table.col_nr=1 
       ) id_table 
       inner join 
       (SELECT row_nr, cell_val name FROM 
        (SELECT * 
        xlsx 
         --PIVOT (MAX(TO_CHAR(CELL_VAL)) 
         FOR COL_NR IN (1 AS ROW_WID,2 AS NAME) 
         ) ad 
        WHERE row_nr >1 
        ) name_table 
       where name_table.col_nr = 2 
       ) name_table 
       ON id_table.row_nr = name_table.row_nr) 
      where to_number(id) = v_record 
     ); 
    end loop; 

delete from xlsx_files; 
END; 
+0

你確定你發佈你試圖編譯監守我可以在你的代碼發佈見上面的語法錯誤的確切代碼。 – XING

+0

是的,直接從程序中複製。它似乎很好地在不同的連接中編譯(只要引用的表存在)。思想點痛風的語法錯誤? – Ian

+0

看來非常系統特定的問題。您需要檢查您正在運行的系統是否具有所有數據庫對象,並且您有必要授予執行該proc的權限。 – XING

回答

0

每威廉·羅伯遜的評論,這個問題是有其使用的程序的另一個會話。這次會議被殺,我可以重新編譯。