我正在尝试拆分 PL/SQL 指令。我带来了以下模式:
splitter_re = '(DECLARE.+?END;)\n+|;\n+'
我有以下 PL/SQL 代码:
CREATE TABLE bk_temp1_kb AS
SELECT DISTINCT bk_c, bk_o, bk_r, bk_m
FROM www2013_02;
DECLARE
time_val NUMBER;
BEGIN
SELECT day INTO time_val
FROM days
WHERE day_desc = TO_CHAR(SYSDATE - 1);
EXECUTE IMMEDIATE
'DROP TABLE telep';
EXECUTE IMMEDIATE
'CREATE TABLE telep AS
SELECT cc,
dao,
a,
nam
FROM prodc
WHERE timer = ' || time_val;
END;
DROP TABLE kart;
CREATE TABLE kart AS
SELECT b.dwp
FROM t_prod_new b
WHERE b.task = 'CARD';
split() 的结果是:
['CREATE TABLE bk_temp1_kb AS\nSELECT DISTINCT bk_c, bk_o, bk_r, bk_m\nFROM www2
013_02', None, '', "DECLARE\n time_val NUMBER;\nBEGIN\n SELECT day INTO time_v
al\n FROM days\n WHERE day_desc = TO_CHAR(SYSDATE - 1);\n \n EXECUTE IMMEDIAT
E\n 'DROP TABLE telep';\n \n EXECUTE IMMEDIATE\n 'CREATE TABLE telep AS\n SE
LECT cc,\n dao,\n a,\n nam \n FROM prodc\n WHERE timer =
' || time_val;\nEND;", 'DROP TABLE kart', None, "CREATE TABLE kart AS\nSELECT b
.dwp\nFROM t_prod_new b\nWHERE b.task = 'CARD';"]
它非常好,但我没有元素。模式有什么问题?