为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本】: dm8
【操作系统】:linux
【CPU】: x86
【问题描述】*:需要将客户的达梦SQL文件进行解析,并拆分为多条语句依次执行,请问达梦有提供相关的库或者工具可以做到吗?试了使用开源的解析库,没法做到。
比如:有条SQL文件内容是:
-- 创建测试表 test_tab
create table IF NOT EXISTS test_tab (id int primary key, name varchar(30));
-- 创建有参数存储过程 p_test
create or replace procedure p_test(i in int)
as j int;
begin
for j in 1 ..i loop
insert into test_tab values(j,'p_test'||j);
end loop;
end;
call p_test(3);
然后希望分别解析成3条语句
create table IF NOT EXISTS test_tab (id int primary key, name varchar(30));
create or replace procedure p_test(i in int)
as j int;
begin
for j in 1 ..i loop
insert into test_tab values(j,'p_test'||j);
end loop;
end;
call p_test(3);
我觉得可以通过正则表达式实现。
比如
以create table 开头 以;结尾,提取到一个文件
以 create or replace procedure 以;结尾,提取到一个文件
以call 开头 以;结尾,提取到一个文件
这个真没有