A method for remote function invocation based on database link and related products
Patent Information
- Application Number
- CN202611096572.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-22
- Publication Date
- 2026-10-30
AI Technical Summary
[0004]然而,通过DBLINK调用远程函数时存诸多难点,包括函数的远程执行、参数传递、结果返回、类型转换等
[0019]本发明的基于数据库链接的远程函数调用方法,通过基于用户输入的远程函数调用语句构建多重选择的查询语句,经数据库链接一次远程交互通信获取匹配的目标远程函数信息,并在本地构建映射函数后触发远程函数执行,实现了在减少远程交互通信次数的情况下完成远程函数的调用,无需多次交互查询远程数据库,保证了函数调用链路的简洁性与数据获取的完整性,从而减少了远程交互通信开销,进而提高了跨库访问的效率和准确性。
Smart Images

Figure CN123011949A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of database technology, and in particular to a remote function call method based on database links and related products. Background Technology
[0002] A database link (DBLINK) is a connection established between two databases in a relational database system. It allows access to objects in one database from another, facilitating data exchange and sharing across databases. A remote table refers to a table defined and stored in homogeneous or heterogeneous databases. DBLINK enables cross-database queries to retrieve data from remote tables.
[0003] In real-world business scenarios, users not only need to access remote tables across databases, but also frequently need to call functions defined in remote databases. A database function is a predefined, reusable piece of program code used to receive input parameters, perform specific operations, and return results. Functions encapsulate specific business logic or calculation rules and can be directly called within Structured Query Language (SQL) statements.
[0004] However, calling remote functions via DBLINK presents numerous challenges, including remote function execution, parameter passing, result return, and type conversion. For instance, to accurately retrieve all basic information about a remote function from the local database, multiple remote communication interactions are required, resulting in low efficiency in remote function calls. Furthermore, if the remote function does not exist in the local database, the parsing and execution process of the remote function cannot be easily completed locally, thus affecting the accuracy of remote function calls. Summary of the Invention
[0005] In view of the above problems, a database-link-based remote function call method and related products are proposed to overcome or at least partially solve the above problems.
[0006] One objective of this invention is to provide a remote function call method based on database links, which can complete the call of remote functions while reducing the number of remote interactive communications, thereby improving the efficiency and accuracy of cross-database access.
[0007] A further objective of this invention is to further improve the accuracy of remote function calls.
[0008] Another further objective of this invention is to be compatible with different input formats, thereby improving the versatility and compatibility of remote function calls.
[0009] Specifically, according to one aspect of the present invention, the present invention provides a remote function call method based on a database link, comprising: Based on the remote function call statement input by the user, construct a multi-select query statement in the local database; The query statement with multiple selections is sent to a remote database for execution via a database connection, and the function information of the target remote function that matches the remote function call statement is obtained from the remote database; Based on function information, construct local functions in the local database and map the local functions to the target remote functions; Call and execute the target remote function in the remote database using a local function.
[0010] Optionally, the steps of obtaining function information of the target remote function that matches the remote function call statement in the remote database include: Determine if a remote function exists in the remote database that matches the remote function call statement; If so, then determine whether multiple matching remote functions exist in the remote database; If multiple remote functions exist, overload matching is performed on all matching remote functions to obtain the target remote function and retrieve its function information. If there are no multiple remote functions, the matched remote function will be used as the target remote function, and the function information of the target remote function will be obtained.
[0011] Optionally, the step of performing overload matching on all matching remote functions includes: Retrieve function information from all matching remote functions, including the number and types of parameters; Retrieve the call parameter information of a remote function call statement, including the number of parameters and their types; The function information of each matched remote function is compared with the call parameter information; The target remote function is selected based on the degree of matching between the number of parameters and the parameter types.
[0012] Optionally, the steps to determine whether a remote function matching the remote function call statement exists in the remote database include: Retrieve the function to be called in a remote function call statement; Determine if the name of the remote function in the remote database is the same as the name of the function to be called; If they are the same, then it is determined that a matching remote function exists in the remote database; If they are not the same, it is determined that there is no matching remote function in the remote database.
[0013] Optionally, before the step of constructing a multi-select query statement in the local database based on the remote function call statement input by the user, the remote function call method further includes: Receives remote function call statements from the user, whereby the remote function call statements are used to access remote functions in a remote database via a database connection; The remote function call statement is analyzed to obtain the function name information and call parameter information. The input format of the function name information includes one-part input, two-part input and three-part input. One-part input includes only the function name, two-part input includes either the namespace name or the package name and the function name, and three-part input includes the namespace name, the package name and the function name.
[0014] Optionally, the steps of constructing a multi-select query statement in the local database based on the remote function call statement entered by the user include: Identify the input format of function name information in remote function call statements; Based on the function name information in the remote function call statement and the identified input format, a query statement containing multiple query branches is constructed. Each query branch corresponds to a different input format, and each query branch is used to query the remote database for remote functions that match the function name information of the corresponding input format.
[0015] Optionally, after the step of calling and executing the target remote function in the remote database via a local function, the remote function invocation method further includes: The local database receives the execution result of the target remote function returned by the remote database; Obtain data type matching rules pre-built based on external data wrappers; Based on data type matching rules, the execution result is converted into a data type compatible with the local database; The converted execution result is output as the return value of the local function.
[0016] According to another aspect of the present invention, a computer-readable storage medium is also provided, on which a computer program is stored, wherein the computer program, when executed by a processor, implements the steps of any of the above-described database-link-based remote function call methods.
[0017] According to another aspect of the present invention, a computer program product is also provided, comprising a computer program that, when executed by a processor, implements the steps of any of the above-described database-link-based remote function call methods.
[0018] According to another aspect of the present invention, a computer device is also provided, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of any of the above-described database-linked remote function call methods.
[0019] The remote function call method based on database linking of the present invention constructs a multi-select query statement based on the remote function call statement input by the user, obtains the matching target remote function information through a single remote interactive communication via database linking, and triggers the execution of the remote function after constructing the mapping function locally. This achieves the completion of remote function calling with reduced remote interactive communication, without the need for multiple interactive queries to the remote database, ensuring the simplicity of the function call chain and the integrity of data acquisition, thereby reducing remote interactive communication overhead and improving the efficiency and accuracy of cross-database access.
[0020] Furthermore, the remote function call method based on database links of the present invention determines the number of matching remote functions when obtaining remote function information. When only a single matching remote function exists, the target remote function is directly selected, and when multiple matching remote functions exist, overload matching is performed. This achieves adaptive target remote function selection under different matching scenarios, while ensuring that the target remote function intended by the user can be accurately selected in the function overload scenario, avoiding calling errors caused by matching multiple functions with the same name, thereby improving the accuracy of remote function calls.
[0021] Furthermore, the remote function call method based on database links of the present invention identifies the input form of the function name, constructs multiple query branches covering all input forms, and integrates them to obtain a query statement. This achieves the matching requirements of different input forms and ensures that function information matching different user input forms can be obtained with only one remote database interaction, thereby improving the universality and compatibility of remote function calls.
[0022] The above and other objects, advantages and features of the present invention will become more apparent to those skilled in the art from the following detailed description of specific embodiments of the invention in conjunction with the accompanying drawings. Attached Figure Description
[0023] The following sections will describe some specific embodiments of the invention in detail by way of example and not limitation, with reference to the accompanying drawings. The same reference numerals in the drawings denote the same or similar parts or portions. Those skilled in the art should understand that these drawings are not necessarily drawn to scale. In the drawings: Figure 1 This is a flowchart illustrating a remote function call method based on a database connection according to an embodiment of the present invention; Figure 2This is a control flow diagram of a remote function call method based on a database connection according to an embodiment of the present invention; Figure 3 This is a schematic diagram of a computer program product according to an embodiment of the present invention; Figure 4 This is a schematic diagram of a computer-readable storage medium according to an embodiment of the present invention; and Figure 5 This is a schematic diagram of a computer device according to an embodiment of the present invention. Detailed Implementation
[0024] Exemplary embodiments of the invention will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.
[0025] To address the aforementioned problems, this invention proposes a remote function call method based on database links. Figure 1 This is a flowchart illustrating a remote function call method based on a database connection according to an embodiment of the present invention. Figure 1 As shown, the remote function call method based on database connection in this embodiment generally includes: Step S102: Based on the remote function call statement input by the user, a multi-select query statement is constructed in the local database. It should be noted that a remote function call statement refers to the SQL statement input by the user to access a remote function in the remote database via DBLINK. For example, a remote function call statement could be `select func1@dblink(t1.a) from t1`. Furthermore, a multi-select query statement refers to an SQL statement with multiple query semantics, used to query matching remote functions from the system tables of the remote database. In other words, after receiving the remote function call statement input by the user, the local database does not directly attempt to call the remote function, but first constructs a multi-select query statement to facilitate subsequent access to the remote function via DBLINK.
[0026] Step S104 involves sending the multi-select query statement to a remote database for execution via a database link, retrieving function information of the target remote function matching the remote function call statement from the remote database. It should be noted that the function information of the remote function includes, but is not limited to, parameter order, number of parameters, parameter types, parameter attributes, return value type, and overload order. Specifically, after the multi-select query statement is executed on the remote database via DBLINK, it returns one or more remote functions matching the user input from the system tables of the remote database, selects a target remote function, and retrieves the function information of that target remote function.
[0027] Step S106: Construct a local function in the local database based on the function information, and map the local function to the target remote function. It should be noted that a local function refers to a function object created in the local database, and mapping refers to constructing a function mapping relationship between the local function and the remote function based on the function information of the target remote function. In other words, the local function can act as a shell to map the corresponding DBLINK remote function. When the local function is called, the database system can forward the call to the target remote function in the target remote database. Therefore, the function information of the target remote function can be saved and passed through the local function parameters, allowing the remote function to complete the parsing and execution process just like a function in the local database, so that information can be sent to the remote database to execute the function through parameter passing.
[0028] Step S108 involves calling and executing the target remote function in the remote database using a local function. Specifically, based on the function mapping relationship between local and remote functions, when the local function is called, information can be sent to the remote database through parameter passing to trigger the execution of the corresponding target remote function in the remote database. This improves the flexibility, operability, and compatibility of database operations. Furthermore, since the local function is constructed in the local database, it can be directly referenced by subsequent SQL statements, giving the target remote function a corresponding proxy function in the local database. Therefore, if the user calls the target remote function again later, they only need to call its corresponding local function, without needing to concern themselves with the connection details of the remote database.
[0029] Furthermore, in this embodiment, the remote database and the local database can be either homogeneous or heterogeneous. When the local database and the remote database are heterogeneous, data type matching rules can be constructed based on an external data wrapper (FDW). These rules are then used to match the data types of the remote and local databases, ensuring correct conversion, output, and transmission to guarantee compatibility between the heterogeneous databases.
[0030] Therefore, the remote function call method based on database link in this embodiment of the invention constructs a multi-select query statement based on the remote function call statement input by the user, obtains the matching target remote function information through a single remote interactive communication via DBLINK, and triggers the execution of the remote function after constructing the mapping function locally. This achieves the completion of remote function calls with reduced remote interactive communication, without the need for multiple interactive queries to the remote database, ensuring the simplicity of the function call chain and the integrity of data acquisition, thereby reducing the overhead of remote interactive communication and improving the efficiency and accuracy of cross-database access.
[0031] Furthermore, the remote function call method based on database connection in this embodiment of the invention encapsulates the calling logic of the remote function in the local function by mapping the local function to the remote function. The application layer does not need to care about the connection details of the remote database, allowing different databases and different business systems to interact through functions, reducing system coupling, thereby reducing the cost of database system transformation, and also reducing the complexity of local code, thus improving the usability of the database system.
[0032] In some embodiments, prior to step S102, the remote function call method of the present invention may further include the following steps: receiving a remote function call statement input by a user; analyzing the remote function call statement to obtain function name information and call parameter information in the remote function call statement. It should be noted that the function name information refers to the name identifier of the remote function to be called specified by the user in the remote function call statement, including one or more of namespace name, package name, and function name, and supports all input formats.
[0033] Specifically, the input formats for function name information include one-part, two-part, and three-part input. One-part input includes only the function name, such as `func1()`. Two-part input includes either the namespace name or the package name, along with the function name, such as `s1.func1()`, where `s1` could be either the namespace name or the package name. Three-part input includes the namespace name, the package name, and the function name, such as `s1.package1.func1()`.
[0034] For example, the remote function call statement is `select func1@dblink(t1.a) from t1;` where the function name is `func1`, and its input format is a single-part input. Another example is the remote function call statement with the function name `abc.func1()`, where the function name is input in a two-part input format, compatible with both `abc` as a namespace name and `abc` as a package name, and different remote databases have different priority call rules.
[0035] Therefore, the remote function call method based on database link in this embodiment of the invention supports multiple input formats, allowing users to flexibly select different input formats to specify the remote function to be called according to the actual scenario. It is compatible with different naming and organization methods of functions in different database systems, thereby improving the universality and compatibility of remote function calls.
[0036] In addition, the remote function call method based on database connection in this embodiment of the invention extracts function name information and call parameter information by analyzing SQL statements, providing a data foundation for subsequent multiple selection queries and overload matching.
[0037] In some embodiments, step S102 may include the following steps: identifying the input format of function name information in a remote function call statement; and constructing a query statement containing multiple query branches based on the function name information in the remote function call statement and the identified input format.
[0038] In one specific embodiment, multiple query branches correspond to different naming semantic possibilities under the input format. Each query branch is used to query a remote database for remote functions that match the function name information under the corresponding naming semantic possibility. For example, for a two-part input, since the first part may be a namespace name or a package name, the query statement includes both query branches for namespace matching and query branches for package name matching to cover both possibilities.
[0039] In another specific embodiment, multiple query branches correspond to different input formats, and each query branch is used to query a remote database for remote functions whose names match the function name information of the corresponding input format. For example, for a single-segment input, the query branch matches the function name in the system table of the remote database. For a two-segment input, since the first segment may be a namespace name or a package name, the query statement includes both query branches matching by namespace and query branches matching by package name to cover both possibilities. For a three-segment input, the query branches perform exact matching simultaneously along the three dimensions of namespace name, package name, and function name.
[0040] Specifically, taking the two-part input s1.func1 as an example, the constructed multi-select query statement contains two query branches. The first query branch matches the system table of the remote database with the namespace name s1 and the function name func1, and the second query branch matches the package name s1 and the function name func1. The query results of the two query branches are merged and returned together.
[0041] In other words, the remote function call method based on database linking of the present invention supports all input forms, and the query statement with multiple selections can cover all possible matching paths through its multiple query branches, thereby obtaining all candidate functions that match the user input in a single remote interactive communication.
[0042] Therefore, the remote function call method based on database link in this embodiment of the invention identifies the input form of the function name, constructs multiple query branches covering all input forms, and integrates them to obtain a query statement. This achieves the matching requirements of different input forms and ensures that function information matching different user input forms can be obtained with only one remote database interaction, without the need for multiple interactions to query the remote database, thereby improving the universality and compatibility of remote function calls.
[0043] In some embodiments, the step of obtaining the function information of the target remote function that matches the remote function call statement in the remote database in step S104 may include the following steps: determining whether there is a remote function that matches the remote function call statement in the remote database; if not, skipping the remote function call operation; if yes, determining whether there are multiple matching remote functions in the remote database; if multiple exist, performing overload matching on all matching remote functions to obtain the target remote function, and obtaining the function information of the target remote function; if multiple do not exist, using the matched remote function as the target remote function, and obtaining the function information of the target remote function.
[0044] It should be noted that because databases allow function overloading (i.e., declaring several functions with similar functionality and the same name in the same scope, but with different numbers and types of parameters), multiple functions with the same name may exist in the remote database that match the remote function call statement. Therefore, after confirming the existence of a matching remote function in the remote database, it is necessary to further determine whether there are multiple matching functions with the same name.
[0045] Based on this, the step of determining whether a remote function matching the remote function call statement exists in the remote database can be specifically executed as follows: obtain the function to be called in the remote function call statement; determine whether the name of the remote function in the remote database is the same as the name of the function to be called; if they are the same, then it is determined that a matching remote function exists in the remote database; if they are not the same, then it is determined that no matching remote function exists in the remote database. Specifically, in this embodiment, the name includes the namespace name, package name, and function name.
[0046] In other words, the remote function call method based on database connection of the present invention uses name consistency as the core criterion to determine whether there is a matching remote function in the remote database, thereby achieving fast pre-screening, thus narrowing the data range of subsequent matching processing, improving the processing efficiency of function matching, and avoiding the problem of missing matching of target functions.
[0047] When multiple functions with the same name are found in the remote database, overloading ambiguity arises. In this case, overloading matching is performed to select the target remote function that best matches the user's call from among the multiple functions with the same name. When only one matching remote function is found in the remote database, there is no overloading ambiguity, and the matched remote function can be directly used as the target remote function.
[0048] Therefore, the remote function call method based on database linking in this embodiment of the invention determines the number of matching remote functions when obtaining remote function information. It directly selects the target remote function when only a single matching remote function exists, and performs overload matching when multiple matching remote functions exist. This achieves adaptive target remote function selection under different matching scenarios, while ensuring that the target remote function intended by the user can be accurately selected in the function overload scenario, avoiding calling errors caused by matching multiple functions with the same name, thereby improving the accuracy of target remote function calls.
[0049] In some embodiments, the above-described step of performing overload matching on all matching remote functions may include the following steps: obtaining function information from all matching remote functions, wherein the function information includes the number of parameters and parameter types; obtaining call parameter information from the remote function call statement, wherein the call parameter information includes the number of parameters and parameter types; comparing the function information of each matching remote function with the call parameter information respectively; and selecting the target remote function based on the degree of matching of the number of parameters and parameter types.
[0050] Specifically, the steps for selecting the target remote function based on the degree of matching of the number of parameters and parameter types can be implemented as follows: a first round of screening based on the degree of matching of the number of parameters; a second round of screening based on the degree of matching of the parameter types; and selecting the remote function with the highest degree of matching of the number of parameters and the degree of matching of the parameter types as the target remote function.
[0051] In addition, the above steps of reloading matching all matching remote functions can be performed in the local database to adapt to the unified local matching rule standard, avoid the problem of inconsistent call results caused by the difference in reloading rules of different remote databases, and thus improve the stability of cross-database calls.
[0052] Therefore, the remote function call method based on database link in this embodiment of the invention compares the parameter signatures of each candidate function with the user call parameters, and selects the target function based on the degree of matching in two dimensions: the number of parameters and the parameter type. This achieves accurate matching of remote function overloads, thereby further ensuring the accuracy of remote function calls.
[0053] In some embodiments, step S106 may include the following steps: creating an empty function shell in a local database as a local function; binding the function information of the target remote function to the empty function shell to establish a mapping relationship between the local function and the target remote function.
[0054] In other words, a local function mapping is built into the local database, and the basic information of the remote function is saved and passed through the local mapping function to form the calling interface of the remote function, without exposing the underlying table structure. The remote function has independent access control, achieving permission isolation and adhering to the principle of least privilege. Furthermore, sensitive business logic and data can be retained in the remote source system, avoiding the exposure of details.
[0055] Therefore, the remote function call method based on database linking in this embodiment of the invention achieves localized transparent calling of remote functions by creating a local empty function shell and binding the function information of the target remote function, thereby improving the accuracy of cross-library function calls.
[0056] In addition, the remote function call method based on database link in this embodiment of the invention persistently binds the function information of the target remote function to the local machine. Subsequent high-frequency calls do not need to repeatedly execute the function information query of the remote function, which further reduces the number of remote interaction communications and thus improves the overall execution efficiency of cross-library function calls.
[0057] In some embodiments, after step S108, the remote function call method of the present invention may further include the following steps: the local database receives the execution result of the target remote function returned by the remote database; obtains a data type matching rule pre-built based on FDW; converts the execution result into a data type compatible with the local database based on the data type matching rule; and outputs the converted execution result as the return value of the local function.
[0058] It should be noted that the execution result is the data returned by the target remote function after it has finished executing in the remote database. Since the remote database and the local database may be heterogeneous, the data type of the execution result is represented based on the type system of the remote database, which may be incompatible with the type system of the local database.
[0059] Based on this, this embodiment uses FDW to convert the execution result into a data type compatible with the local database, and outputs the converted execution result, which is now fully compatible with the type system of the local database, as the return value of the local function.
[0060] Therefore, the remote function call method based on database link in this embodiment of the invention performs type conversion on the remote execution result by using data type matching rules built based on FDW, thereby achieving data type compatibility in heterogeneous database environments and ensuring that the result returned by the remote function can be correctly identified and processed by the local database, thus improving the stability and accuracy of cross-database function calls.
[0061] Figure 2 This is a control flow diagram of a remote function call method based on a database connection according to an embodiment of the present invention. The following is in conjunction with... Figure 2 The process steps of remote function calling in this embodiment will be described in detail.
[0062] Step S202: Receive the remote function call statement input by the user. It should be noted that the remote function call statement is used to access remote functions in a remote database via DBLINK.
[0063] Step S204 involves analyzing the remote function call statement to obtain the function name and call parameter information. It should be noted that the function name information includes one or more of the following: namespace name, package name, and function name. Additionally, the call parameter information includes the number of parameters and their types.
[0064] Step S206: Identify the input format of the function name information in the remote function call statement. It should be noted that the input formats for the function name information include single-segment input, two-segment input, and three-segment input. Single-segment input includes only the function name; two-segment input includes either the namespace name or the package name, along with the function name; and three-segment input includes the namespace name, the package name, and the function name.
[0065] Step S208: Construct a query statement containing multiple query branches based on the function name information in the remote function call statement and the identified input format, resulting in a multi-select query statement. It should be noted that each query branch corresponds to a different input format, and each query branch is used to query the remote database for remote functions whose names match the function name information of the corresponding input format.
[0066] Step S210: Send the multi-select query statement to the remote database for execution via DBLINK.
[0067] Step S212: Determine whether a remote function matching the remote function call statement exists in the remote database. If yes, proceed to step S214; otherwise, proceed to step S232.
[0068] Step S214: Determine if there are multiple matching remote functions in the remote database. If yes, proceed to step S216; otherwise, proceed to step S218.
[0069] Step S216: Perform overload matching on all matched remote functions to obtain the target remote function, acquire the function information of the target remote function, and execute step S220.
[0070] Step S218: Take the matched remote function as the target remote function, obtain the function information of the target remote function, and execute step S220.
[0071] Step S220: Construct a local function in the local database based on the function information, and map the local function to the target remote function.
[0072] Step S222: Call and execute the target remote function in the remote database through a local function.
[0073] Step S224: Determine whether the target remote function was executed successfully. If yes, proceed to step S226; otherwise, proceed to step S230.
[0074] Step S226: Based on the data type matching rules built by FDW, the execution result is converted into a data type compatible with the local database.
[0075] In step S228, the converted execution result is output as the return value of the local function. At this point, the remote function call process ends, and we can return to step S202 to wait for the next call.
[0076] Step S230: Return execution failure information and skip the remote function call operation. It should be noted that reasons for execution failure include, but are not limited to, insufficient permissions, internal exceptions within the remote function, and network timeouts. At this point, the remote function call process ends, and we can return to step S202 to continue waiting for the next call.
[0077] Step S232: Return the matching failure information and skip the remote function call operation. At this point, the remote function call process ends, and we can return to step S202 to continue waiting for the next call to be triggered.
[0078] Therefore, the remote function call method based on database link in this embodiment of the invention constructs a multi-select query statement based on the remote function call statement input by the user, obtains the matching target remote function information through a single remote interactive communication via DBLINK, and triggers the execution of the remote function after constructing the mapping function locally. This achieves the completion of remote function calls with reduced remote interactive communication, without the need for multiple interactive queries to the remote database, ensuring the simplicity of the function call chain and the integrity of data acquisition, thereby reducing the overhead of remote interactive communication and improving the efficiency and accuracy of cross-database access.
[0079] Furthermore, the remote function call method based on database connection in this embodiment of the invention encapsulates the calling logic of the remote function in the local function by mapping the local function to the remote function. The application layer does not need to care about the connection details of the remote database, allowing different databases and different business systems to interact through functions, reducing system coupling, thereby reducing the cost of database system transformation, and also reducing the complexity of local code, thus improving the usability of the database system.
[0080] This embodiment also provides a computer program product 10, a computer-readable storage medium 20, and a computer device 30. Figure 3 This is a schematic diagram of a computer program product 10 according to an embodiment of the present invention. Figure 4 This is a schematic diagram of a computer-readable storage medium 20 according to an embodiment of the present invention. Figure 5 This is a schematic block diagram of a computer device 30 according to an embodiment of the present invention.
[0081] Computer program product 10 includes computer program 11, which, when executed by processor 32, implements the steps of any of the above-described database-link-based remote function call methods. Computer-readable storage medium 20 stores the computer program 11 thereon, which, when executed by processor 32, implements the steps of any of the above-described database-link-based remote function call methods. Computer device 30 may include memory 31, processor 32, and computer program 11 stored in memory 31 and running on processor 32.
[0082] The computer program 11 used to perform the operations of the present invention may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, status setting data, integrated circuit configuration data, or source code or object code written in any combination of one or more programming languages and procedural programming languages.
[0083] Computer program 11 may execute entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the latter case, the remote computer may be connected to the user's computer via any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, to perform aspects of the invention, electronic circuits including, for example, programmable logic circuits, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs) may execute computer-readable program instructions to personalize the electronic circuits by utilizing state information of computer-readable program instructions.
[0084] For the purposes of this embodiment, computer program product 10 is a related product that includes computer program 11.
[0085] For the purposes of this embodiment, computer-readable storage medium 20 is a tangible device capable of holding and storing a computer program 11. It can be any device capable of containing, storing, communicating, propagating, or transmitting the program 11 for use by or in conjunction with an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable storage medium 20 include: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable optical disc read-only memory (CD-ROM), digital versatile disc (DVD), memory stick, floppy disk, mechanical encoding device, and any suitable combination thereof.
[0086] Therefore, those skilled in the art should recognize that although numerous exemplary embodiments of the present invention have been shown and described in detail herein, many other variations or modifications conforming to the principles of the present invention can be directly determined or derived from the disclosure of the present invention without departing from the spirit and scope of the invention. Thus, the scope of the present invention should be understood and construed as covering all such other variations or modifications.
Claims
1. A remote function call method based on database connection, comprising: Based on the remote function call statement input by the user, construct a multi-select query statement in the local database; The multi-selection query statement is sent to a remote database for execution via a database link to obtain the function information of the target remote function that matches the remote function call statement in the remote database; Based on the function information, a local function is constructed in the local database, and the local function is mapped to the target remote function; The target remote function is invoked and executed in the remote database through the local function.
2. The remote function call method based on database connection according to claim 1, wherein, The step of obtaining the function information of the target remote function that matches the remote function call statement in the remote database includes: Determine whether a remote function matching the remote function call statement exists in the remote database; If so, determine whether multiple matching remote functions exist in the remote database; If multiple remote functions exist, overload matching is performed on all matching remote functions to obtain the target remote function, and the function information of the target remote function is obtained. If there are no multiple remote functions, the matched remote function will be used as the target remote function, and the function information of the target remote function will be obtained.
3. The remote function call method based on database connection according to claim 2, wherein, The step of performing overload matching on all matching remote functions includes: Retrieve function information from all matching remote functions, wherein the function information includes the number of parameters and the parameter types; Obtain the call parameter information of the remote function call statement, wherein the call parameter information includes the number of parameters and the parameter types; The function information of each matched remote function is compared with the calling parameter information. The target remote function is selected based on the degree of matching between the number of parameters and the parameter types.
4. The remote function call method based on database connection according to claim 2, wherein, The step of determining whether a remote function matching the remote function call statement exists in the remote database includes: Retrieve the function to be called from the remote function call statement; Determine whether the name of the remote function in the remote database is the same as the name of the function to be called; If they are the same, then it is determined that a matching remote function exists in the remote database; If they are not the same, it is determined that there is no matching remote function in the remote database.
5. The remote function call method based on database connection according to claim 1, wherein, Before the step of constructing a multi-select query statement in the local database based on the user-input remote function call statement, the remote function call method further includes: Receive a remote function call statement input by the user, wherein the remote function call statement is used to access a remote function in the remote database through a database link; The remote function call statement is analyzed to obtain the function name information and call parameter information in the remote function call statement. The input form of the function name information includes one-part input, two-part input and three-part input. The one-part input includes only the function name. The two-part input includes either the namespace name or the package name and the function name. The three-part input includes the namespace name, the package name and the function name.
6. The remote function call method based on database connection according to claim 5, wherein, The steps for constructing a multi-select query statement in the local database based on the remote function call statement input by the user include: Identify the input format of the function name information in the remote function call statement; Based on the function name information in the remote function call statement and the identified input format, a query statement containing multiple query branches is constructed. Each of the multiple query branches corresponds to a different input format, and each query branch is used to query the remote database for a remote function whose function name information matches the corresponding input format.
7. The remote function call method based on database connection according to claim 1, wherein, After the step of calling and executing the target remote function in the remote database via the local function, the remote function invocation method further includes: The local database receives the execution result of the target remote function returned by the remote database; Obtain data type matching rules pre-built based on external data wrappers; Based on the data type matching rules, the execution result is converted into a data type compatible with the local database; The converted execution result is output as the return value of the local function.
8. A computer program product comprising a computer program, wherein, When executed by a processor, the computer program implements the steps of the remote function call method based on a database link as described in any one of claims 1 to 7.
9. A computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the remote function call method based on a database link as described in any one of claims 1 to 7.
10. A computer device comprising a memory, a processor, and a computer program stored in the memory, wherein, The processor executes the computer program to implement the steps of the remote function call method based on a database link as described in any one of claims 1 to 7.
