Heterogeneous database stored procedure access method, device, equipment and storage medium
By using a heterogeneous database stored procedure access method, Oracle stored procedures are parsed and converted into Java class programs, solving the compatibility issues of domestic databases and achieving seamless access and transparent execution across databases.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- 北京景尧科技有限公司
- Filing Date
- 2023-01-10
- Publication Date
- 2026-05-12
AI Technical Summary
After replacing Oracle databases, domestic databases are incompatible with Oracle stored procedures, resulting in high costs and risks for application system modification and potential business interruption.
By using a heterogeneous database stored procedure access method, it determines whether the received Oracle SQL statement is a stored procedure. If so, it parses and converts it into a Java class program, loads it into an existing container for execution, and achieves seamless access across databases.
It solves the problem of domestic databases not supporting stored procedures, reduces modification costs and risks, and achieves transparent execution of the database without the database's awareness.
Smart Images

Figure CN116303530B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, device, and storage medium for accessing stored procedures in heterogeneous databases. Background Technology
[0002] Currently, core business systems in industries such as finance, telecommunications, energy, government and enterprise, and the military are all based on Oracle, resulting in a strong and tightly coupled dependency on Oracle. However, the localization of databases requires directly replacing existing Oracle databases with domestically developed ones, which faces a technical challenge: domestic databases often fail to meet compatibility standards with Oracle stored procedures.
[0003] Traditional solutions for Oracle stored procedure compatibility mainly include application-side modification and database-side compatibility. Application-side modification involves altering all applications running the Oracle stored procedures, breaking them down into single SQL statements. However, this approach requires modifying hundreds or even thousands of applications, inevitably involving testing and trial runs, which is prohibitively expensive for customers in terms of both time and money. Furthermore, the rewritten applications may contain undiscovered bugs and pose a risk of business interruption for 24 / 7 operations. Database-side compatibility refers to domestic databases directly supporting Oracle stored procedures; however, currently, domestic databases cannot achieve full compatibility with Oracle stored procedures in the short term.
[0004] Therefore, there is an urgent need for a heterogeneous database stored procedure access method to solve the technical problem that some domestic databases do not support stored procedures after an application system replaces an existing Oracle database with a domestic database. Summary of the Invention
[0005] The main objective of this invention is to provide a method, apparatus, device, and storage medium for accessing stored procedures in heterogeneous databases, aiming to solve the technical problem that some domestic databases do not support stored procedures after an application system replaces an existing Oracle database with a domestic database.
[0006] To achieve the above objectives, the present invention provides a method for accessing stored procedures in heterogeneous databases, the method comprising the following steps:
[0007] If the received Oracle SQL statement is a stored procedure, determine whether the stored procedure needs to be created or replaced.
[0008] If it is necessary to create or replace the stored procedure, each step of the stored procedure is parsed sequentially to obtain the parsing result;
[0009] Convert the parsing results into a Java class program;
[0010] Load the Java class program into an existing container and return the execution result.
[0011] Optionally, the step of converting the parsing result into a Java class program specifically includes:
[0012] The parsed results are converted into Java class programs using an SQL converter;
[0013] The Java class program is synchronously sent to a container containing an SQL converter, and the parsing results are converted into corresponding Java class programs using the same steps.
[0014] Optionally, after the step of determining whether to create or replace the stored procedure if the received Oracle SQL statement is a stored procedure, the method further includes:
[0015] If the stored procedure does not need to be created or replaced, then determine whether the stored procedure exists.
[0016] If it exists, an error message will be displayed indicating that an error has already occurred.
[0017] Optionally, after the step of determining whether the stored procedure exists if it is not necessary to create or replace the stored procedure, the method further includes:
[0018] If it does not exist, then each step of the stored procedure is parsed sequentially to obtain the parsing result;
[0019] The parsing results are converted into Java class programs, and similar steps in the parsing results are converted into corresponding Java class programs;
[0020] The Java class program is synchronously sent to a container containing an SQL converter, and the Java class program is loaded into the existing container, and the execution result is returned.
[0021] Optionally, before the step of determining whether to create or replace the stored procedure if the received Oracle SQL statement is a stored procedure, the method further includes:
[0022] Receive Oracle SQL statements and intercept and parse them in real time;
[0023] Determine whether the Oracle SQL statement is a stored procedure.
[0024] Optionally, after the step of determining whether the Oracle SQL statement belongs to a stored procedure, the method further includes:
[0025] If the Oracle SQL statement is a stored procedure, determine whether the stored procedure needs to be deleted.
[0026] If the stored procedure needs to be deleted, determine whether the stored procedure exists.
[0027] If it exists, delete the corresponding stored procedure and send the deletion command synchronously to the container containing the SQL converter.
[0028] Optionally, after the step of determining whether the Oracle SQL statement belongs to a stored procedure, the method further includes:
[0029] If the Oracle SQL statement is not a stored procedure, it will be executed according to the database's regular logic.
[0030] Furthermore, to achieve the above objectives, the present invention also proposes a heterogeneous database stored procedure access device, the device comprising:
[0031] The determination module is used to determine whether to create or replace the stored procedure if the received Oracle SQL statement is a stored procedure.
[0032] The parsing module is used to parse each step of the stored procedure sequentially to obtain the parsing result if it is necessary to create or replace the stored procedure.
[0033] A conversion module is used to convert the parsed results into Java class programs;
[0034] The output module is used to load the Java class program into an existing container and return the execution result.
[0035] Furthermore, to achieve the above objectives, the present invention also proposes a heterogeneous database stored procedure access device, the device comprising: a memory, a processor, and a heterogeneous database stored procedure access program stored in the memory and executable on the processor, the heterogeneous database stored procedure access program being configured to implement the steps of the heterogeneous database stored procedure access method described above.
[0036] Furthermore, to achieve the above objectives, the present invention also proposes a storage medium storing a heterogeneous database stored procedure access program, wherein when the heterogeneous database stored procedure access program is executed by a processor, it implements the steps of the heterogeneous database stored procedure access method described above.
[0037] This invention addresses the technical problem of some domestic databases not supporting stored procedures when an application system replaces an existing Oracle database with a stored procedure. By determining whether the received Oracle SQL statement belongs to a stored procedure, and if so, parsing each step of the stored procedure to obtain the parsing result, converting the parsing result into a Java class program, loading the Java class program into an existing container, and returning the execution result, this invention solves the technical problem of some domestic databases not supporting stored procedures after an application system replaces an existing Oracle database with a domestic database. Attached Figure Description
[0038] Figure 1 This is a schematic diagram of the structure of a heterogeneous database stored procedure access device in the hardware operating environment involved in the embodiments of the present invention;
[0039] Figure 2 This is a flowchart illustrating the first embodiment of the heterogeneous database stored procedure access method of the present invention;
[0040] Figure 3 This is a flowchart illustrating the second embodiment of the heterogeneous database stored procedure access method of the present invention;
[0041] Figure 4 This is a schematic diagram illustrating the creation or replacement of a stored procedure in the heterogeneous database stored procedure access method of the present invention.
[0042] Figure 5 This is a flowchart illustrating the third embodiment of the heterogeneous database stored procedure access method of the present invention;
[0043] Figure 6 This is a schematic diagram of the deletion process of a stored procedure in the heterogeneous database stored procedure access method of the present invention;
[0044] Figure 7 This is a schematic diagram of the data bus architecture between the application and the database in the heterogeneous database stored procedure access method of the present invention.
[0045] Figure 8 This is a structural block diagram of the first embodiment of the heterogeneous database stored procedure access device of the present invention.
[0046] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0047] It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.
[0048] Reference Figure 1 , Figure 1 This is a schematic diagram of the heterogeneous database stored procedure access device structure in the hardware operating environment involved in the embodiments of the present invention.
[0049] like Figure 1 As shown, the heterogeneous database stored procedure access device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to enable communication between these components. The user interface 1003 may include a display screen or an input unit such as a keyboard; optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wireless-Fidelity (Wi-Fi) interface). The memory 1005 may be high-speed random access memory (RAM) or stable non-volatile memory (NVM), such as a disk drive. The memory 1005 may also optionally be a storage device independent of the aforementioned processor 1001.
[0050] Those skilled in the art will understand that Figure 1 The structure shown does not constitute a limitation on heterogeneous database stored procedure access devices, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0051] like Figure 1 As shown, the memory 1005, which serves as a storage medium, may include an operating system, a network communication module, a user interface module, and a heterogeneous database stored procedure access program.
[0052] exist Figure 1In the heterogeneous database stored procedure access device shown, the network interface 1004 is mainly used for data communication with the network server; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in the heterogeneous database stored procedure access device of the present invention can be set in the heterogeneous database stored procedure access device, and the heterogeneous database stored procedure access device calls the heterogeneous database stored procedure access program stored in the memory 1005 through the processor 1001 and executes the heterogeneous database stored procedure access method provided in the embodiment of the present invention.
[0053] This invention provides a method for accessing stored procedures in heterogeneous databases, referring to... Figure 2 , Figure 2 This is a flowchart illustrating the first embodiment of the heterogeneous database stored procedure access method of the present invention.
[0054] In this embodiment, the heterogeneous database stored procedure access method includes the following steps:
[0055] Step S10: If the received Oracle SQL statement is a stored procedure, determine whether the stored procedure needs to be created or replaced;
[0056] It should be noted that the executing entity in this embodiment can be a computing service device with network communication, data processing, and program execution functions, such as a tablet computer or personal computer, or an electronic device capable of performing the same or similar functions, such as the one described above. Figure 1 The heterogeneous database stored procedure access device shown is an example. The following uses a heterogeneous database stored procedure access device as an example to illustrate this embodiment and the embodiments described below.
[0057] Furthermore, by constructing a data bus with unified data access standards, an SQL converter is developed at the data bus layer to uniformly solve the problem of domestic databases not being compatible with Oracle stored procedures.
[0058] It should be noted that the aforementioned data bus is built on a cloud-native foundation and possesses the characteristics of cloud-native distributed and horizontally scalable architecture. Cloud-native is a cloud technology product system built upon distributed cloud deployment and unified operation and management, based on technologies such as containers, microservices, and DevOps.
[0059] For example, refer to Figure 7 , Figure 7This diagram illustrates the data bus architecture between the application and the database in the heterogeneous database stored procedure access method of the present invention. The heterogeneous database stored procedure access device receives data read / write requests and sends them to the application. The bus client (which implements the standardization of the development language driver interface; JAVA implements the JDBC standard interface, and C implements the ODBC standard interface; the bus client is mainly used to obtain the connection address and port of the bus server, the bus SQL statement execution interface, the bus SQL statement result interface, and the bus metadata interface) accesses the application through the JDBC or ODBC standard interface. The bus client requests a short bus service address from the IP address allocation center. The IP address allocation center is mainly used to inform the bus client which bus server is currently available and returns the address of the available bus server to the bus client. Then, the bus client connects to the bus server according to the bus server address (the bus server connector stores multiple long connections with the bus client, connecting different bus servers). Client requests are distributed to different contexts to ensure isolation between requests. The bus server connector in the data bus connects to the global cache, which caches execution results on a transaction-by-transaction basis. Within the same transaction, if the same SQL query appears, it is returned directly from the cached result instead of querying the database, saving database resources and improving overall database performance. If the data is already cached, the result is retrieved directly from the global cache and returned. If the requested data is not in the cache, it is converted by an SQL converter before execution. (The SQL converter can be pre-configured to convert Oracle's special SQL syntax into SQL syntax that can be recognized by the domestic database. Before the application sends the SQL statement to the domestic database, it is first converted into a pre-configured SQL statement that the domestic database can recognize.) Then, the SQL converter accesses the Oracle database through a standard JDBC interface. The log extractor performs real-time log extraction on the Oracle database and then writes the converted stored procedures to the domestic database in real-time. After the database switchover is completed, the domestic database becomes the production database (primary database), and the original Oracle database becomes the backup database. The SQL converter on the data bus is responsible for parsing and translating the Oracle stored procedures.
[0060] It should be explained that the above stored procedure flow can be divided into two categories: one is the stored procedure creation or replacement flow, and the other is the stored procedure deletion flow. These two flows cover the use cases of creating, replacing, and deleting Oracle stored procedures.
[0061] Understandably, Oracle database is currently the most widely used database management system in the world. As a general-purpose database system, it has complete data management functions; as a relational database, it is a complete relational product; and as a distributed database, it implements distributed processing capabilities. SQL stands for Structured Query Language, specifically designed for data access, data updates, and database management operations.
[0062] It should be noted that if the stored procedure does not need to be created or replaced, the system checks whether the stored procedure exists. If it exists, an error message is displayed indicating that the stored procedure already exists. If it does not exist, each step of the stored procedure is parsed sequentially to obtain the parsing result. Then, the parsing result is converted into a Java class program, and similar steps in the parsing result are converted into corresponding Java class programs. Finally, the Java class program is synchronously sent to a container containing an SQL converter, and the Java class program is loaded into the existing container, and the execution result is returned.
[0063] Step S20: If it is necessary to create or replace the stored procedure, then parse each step of the stored procedure in sequence to obtain the parsing result;
[0064] It should be noted that the process of creating or replacing a stored procedure refers to the process of sequentially parsing and translating each step of the stored procedure through an SQL converter when it is necessary to create or replace the original Oracle stored procedure. This process then converts the stored procedure into a Java class program that can be recognized by all domestic databases, and finally sends the Java class program to the domestic database for playback and execution.
[0065] Step S30: Convert the parsing result into a Java class program;
[0066] It's important to note that the conversion involves translating the parsed Oracle stored procedure line by line. First, the stored procedure undergoes lexical and syntactic analysis, followed by syntax conversion. Ultimately, the stored procedure is translated into a Java class program. This Java class program, after lexical and syntactic conversion, is then hot-loaded into the process through real-time compilation (when the data bus executes SQL and parses the stored procedure, it first queries the pre-compiled stored procedure; if it doesn't exist, it calls the stored procedure-to-Java compiler to compile it in real-time and saves it; after compilation, the bus executes the Java version of the stored procedure). When subsequent calls arrive, the corresponding Java class program can be retrieved by the stored procedure name, executed, and the result returned to the application. Furthermore, the generated Java class program needs to be synchronized so that connections on other cloud-native container nodes can also call the stored procedure.
[0067] Step S40: Load the Java class program into the existing container and return the execution result.
[0068] In the specific implementation, after each parsed step is converted into a Java class program that can be recognized by all domestic databases, the same steps of the above stored procedure are also converted into corresponding Java class programs. Then, the Java class programs are synchronously sent to each container containing an SQL converter on the cloud-native distributed data bus (such as databus2.container, databus.container3, ..., databus.containerN), and the Java class programs are loaded into the existing container (such as databus.container1). Finally, the execution result is returned to the application.
[0069] For example, refer to Figure 4 , Figure 4 This is a flowchart illustrating the creation or replacement of stored procedures in the heterogeneous database stored procedure access method of the present invention. When the data bus of the heterogeneous database stored procedure access device receives a data read / write request, it intercepts and parses the SQL, then determines whether the received Oracle SQL statement belongs to a stored procedure. If it does, it determines whether to create or replace the stored procedure. If it is necessary to create or replace the stored procedure, it parses each step of the stored procedure sequentially. Then, it converts each parsed step into a Java class program that can be recognized by all domestic databases, and converts similar steps of the stored procedure into corresponding Java class programs. Then, it synchronously sends the Java class programs to each container containing an SQL converter on the cloud-native distributed data bus (e.g., data bus 2.container, data bus.container 3, ..., data bus.container N), and loads the generated Java class into an existing container (e.g., data bus.container 1), and returns the execution result. (Note: Subsequent requests for this Oracle stored procedure can be made by calling the Java class program within the SQL converter on the data bus.) If the stored procedure does not need to be created or replaced, it is determined whether the stored procedure already exists. If it does exist, an error message is displayed. If it does not exist, each step of the stored procedure is parsed sequentially to obtain the parsing result. The parsing result is then converted into a Java class program, and similar steps in the parsing result are converted into corresponding Java class programs. The Java class programs are then synchronously sent to the container containing the SQL converter, loaded into the existing container, and the execution result is returned. If it is not a stored procedure, the Oracle SQL statement is executed according to the regular database logic.
[0070] This embodiment determines whether to create or replace a stored procedure if the received Oracle SQL statement is a stored procedure. If so, it parses each step of the stored procedure sequentially to obtain the parsing result, converts the parsing result into a Java class program, loads the Java class program into an existing container, and returns the execution result. Because this invention solves the technical problem of some domestic databases not supporting stored procedures after an application system replaces an existing Oracle database with a domestic database, it is completely different from existing traditional solutions, which involve high costs and risks. This solution, by establishing an additional bus architecture, concentrates the difficulties of converting Oracle stored procedures within this solution, thereby achieving compatibility with Oracle stored procedures.
[0071] refer to Figure 3 , Figure 3 This is a flowchart illustrating the second embodiment of the heterogeneous database stored procedure access method of the present invention.
[0072] Based on the first embodiment described above, in this embodiment, before step S10, the method further includes:
[0073] Step S01: Receive Oracle SQL statements and intercept and parse them in real time;
[0074] Step S02: Determine whether the Oracle SQL statement is a stored procedure.
[0075] In practical implementation, when the heterogeneous database stored procedure access device receives a data read / write request, the data bus intercepts and parses the received Oracle SQL statement in real time, and determines whether the received Oracle SQL statement belongs to a stored procedure.
[0076] Understandably, the above stored procedure flow can be divided into two categories: the creation or replacement flow of a stored procedure, and the deletion flow of a stored procedure. These two flows cover the use cases for creating, replacing, and deleting Oracle stored procedures.
[0077] This embodiment receives Oracle SQL statements and intercepts and parses them in real time; it determines whether the Oracle SQL statement belongs to a stored procedure; if the received Oracle SQL statement belongs to a stored procedure, it determines whether the stored procedure needs to be created or replaced; if the stored procedure needs to be created or replaced, it parses each step of the stored procedure sequentially to obtain the parsing result; the parsing result is converted into a Java class program; the Java class program is loaded into an existing container, and the execution result is returned. Because this invention solves the technical problem of some domestic databases not supporting stored procedures after an application system replaces an existing Oracle database with a domestic database, this invention uses an SQL converter to convert Oracle SQL statements into Java class programs that can be recognized by domestic databases, seamlessly connecting multiple databases through a common Java class, thereby achieving database-insensitive and transparent execution.
[0078] refer to Figure 4 , Figure 4 This is a flowchart illustrating the third embodiment of the heterogeneous database stored procedure access method of the present invention.
[0079] Based on the above embodiments, in this embodiment, after step S02, the method further includes:
[0080] Step S10': If the Oracle SQL statement is a stored procedure, determine whether the stored procedure needs to be deleted;
[0081] Step S20': If it is necessary to delete the stored procedure, determine whether the stored procedure exists;
[0082] Step S30': If it exists, delete the corresponding stored procedure and send the deletion command synchronously to the container containing the SQL converter.
[0083] It should be noted that the SQL converter can convert Oracle's special SQL syntax into SQL syntax that can be recognized by domestic databases through pre-configuration. Before the application sends SQL statements to the domestic database, it is first converted into pre-configured SQL statements that can be recognized by the domestic database.
[0084] In specific implementations, for example, refer to Figure 6 , Figure 6This is a schematic diagram of the stored procedure deletion process in the heterogeneous database stored procedure access method of the present invention. When the data bus of the heterogeneous database stored procedure access device receives a data read / write request, it intercepts and parses the Oracle SQL. The data bus determines whether the Oracle SQL belongs to a stored procedure. If it belongs to a stored procedure, it further determines whether to delete the stored procedure. If the stored procedure needs to be deleted, it determines whether the stored procedure already exists. If the stored procedure already exists, it deletes the corresponding stored procedure and synchronously sends the deletion instruction to each container containing an SQL converter on the cloud-native distributed data bus (e.g., data bus 2.container, data bus.container 3, ..., data bus.container N). If the stored procedure does not exist, an error message is displayed. If the stored procedure does not need to be deleted, other logic is executed according to the Database Definition Language (DDL) type. If it does not belong to a stored procedure, the SQL statement is executed according to the normal logic.
[0085] This embodiment receives Oracle SQL statements and intercepts and parses them in real time; it determines whether the Oracle SQL statement belongs to a stored procedure; if the received Oracle SQL statement belongs to a stored procedure, it determines whether the stored procedure needs to be deleted; if the stored procedure needs to be deleted, it determines whether the stored procedure already exists; if it exists, it deletes the corresponding stored procedure and synchronously sends the deletion command to a container containing an SQL converter, and returns the execution result. Because this invention solves the technical problem that some domestic databases do not support stored procedures after an application system replaces an existing Oracle database with a domestic database, compared to existing technologies, this invention converts Oracle SQL statements into Java classes that can be recognized by domestic databases through an SQL converter, seamlessly connecting multiple databases through a common Java class, thereby achieving database-insensitive and transparent execution.
[0086] Furthermore, this embodiment of the invention also proposes a storage medium storing a heterogeneous database stored procedure access program, which, when executed by a processor, implements the steps of the heterogeneous database stored procedure access method described above.
[0087] Reference Figure 8 , Figure 8 This is a structural block diagram of the first embodiment of the heterogeneous database stored procedure access device of the present invention.
[0088] like Figure 8 As shown, the heterogeneous database stored procedure access device proposed in this embodiment of the invention includes: a judgment module 801, a parsing module 802, a conversion module 803, and an output module 804.
[0089] The judgment module 801 is used to determine whether to create or replace the stored procedure if the received Oracle SQL statement is a stored procedure.
[0090] The parsing module 802 is used to parse each step of the stored procedure sequentially to obtain the parsing result if it is necessary to create or replace the stored procedure.
[0091] The conversion module 803 is used to convert the parsing result into a Java class program;
[0092] The output module 804 is used to load the Java class program into an existing container and return the execution result.
[0093] This embodiment determines whether to create or replace a stored procedure if the received Oracle SQL statement is a stored procedure. If so, it parses each step of the stored procedure sequentially to obtain the parsing result, converts the parsing result into a Java class program, loads the Java class program into an existing container, and returns the execution result. Because this invention solves the technical problem of some domestic databases not supporting stored procedures after an application system replaces an existing Oracle database with a domestic database, this invention uses an SQL converter to convert Oracle SQL statements into Java class programs that can be recognized by domestic databases, seamlessly connecting multiple databases through a common Java class, thus achieving database-insensitive and transparent execution.
[0094] Based on the first embodiment of the heterogeneous database stored procedure access device of the present invention, a second embodiment of the heterogeneous database stored procedure access device of the present invention is proposed.
[0095] In this embodiment, the judgment module 801 is further configured to receive Oracle SQL statements and intercept and parse them in real time; and determine whether the Oracle SQL statement belongs to a stored procedure.
[0096] The judgment module 801 is further configured to execute the Oracle SQL statement according to the conventional database logic if the Oracle SQL statement does not belong to a stored procedure.
[0097] Other embodiments or specific implementations of the heterogeneous database stored procedure access device of the present invention can be referred to the above-described method embodiments, and will not be repeated here.
[0098] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0099] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0100] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as read-only memory / random access memory, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0101] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.
Claims
1. A method for accessing stored procedures in a heterogeneous database, characterized in that, The method includes: Receive Oracle SQL statements via the data bus and intercept and parse them in real time; Determine whether the Oracle SQL statement is a stored procedure; If the received Oracle SQL statement is a stored procedure, determine whether the stored procedure needs to be created or replaced. If it is necessary to create or replace the stored procedure, each step of the stored procedure is parsed sequentially to obtain the parsing result; Convert the parsing results into a Java class program; Load the Java class program into an existing container and return the execution result; After the step of determining whether the Oracle SQL statement belongs to a stored procedure, the method further includes: If the Oracle SQL statement is a stored procedure, determine whether the stored procedure needs to be deleted. If the stored procedure needs to be deleted, determine whether the stored procedure exists. If it exists, delete the corresponding stored procedure and send the deletion command synchronously to the container containing the SQL converter; The step of converting the parsed result into a Java class program specifically includes: The parsed results are converted into Java class programs using an SQL converter; The Java class program is synchronously sent to a container containing an SQL converter, and the parsing results are converted into corresponding Java class programs using the same steps.
2. The method as described in claim 1, characterized in that, Following the step of determining whether to create or replace the stored procedure if the received Oracle SQL statement is a stored procedure, the method further includes: If the stored procedure does not need to be created or replaced, then determine whether the stored procedure exists. If it exists, an error message will be displayed indicating that an error has already occurred.
3. The method as described in claim 2, characterized in that, Following the step of determining whether the stored procedure exists if it is not necessary to create or replace the stored procedure, the method further includes: If it does not exist, then each step of the stored procedure is parsed sequentially to obtain the parsing result; The parsing results are converted into Java class programs, and similar steps in the parsing results are converted into corresponding Java class programs; The Java class program is synchronously sent to a container containing an SQL converter, and the Java class program is loaded into the existing container, and the execution result is returned.
4. The method as described in claim 1, characterized in that, After the step of determining whether the Oracle SQL statement belongs to a stored procedure, the method further includes: If the Oracle SQL statement is not a stored procedure, it will be executed according to the database's regular logic.
5. A heterogeneous database stored procedure access device, characterized in that, The device includes: The determination module is used to determine whether to create or replace the stored procedure if the received Oracle SQL statement is a stored procedure. The parsing module is used to parse each step of the stored procedure sequentially to obtain the parsing result if it is necessary to create or replace the stored procedure. A conversion module is used to convert the parsed results into Java class programs; The output module is used to load the Java class program into an existing container and return the execution result; The judgment module is also used to receive Oracle SQL statements through the data bus and intercept and parse them in real time; and to determine whether the Oracle SQL statement belongs to a stored procedure. The judgment module is further configured to determine whether the stored procedure needs to be deleted if the Oracle SQL statement is a stored procedure; if the stored procedure needs to be deleted, determine whether the stored procedure exists; if it exists, delete the corresponding stored procedure and synchronously send the deletion instruction to the container containing the SQL converter. The conversion module is further configured to convert the parsing result into a Java class program using an SQL converter; synchronously send the Java class program to a container containing the SQL converter; and convert similar steps of the parsing result into corresponding Java class programs.
6. A heterogeneous database stored procedure access device, characterized in that, The device includes: a memory, a processor, and a heterogeneous database stored procedure access program stored on the memory and executable on the processor, the heterogeneous database stored procedure access program being configured to implement the steps of the heterogeneous database stored procedure access method as described in any one of claims 1 to 4.
7. A storage medium, characterized in that, The storage medium stores a heterogeneous database stored procedure access program, which, when executed by a processor, implements the steps of the heterogeneous database stored procedure access method as described in any one of claims 1 to 4.