如何将用SQL编写的存储过程转换为Java。得到了ANTLR的参考资料

时间:2021-12-12 21:19:43

I am completely new to Programming language translation and don't know how to start. I want to convert stored procedures written in PL/SQL to Java, to make our application database independent.

我是编程语言翻译的新手,不知道如何开始。我想将用PL / SQL编写的存储过程转换为Java,以使我们的应用程序数据库独立。

There are about 50 stored procedures, each having about 10000-15000 lines of code. I am looking for a way to automate this.

大约有50个存储过程,每个过程具有大约10000-15000行代码。我正在寻找一种自动化的方法。

I have got a reference of ANTLR parser, and have found some parsers on GitHub, but have no clue, how to go about it.

我有一个ANTLR解析器的参考,并在GitHub上找到了一些解析器,但没有任何线索,如何去做。

1 个解决方案

#1


4  

First of all you must know some theory, and also you have to learn something about ANTLR. The ANTLR parser will give you "only" AST (Abstract syntax tree), which is just a small 1st step. The rest is up to you. There is an article called "Life after parsing" describing the problems with automatic translation. If you do not have an experience with this, you probably should not start this way.

首先,你必须了解一些理论,而且你必须学习一些关于ANTLR的知识。 ANTLR解析器将为您提供“仅”AST(抽象语法树),这只是第一步。剩下的由你决定。有一篇名为“解析后的生活”的文章描述了自动翻译的问题。如果你没有这方面的经验,你可能不应该这样开始。

You can use ANTRL for:

您可以使用ANTRL:

  • generation of PL/SQL code call-tree. To get some overview of code's business logic.
  • 生成PL / SQL代码调用树。获得代码业务逻辑的概述。
  • extract SQL statements from PL/SQL code
  • 从PL / SQL代码中提取SQL语句
  • extract table names from SQLs
  • 从SQL中提取表名

This can give you some overview which "module" accesses particular tables. You can also serialize the AST tree into some "fake" java code, where original PL/SQL will be stored as comments. But the rest it up to you. PL/SQL programming style is different from Java one.

这可以为您提供“模块”访问特定表的概述。您还可以将AST树序列化为一些“假”java代码,其中原始PL / SQL将存储为注释。但其余的由你决定。 PL / SQL编程风格与Java风格不同。

PS: You will also find that some of Oracle's proprietary SQLs can not be easily translated into ISO SQL92, and some databases do not even support ISO SQL92 (or higher). So as I wrote before most of the work must be done manually. So maybe rewriting it from scratch is not so bad idea.

PS:您还会发现Oracle的一些专有SQL无法轻松转换为ISO SQL92,而某些数据库甚至不支持ISO SQL92(或更高版本)。因此,在我写之前,大多数工作必须手动完成。所以也许从头开始重写它并不是一个坏主意。

#1


4  

First of all you must know some theory, and also you have to learn something about ANTLR. The ANTLR parser will give you "only" AST (Abstract syntax tree), which is just a small 1st step. The rest is up to you. There is an article called "Life after parsing" describing the problems with automatic translation. If you do not have an experience with this, you probably should not start this way.

首先,你必须了解一些理论,而且你必须学习一些关于ANTLR的知识。 ANTLR解析器将为您提供“仅”AST(抽象语法树),这只是第一步。剩下的由你决定。有一篇名为“解析后的生活”的文章描述了自动翻译的问题。如果你没有这方面的经验,你可能不应该这样开始。

You can use ANTRL for:

您可以使用ANTRL:

  • generation of PL/SQL code call-tree. To get some overview of code's business logic.
  • 生成PL / SQL代码调用树。获得代码业务逻辑的概述。
  • extract SQL statements from PL/SQL code
  • 从PL / SQL代码中提取SQL语句
  • extract table names from SQLs
  • 从SQL中提取表名

This can give you some overview which "module" accesses particular tables. You can also serialize the AST tree into some "fake" java code, where original PL/SQL will be stored as comments. But the rest it up to you. PL/SQL programming style is different from Java one.

这可以为您提供“模块”访问特定表的概述。您还可以将AST树序列化为一些“假”java代码,其中原始PL / SQL将存储为注释。但其余的由你决定。 PL / SQL编程风格与Java风格不同。

PS: You will also find that some of Oracle's proprietary SQLs can not be easily translated into ISO SQL92, and some databases do not even support ISO SQL92 (or higher). So as I wrote before most of the work must be done manually. So maybe rewriting it from scratch is not so bad idea.

PS:您还会发现Oracle的一些专有SQL无法轻松转换为ISO SQL92,而某些数据库甚至不支持ISO SQL92(或更高版本)。因此,在我写之前,大多数工作必须手动完成。所以也许从头开始重写它并不是一个坏主意。