我完全不知道我的问题在哪里。之前我写了一个编译得很好的程序,但是现在我注意到如果我采用确切的代码(甚至从程序本身复制/粘贴),并尝试再次运行它,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 :(得分:0)
根据William Robertson的评论,问题是有另一个会议正在使用该程序。这次会议被杀了,我能够重新编译。