Method, apparatus, device, and medium for generating query statements and querying service data

The conditions are entered through the view metadata design interface, and the preliminary query statement is generated, which solves the problem of low development efficiency when the query conditions are complex, and realizes efficient and flexible database query and code development.

CN118193567BActive Publication Date: 2025-07-18BEIJING SHENZHOU AEROSPACE SOFTWARE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410262185.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-07
Publication Date
2025-07-18
Estimated Expiration
2044-03-07

AI Technical Summary

Technical Problem

In the prior art, when the query conditions are complex, the database-related code development efficiency of Web program development is low, and complex query statements are required frequently, resulting in a high probability of errors.

Method used

Enter the view metadata name, condition fields and condition configuration information through the view metadata design interface to generate preparatory query statements, and the server automatically splices SQL statements to reduce manual writing, and provides a graphical interface to set query conditions.

Benefits of technology

It improves the development efficiency of database-related code, reduces the probability of errors, enhances the flexibility and customization capabilities of the system, simplifies the query process, and improves the query efficiency and modular reusability of the code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118193567B_ABST
    Figure CN118193567B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of databases, and discloses a method, device, equipment and medium for generating query statements and querying service data. The present invention includes: receiving a save request; extracting a view metadata name, at least one conditional field, and conditional configuration information for each conditional field from the save request; generating a preliminary query statement according to the view metadata name, at least one conditional field, and conditional configuration information for each conditional field. Receiving a query request; parsing the query request to obtain a first view metadata name, at least one query parameter, a conditional value and a conditional symbol for each query parameter; obtaining a first preliminary query statement according to the first view metadata name; generating a target query statement according to the first preliminary query statement, at least one query parameter, a conditional value and a conditional symbol for each query parameter; executing the target query statement to obtain a first query data set. The present invention can improve the development efficiency of related code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of databases, and particularly to a method, apparatus, device, and medium for generating query statements and querying service data. Background Art

[0002] In recent years, the technical threshold for the development work of Web programs is relatively high. Usually, when developing Web programs, it is necessary to take into account the code of the client, the server, and the database.

[0003] In the related art, every time a query condition for a database table is added or modified, the user needs to write a corresponding Structured Query Language (SQL) script. After receiving the query parameters, the query statement is obtained by splicing according to the SQL script and the query parameters, and the query data can be obtained after executing the query statement.

[0004] However, when the query conditions are relatively complex, or when a large number of query conditions need to be set, the development efficiency of the related code is low. Summary of the Invention

[0005] In view of this, the present invention provides a method, apparatus, device, and medium for generating query statements and querying service data to solve the problem of low development efficiency of the code related to query conditions.

[0006] In a first aspect, the present invention provides a method for generating a query statement. The method is applied to a database management system and includes:

[0007] Receiving a save request;

[0008] Extracting a view metadata name, at least one condition field, and condition configuration information corresponding to each condition field from the save request, where the view metadata name, at least one condition field, and condition configuration information corresponding to each condition field are all input by the user in a view metadata design interface;

[0009] Generating a preliminary query statement corresponding to the view metadata name according to the view metadata name, at least one condition field, and condition configuration information corresponding to each condition field.

[0010] A method for generating a query statement provided by the present invention has the following advantages:

[0011] First, developers can directly input the view metadata name, corresponding conditional fields, and conditional configuration information in the view metadata design interface according to actual needs. This greatly enhances the flexibility and customization ability of the system, enabling developers to customize data views that meet their own needs according to business scenarios. Moreover, this solution allows developers to intuitively set query conditions through a graphical interface, eliminating the need to write complex query statements, reducing the usage threshold, and improving the development efficiency of database-related code. Additionally, the server can automatically generate preliminary query statements based on the developers' input, reducing the probability of errors.

[0012] Second, when queries under different conditional parameters need to be performed based on the same view, only the pre-set preliminary query statements need to be called, which can enhance the query efficiency of business data.

[0013] Third, since users can dynamically add, modify, or delete conditional fields and their configuration information according to actual situations, this solution can quickly respond to changes in business requirements without having to rewrite database-related code according to business requirements, that is, it can improve the development efficiency of related code.

[0014] In an alternative embodiment, generating the preliminary query statement corresponding to the view metadata name according to the view metadata name, at least one conditional field, and the conditional configuration information corresponding to each conditional field includes:

[0015] Obtain the target view metadata corresponding to the view metadata name according to the view metadata name;

[0016] Extract the target database table name from the target view metadata;

[0017] Generate the preliminary query statement according to the target database table name, at least one conditional field, and the conditional configuration information corresponding to each conditional field.

[0018] Specifically, first, this solution can automatically generate preliminary query statements, greatly simplifying the construction process of query statements. Further, it can improve query efficiency and also reduce errors caused by manual writing of queries. Second, using view metadata as an intermediate layer not only encapsulates the specific details of database tables but also provides rich query condition interfaces. This design pattern can enhance the modularity and reusability of code. For frequently changing or similar query requirements, only the conditional configuration of view metadata needs to be adjusted to achieve a quick response.

[0019] In a second aspect, the present invention provides a method for querying business data, which is applied to a database management system, and the method includes:

[0020] Receive a query request;

[0021] Parse the query request to obtain a first view metadata name, at least one query parameter, and a condition value and a condition symbol corresponding to each query parameter;

[0022] Obtain a first preliminary query statement corresponding to the first view metadata name according to the first view metadata name;

[0023] Generate a target query statement according to the first preliminary query statement, at least one query parameter, and a condition value and a condition symbol corresponding to each query parameter;

[0024] Execute the target query statement to obtain a first query data set.

[0025] A method for querying service data provided by the present invention has the following advantages:

[0026] First, directly obtaining a preliminary query statement according to the view metadata name can reduce the workload of repeatedly writing basic queries. Further, the query efficiency can be improved. Second, by using view metadata as intermediate layer data, when the database table structure changes, only the view metadata needs to be updated. In this way, there is no need to rewrite the relevant query code, which can greatly improve the development efficiency of database-related code.

[0027] In an optional implementation manner, the method further includes:

[0028] Determine a target view metadata corresponding to the first view metadata name according to the first view metadata name;

[0029] When it is determined that the target view metadata includes association relationship information, extract an association table name and at least one association field name from the association relationship information;

[0030] Determine a target association table corresponding to the association table name according to the association table name;

[0031] Determine at least one associated data corresponding to each piece of data in the first query data set in the target association table according to each association field name;

[0032] Concatenate each piece of data and at least one associated data corresponding to each piece of data to obtain a second query data set.

[0033] Specifically, this solution can automatically load the data in the associated table according to the association relationship information in the view metadata, simplify the query process, and improve the development efficiency. Moreover, by splicing the associated data, it ensures that all information related to the master data is included in the query result, improving the data integrity. By loading the associated data at once and splicing them together, it can reduce the overhead of multiple database queries. Especially in the batch processing scenario, it can enhance the overall performance of the system.

[0034] In an alternative embodiment, the method further includes:

[0035] Extract the type of the target view metadata from the target view metadata;

[0036] Package all the data in the second query data set according to the type of the target view metadata to obtain a return result.

[0037] Specifically, packaging the second query data set according to the type of the target view metadata ensures that the data structure of the return result matches the business requirements, facilitating front-end display and back-end processing.

[0038] In a third aspect, the present invention provides a device for generating a query statement. The device is applied to a database management system and includes:

[0039] A receiving module, configured to receive a save request;

[0040] An extraction module, configured to extract a view metadata name, at least one conditional field, and conditional configuration information corresponding to each conditional field from the save request, where the view metadata name, at least one conditional field, and the conditional configuration information corresponding to each conditional field are all input by a user in a view metadata design interface;

[0041] A generation module, configured to generate a preliminary query statement corresponding to the view metadata name according to the view metadata name, at least one conditional field, and the conditional configuration information corresponding to each conditional field.

[0042] In a fourth aspect, the present invention provides a device for querying business data. The device is applied to a database management system and includes:

[0043] A receiving module, configured to receive a query request;

[0044] A parsing module, configured to parse the query request to obtain a first view metadata name, at least one query parameter, and a conditional value and a conditional symbol corresponding to each query parameter;

[0045] An acquisition module, configured to acquire a first preliminary query statement corresponding to the first view metadata name according to the first view metadata name;

[0046] A generation module, configured to generate a target query statement according to the first preliminary query statement, at least one query parameter, and a condition value and a condition symbol corresponding to each query parameter;

[0047] An execution module, configured to execute the target query statement to obtain a first query data set.

[0048] In a fifth aspect, the present invention provides a computer device, including: a memory and a processor, which are communicatively connected to each other. The memory stores computer instructions, and the processor executes the computer instructions to execute the method for generating a query statement according to the first aspect or any corresponding embodiment thereof, or execute the method for querying service data according to the second aspect or any corresponding embodiment thereof.

[0049] In a sixth aspect, the present invention provides a computer-readable storage medium, on which computer instructions are stored. The computer instructions are used to cause a computer to execute the method for generating a query statement according to the first aspect or any corresponding embodiment thereof, or execute the method for querying service data according to the second aspect or any corresponding embodiment thereof.

[0050] In a seventh aspect, the present invention provides a computer program product, including computer instructions, which are used to cause a computer to execute the method for generating a query statement according to the first aspect or any corresponding embodiment thereof, or execute the method for querying service data according to the second aspect or any corresponding embodiment thereof. Description of the Drawings

[0051] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the related art, the following will briefly introduce the drawings required for use in the description of the specific embodiments or the related art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0052] Figure 1 is a schematic diagram of a view metadata design interface according to an embodiment of the present invention;

[0053] Figure 2 is a flowchart of a method for generating a query statement according to an embodiment of the present invention;

[0054] Figure 3 is a flowchart of another method for generating a query statement according to an embodiment of the present invention;

[0055] Figure 4 is a schematic flowchart of a method for querying service data according to an embodiment of the present invention;

[0056] Figure 5 is a schematic flowchart of another method for querying service data according to an embodiment of the present invention;

[0057] Figure 6 is a structural block diagram of a device for generating a query statement according to an embodiment of the present invention;

[0058] Figure 7 is a structural block diagram of a device for querying service data according to an embodiment of the present invention;

[0059] Figure 8 is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. Detailed implementation manners

[0060] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Apparently, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0061] In recent years, the software industry has developed rapidly, and most business functions are implemented based on the architecture combining Web applications and databases. For example, various shopping applications, office applications, and so on. In traditional Web program development, a large amount of code needs to be written for adding or modifying any database-related function.

[0062] The embodiments of the present invention provide a method for generating a query statement and querying service data. By pre-generating a query statement through intermediate variable view metadata to query service data, the development efficiency of related code can be greatly improved.

[0063] The present invention is applied to a database management system, which may include a client and a server. Among them, the client may be a terminal, such as a desktop computer, a laptop computer, a mobile phone, and so on. The server may be a server or a server cluster, etc. The client may be the terminal where the developer is located or the terminal where an ordinary user is located, and is installed with a Web-side program. The server may be installed with a server-side program and store a database, and a large number of database tables are stored in the database.

[0064] The view metadata is described below. The view metadata corresponds to the views in the database and is used to query business data according to conditions. The view metadata may include the view metadata name, database table name, type of view metadata, page template, conditional fields, and conditional configuration information of the conditional fields.

[0065] Among them, the view metadata name, database table name, type of view metadata, page template, conditional fields, and field configuration information of the conditional fields can all be configured in the view metadata design interface as shown in Figure 1 The design interface includes three major modules: the view metadata setting module, the field list, and the conditional input module corresponding to the view type. Among them, the view metadata setting module includes an input box for the view metadata name, an input box for the database table name, an input box for the view type, an input box for the page template, and an input box for the field set.

[0066] The setting rules of the view metadata are described in detail below.

[0067] First, enter the view metadata name in the input box for the view metadata name. The view metadata name is a required input item and is the unique identifier of the view metadata. In the input box for the database table name, the entity metadata name or the database table name can be selected through a drop-down list. If the entity metadata name is selected, the client can obtain the set of field configuration information of the corresponding entity metadata from the server. If the database table name is selected, the client can obtain the table information and the set of field configuration information of the corresponding database table from the server. The relevant information obtained from the server can be displayed in the view metadata setting module.

[0068] Second, select the type of view metadata through the drop-down list in the input box for the view type. The type of view metadata can be the option type, the verification type, the default value type, etc. (if not selected, the default is the list type). The list type is used to display a list, and it can be selected whether to have buttons such as form addition, modification, viewing, deletion, and custom buttons. The option type can specify the option display field and the value field, concatenate them into drop-down options, and can specify the parent node field to form tree options. The verification type can customize the verification result and the prompt message. The default value type can only return one value and is often used for logic such as automatic number generation.

[0069] Third, the page template can be selected or not. If not selected, the default page template will be used. For example, the default page module can be a list template. The page template is pre-created by developers and configured in the Web application. Developers can create page templates through page template editing software, such as online Velocity, etc. The page template can be in various page formats such as native Htm, JQueryUI, Vue, React, Amis, etc. The page template can include form layouts and definitions of each component. Among them, the form layout includes the number of rows and columns of the form, the number of components in each row or column, etc. The definition of the component can include the display form of the component (such as dropdown box, option, color, etc.), and the data length that the component can fill.

[0070] Fourth, both the field list and the field set input box can be used to set the conditional field set and conditional configuration information involved in the view metadata.

[0071] 1. Conditional field set.

[0072] (1) By default, the view metadata lists all fields of the selected entity metadata or database table, and unnecessary fields can be deleted manually.

[0073] (2) For fields that do not need to be displayed, a "!" can be added after the field to hide the field.

[0074] (3) When the form of the field is an option, the display field that can be set to be escaped as an option can be used. The alias for the field display can be set using "~", and specific calculations can be performed using database functions.

[0075] (4) "xxx.*" can be used to represent querying all fields of the "xxx" database table.

[0076] (5) The full-expression language (Expression Language, EL) expression wrapped by "%xxx%" can be used to perform calculations and processing on the fields after querying.

[0077] 2. Conditional configuration information.

[0078] (1) The association relationship and data filtering conditions of the entity metadata are set through the conditional expression starting with "@" at the end of the field set input box.

[0079] Example 1, setting the association relationship of the entity metadata "@$$xxx.ID+=$$yyy.MAINID" means that there is a left-join foreign key association relationship between the "xxx" database table and the "yyy" database table.

[0080] Example 2, set the data filtering condition "$$xxx.NAME=#{NAME}", which means the value of the NAME field in the "xxx" database table is equal to the value of the query parameter NAME.

[0081] Example 3, set the association relationship and data filtering condition "@$$xxx.ID+=$$yyy.MAINID&$$xxx.NAME=#{NAME}" at the same time, which means there is a left-join foreign key association relationship between the "xxx" database table and the "yyy" database table, and the value of the NAME field in the "xxx" database table is equal to the value of the query parameter NAME.

[0082] (2) Implement the grouped query of "group by" by specifying the grouping condition through " / $$". For example, " / $$xxx.zz" means to perform a grouped query on the business data in the "xxx" database table according to the "zz" field.

[0083] (3) Specify ascending sorting through "+", and descending sorting through "-".

[0084] Example 1, "|$$xxx.yyy+" means to sort the data in the "xxx" database table in ascending order according to the "yyy" field.

[0085] Example 2, "$$xxx.zz-" means to sort the data in the "xxx" database table in descending order according to the "zz" field.

[0086] (4) Use CHILD[$$……,$$x……] to form an array of data in the associated table corresponding to the associated entity metadata as child nodes and place it in the CHILD attribute of each piece of data.

[0087] For example, in CHILD[$$xxx.yyy,$$xxx.zzz], it means to splice the values of the "yyy" field and the "zzz" field in the associated table "xxx" into an array and place it in the CHILD attribute of the corresponding data in the database table.

[0088] (5) Use ($$……,) to indicate that the specified fields of the associated data are spliced into values separated by ",".

[0089] For example, ($$xxx.yyy,) means to splice the values of the "yyy" field of all data in the associated table "xxx" together using ",".

[0090] (6) Use {$$……} to indicate that the associated data is spliced after the query result data.

[0091] For example, {$$xxx.yyy} means to splice the value of the "yyy" field in the associated table "xxx" after the query result data.

[0092] After the developer configures the set of conditional fields and the conditional configuration information, a save operation can be performed. When the client detects the developer's save operation, it can obtain the identifier of the page template (i.e., the page template selected by the user or the default one). Additionally, the client converts the view metadata name, database table name, conditional fields, conditional configuration information, etc. entered by the developer into the full pinyin. If there are duplicates in the full pinyin, suffix numbers 1, 2, 3, etc. are added to the end of the full pinyin. Then, according to the identifier of the page template, the corresponding JS (JavaScript) file, Cascading Style Sheets file, etc. of the target page template can be obtained from the page template library of the Web-side program. Finally, the client can generate a conditional input module based on the conditional configuration information in the converted format and the form layout and definitions of each component in the target page template, and display it, as Figure 1 shown in the upper right corner.

[0093] The Web-side program also provides an EL expression editor. Developers can assemble EL expressions in the EL expression editor through prefabricated functions, custom functions, etc. Among them, the prefabricated functions can include various functions such as logical judgment, numeric functions, time functions, string functions, array functions, interface call functions, etc. The custom functions can be JS (JavaScript) functions.

[0094] According to an embodiment of the present invention, an embodiment of a method for generating a query statement is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.

[0095] In this embodiment, a method for generating a query statement is provided, which is executed by the above-mentioned server Figure 2 is a flowchart of the method for generating a query statement according to an embodiment of the present invention, as Figure 2 shown, and the process includes the following steps:

[0096] Step S201, receive a save request, and extract the view metadata name, at least one conditional field, and the conditional configuration information corresponding to each conditional field from the save request.

[0097] Among them, the view metadata name, at least one conditional field, and the conditional configuration information corresponding to each conditional field are all input by the user in the view metadata design interface.

[0098] In practice, when the developer is in Figure 1After completing the design of view metadata in the shown design interface, a save operation can be performed. When the client detects the save operation of the development, it can generate a save request and send it to the server according to the name of the view metadata, the database table name, the conditional fields, the conditional configuration information set, the type of the view metadata, etc. input by the developer. After receiving the save request, the server can parse the save request and obtain the name of the view metadata, the database table name, the conditional fields, the conditional configuration information, the type of the view metadata, etc.

[0099] Step S202, generate a preliminary query statement corresponding to the view metadata name according to the view metadata name, at least one conditional field, and the conditional configuration information corresponding to each conditional field.

[0100] Among them, the type of the preliminary query statement can be a Structured Query Language (SQL) statement.

[0101] In implementation, the server can generate view metadata according to the view metadata name, each conditional field, the conditional configuration information of each conditional field, and the type of the view metadata. In addition, the server can also obtain a query statement template, fill the view metadata name, the database table name, the conditional fields, and the conditional configuration information into the specified positions of the query statement template to obtain a preliminary query statement, and store it.

[0102] The method for generating a query statement provided in this embodiment:

[0103] First, the developer can directly input the view metadata name and the corresponding conditional fields and conditional configuration information in the view metadata design interface according to actual needs, which greatly enhances the flexibility and customization ability of the system, enabling the developer to customize a data view that meets their own needs according to the business scenario. Moreover, this solution allows the developer to intuitively set query conditions through a graphical interface without writing complex SQL statements, reducing the usage threshold and improving the development efficiency of database-related code. In addition, the server can automatically generate a preliminary query statement according to the developer's input, reducing the probability of errors.

[0104] Second, when it is necessary to perform queries under different conditional parameters based on the same view, only the pre-set preliminary query statement needs to be called, which can enhance the query efficiency of business data.

[0105] Third, since the user can dynamically add, modify, or delete conditional fields and their configuration information according to the actual situation, this solution can quickly respond to changes in business requirements without having to rewrite database-related code according to business requirements, that is, it can improve the development efficiency of related code.

[0106] In this embodiment, a method for generating a query statement is provided, which is executed by the above-mentioned server. Figure 3 It is a flowchart of the method for generating a query statement according to an embodiment of the present invention. As Figure 3 shown, the process includes the following steps:

[0107] Step S301, receive a save request, and extract the view metadata name, at least one condition field, and condition configuration information corresponding to each condition field from the save request.

[0108] Among them, the view metadata name, at least one condition field, and condition configuration information corresponding to each condition field are all input by the user in the view metadata design interface.

[0109] The specific processing of step S301 is similar to that of step S201, and will not be elaborated here.

[0110] Step S302, generate a preliminary query statement corresponding to the view metadata name according to the view metadata name, at least one condition field, and condition configuration information corresponding to each condition field.

[0111] Specifically, the above step S302 includes:

[0112] Step S3021, obtain the target view metadata corresponding to the view metadata name according to the view metadata name.

[0113] In implementation, the server can determine whether there is target view metadata corresponding to the view metadata name according to the view metadata name. If so, the target view metadata can be updated according to the extracted condition fields and condition configuration information, and step S3022 can be performed. If not, the target view metadata can be generated according to the view metadata name, database table name, at least one condition field, condition configuration information corresponding to each condition field, type of view metadata, etc.

[0114] Step S3022, extract the target database table name from the target view metadata.

[0115] In implementation, the server can parse the target view metadata and extract the target database table name therefrom.

[0116] Step S3023, generate a preliminary query statement according to the target database table name, at least one condition field, and condition configuration information corresponding to each condition field.

[0117] In implementation, the server can first obtain a query statement template, fill in the target database table name, conditional fields, and conditional configuration information at the specified positions of the query statement template to obtain a preliminary query statement, and store it.

[0118] For the method for generating a query statement provided in this embodiment, first, this solution can automatically generate a preliminary query statement, greatly simplifying the construction process of the query statement. Further, it can improve the query efficiency, and also reduce errors caused by manually writing queries. Second, using view metadata as the middle layer not only encapsulates the specific details of the database table but also provides a rich query condition interface. This design pattern can enhance the modularity and reusability of the code. For frequently changing or similar query requirements, only the conditional configuration of the view metadata needs to be adjusted to achieve a quick response.

[0119] According to an embodiment of the present invention, an embodiment of a method for querying business data is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. And although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.

[0120] In this embodiment, a method for querying business data is provided, which is executed by the above-mentioned server. Figure 4 is a flowchart of the method for querying business data according to an embodiment of the present invention, as Figure 4 shown, this process includes the following steps:

[0121] Step S401, receive a query request, parse the query request to obtain the first view metadata name, at least one query parameter, and the conditional value and conditional symbol corresponding to each query parameter.

[0122] In implementation, in the conditional input module shown in the upper right corner as Figure 1 , an ordinary user can enter a conditional value in the input box corresponding to the conditional field and click the "Search" control. After the client detects this operation, it can generate a query request according to the first view metadata name corresponding to the conditional input module, the preset conditional fields (i.e., query parameters), the conditional configuration information (including conditional symbols), and the corresponding field values (i.e., conditional values), and send it to the server. After receiving the query request, the server can parse the query request to obtain the first view metadata name, at least one query parameter, and the conditional value and conditional symbol corresponding to each query parameter. For example, in Figure 1 , the query parameters include "Name" and "ID number".

[0123] Step S402: Obtain a first preliminary query statement corresponding to the first view metadata name according to the first view metadata name.

[0124] In implementation, the server can determine a first preliminary query statement corresponding to the first view metadata name according to the first view metadata name.

[0125] Step S403: Generate a target query statement according to the first preliminary query statement, at least one query parameter, and the condition value and condition symbol corresponding to each query parameter.

[0126] Specifically, the server can determine the target position where the query parameter is located in the first preliminary query statement according to the query parameter, and fill the condition value and condition symbol of the query parameter into the target position according to a predetermined rule, and a target query statement can be obtained.

[0127] For example, {"AGE": "5"}, where the query parameter is "AGE", the condition symbol is ">", and the condition value is "5".

[0128] Step S404: Execute the target query statement to obtain a first query data set.

[0129] Among them, the target query statement can be an SQL statement.

[0130] Specifically, the server can execute the target query statement and obtain a first query data set from the database table stored in the database through the query conditions carried in the target query statement.

[0131] For the method for querying service data provided in this embodiment, first, directly obtaining a preliminary query statement according to the view metadata name can reduce the workload of repeatedly writing basic queries, and further, can improve the query efficiency. Second, by using the view metadata as the intermediate layer data, when the database table structure changes, only the view metadata needs to be updated. In this way, there is no need to rewrite the relevant query code, which can greatly improve the development efficiency of the database-related code.

[0132] In this embodiment, a method for querying service data is provided, which is executed by the above-mentioned server. Figure 5 It is a flowchart of the method for querying service data according to an embodiment of the present invention. As Figure 5 shown, the process includes the following steps:

[0133] Step S501: Receive a query request, parse the query request to obtain a first view metadata name, at least one query parameter, and the condition value and condition symbol corresponding to each query parameter.

[0134] Step S502: Obtain a first preliminary query statement corresponding to the first view metadata name according to the first view metadata name.

[0135] Step S503: Generate a target query statement according to the first preliminary query statement, at least one query parameter, and the condition value and condition symbol corresponding to each query parameter.

[0136] Step S504: Execute the target query statement to obtain a first query data set.

[0137] The specific processing of steps S501 to S504 is similar to the specific processing of steps S401 to S404, and will not be elaborated here.

[0138] Step S505: Determine the target view metadata corresponding to the first view metadata name according to the first view metadata name.

[0139] In implementation, the server stores multiple view metadata. The server can determine the target view metadata from multiple view metadata according to the first view metadata name.

[0140] Step S506: When it is determined that the target view metadata includes association relationship information, extract the association table name and at least one association field name from the association relationship information.

[0141] In implementation, the server can determine whether the condition configuration information of the target view metadata includes association relationship information. If so, it can extract the association table name and the association field name from the association relationship information. For example, the association relationship information is "@$$xxx.ID+=$$yyy.MAINID", the database table name corresponding to the target view metadata is "xxx", the association table name is "yyy", and the association field name is "MAINID".

[0142] Step S507: Determine the target association table corresponding to the association table name according to the association table name.

[0143] In implementation, the server can determine the target association table from multiple database tables stored in the database according to the association table name.

[0144] Step S508: Determine at least one piece of associated data corresponding to each piece of data in the first query data set in the target association table according to each association field name.

[0145] In implementation, for each association field name, the server can determine the associated data corresponding to each piece of data according to the association field name and the field value of the target field corresponding to each piece of data in the first query data set. Specifically, the following two methods can be used for processing:

[0146] In Method 1, the server can traverse each piece of data in the target association table. For each piece of data traversed, it determines whether the field value of the association field corresponding to the association field name in this piece of data is the same as the field value of the target field of the target data in the first query dataset. If so, the traversed data can be determined as the associated data of the target data. Here, the target data is any piece of data in the first query dataset. If not, it can traverse the next piece of data in the target association table. And so on, the associated data corresponding to each piece of data in the first query dataset can be determined.

[0147] In Method 2, the server can traverse each piece of data in the first query dataset. For each piece of data traversed, it determines the field value of the target field corresponding to the association field name in the traversed data, and determines whether there is at least one piece of data in the target association table whose field value of the association field is the same as the field value of the target field. If so, the at least one piece of data can be determined as the associated data corresponding to the traversed data. If not, it can traverse the next piece of data in the first query dataset. And so on, the associated data corresponding to each piece of data in the first query dataset can be determined.

[0148] For example, if the association field name is "MAINID", the name of the target field is "ID", and the "ID" of the target data in the first dataset is "001", the data with "MAINID" = "001" in the association table can be determined as the associated data corresponding to the target data.

[0149] Step S509: Concatenate each piece of data and at least one piece of associated data corresponding to each piece of data to obtain a second query dataset.

[0150] In implementation, for each piece of data, the server can concatenate at least one piece of associated data corresponding to this data behind this data to obtain the concatenated data, and the multiple pieces of concatenated data constitute the second query dataset.

[0151] Step S510: Extract the type of the target view metadata from the target view metadata.

[0152] Among them, the type of the target view metadata can be a data dictionary type, a list type, a tree type, etc.

[0153] In implementation, the server can parse the target entity metadata to extract the type of the target view metadata.

[0154] Step S511: Package all the data in the second query dataset according to the type of the target view metadata to obtain the return result.

[0155] In implementation, the server can obtain the conversion method corresponding to the type of the target view metadata according to the type of the target view metadata, perform format conversion on all the data in the second query data set to obtain the final return result, and send it to the client.

[0156] In some alternative implementation manners, the server can convert the field values in each piece of data in the second query data set according to the condition configuration information. For example, if an EL expression is set in the condition configuration information, the field value needs to be input into the EL expression to obtain the calculation result.

[0157] For the method for querying service data provided in this embodiment, first, this solution can automatically load the data in the associated table according to the association relationship information in the view metadata, simplify the query process, and improve the development efficiency. Second, by splicing the associated data, it is ensured that all the information related to the master data is included in the query result, improving the integrity of the data. Moreover, by loading the associated data at one time and splicing them together, the overhead of multiple database queries can be reduced. Especially in the batch processing scenario, the overall performance of the system can be improved. Third, encapsulating the second query data set according to the type of the target view metadata ensures that the data structure of the return result matches the business requirements, facilitating front-end display and back-end processing.

[0158] In this embodiment, a device for generating a query statement is further provided. This device is used to implement the above-mentioned embodiment and preferred implementation manners, and those that have been described will not be elaborated again. As used hereinafter, the term "module" can be a combination of software and / or hardware that can implement a predetermined function. Although the device described in the following embodiments is preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated.

[0159] This embodiment provides a device for generating a query statement, as Figure 6 shown, including:

[0160] A receiving module 601, configured to receive a save request;

[0161] An extraction module 602, configured to extract a view metadata name, at least one condition field, and condition configuration information corresponding to each condition field from the save request, where the view metadata name, at least one condition field, and condition configuration information corresponding to each condition field are all input by the user in the view metadata design interface;

[0162] A generating module 603, configured to generate a preliminary query statement corresponding to the view metadata name according to the view metadata name, at least one condition field, and condition configuration information corresponding to each condition field.

[0163] In some alternative embodiments, a generation module 603 is configured to:

[0164] Obtain target view metadata corresponding to the view metadata name;

[0165] Extract the target database table name from the target view metadata;

[0166] Generate the preliminary query statement according to the target database table name, at least one conditional field, and conditional configuration information corresponding to each conditional field.

[0167] The further function descriptions of the above modules and units are the same as those in the corresponding foregoing embodiments, and will not be elaborated herein.

[0168] The device for generating a query statement in this embodiment is presented in the form of functional units. Here, the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and a memory that execute one or more software or fixed programs, and / or other devices that can provide the above functions.

[0169] In this embodiment, a device for querying service data is further provided. This device is used to implement the above embodiments and preferred implementation manners, and those that have been described will not be elaborated again. As used hereinafter, the term "module" may be a combination of software and / or hardware that can implement a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated.

[0170] This embodiment provides a device for querying service data, as Figure 7 shown, including:

[0171] A receiving module 701, configured to receive a query request;

[0172] An analysis module 702, configured to analyze the query request to obtain a first view metadata name, at least one query parameter, and a conditional value and a conditional symbol corresponding to each query parameter;

[0173] An obtaining module 703, configured to obtain a first preliminary query statement corresponding to the first view metadata name according to the first view metadata name;

[0174] A generation module 704, configured to generate a target query statement according to the first preliminary query statement, at least one query parameter, and a conditional value and a conditional symbol corresponding to each query parameter;

[0175] Execution module 705 is configured to execute the target query statement and obtain a first query data set.

[0176] In some alternative embodiments, the execution module 705 is further configured to:

[0177] Determine a target view metadata corresponding to the first view metadata name according to the first view metadata name;

[0178] When it is determined that the target view metadata includes association relationship information, extract an association table name and at least one association field name from the association relationship information;

[0179] Determine a target association table corresponding to the association table name according to the association table name;

[0180] Determine at least one piece of associated data corresponding to each piece of data in the first query data set in the target association table according to each association field name;

[0181] Concatenate each piece of data and at least one piece of associated data corresponding to each piece of data to obtain a second query data set.

[0182] In some alternative embodiments, the execution module 705 is further configured to:

[0183] Extract the type of the target view metadata from the target view metadata;

[0184] Encapsulate all the data in the second query data set according to the type of the target view metadata to obtain a return result.

[0185] The device for querying service data in this embodiment is presented in the form of functional units. Here, the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and a memory that execute one or more software or fixed programs, and / or other devices that can provide the above functions.

[0186] This embodiment of the present invention further provides a computer device having the above Figure 6 shown device for generating a query statement, or having the above Figure 7 shown device for querying service data.

[0187] Please refer to Figure 8 , Figure 8 which is a schematic structural diagram of a computer device provided by an alternative embodiment of the present invention. As shown in Figure 8As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including a high-speed interface and a low-speed interface. Each component communicates with each other using different buses and can be installed on a common motherboard or installed in other ways as needed. The processor can process instructions executed within the computer device, including instructions stored in the memory or on the memory to display graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In some alternative embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (such as an array of servers, a set of blade servers, or a multi-processor system). Figure 8 In the figure, one processor 10 is taken as an example.

[0188] The processor 10 can be a central processing unit, a network processor, or a combination thereof. Among them, the processor 10 can further include a hardware chip. The above hardware chip can be an application-specific integrated circuit, a programmable logic device, or a combination thereof. The above programmable logic device can be a complex programmable logic device, a field programmable gate array, a generic array logic, or any combination thereof.

[0189] Among them, the memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiments.

[0190] The memory 20 can include a program storage area and a data storage area. Among them, the program storage area can store an operating system and application programs required for at least one function; the data storage area can store data created according to the use of the computer device, etc. In addition, the memory 20 can include a high-speed random access memory and can also include a non-transitory memory, such as at least one disk storage device, a flash memory device, or other non-transitory solid-state storage devices. In some alternative embodiments, the memory 20 can optionally include a memory remotely set relative to the processor 10, and these remote memories can be connected to the computer device through a network. Examples of the above network include but are not limited to the Internet, an enterprise intranet, a local area network, a mobile communication network, and combinations thereof.

[0191] The memory 20 can include a volatile memory, such as a random access memory; the memory can also include a non-volatile memory, such as a flash memory, a hard disk, or a solid-state drive; the memory 20 can also include a combination of the above types of memories.

[0192] The computer device further includes a communication interface 30 for the computer device to communicate with other devices or a communication network.

[0193] Embodiments of the present invention also provide a computer-readable storage medium. The method according to the embodiments of the present invention can be implemented in hardware, firmware, or be implemented as computer code that can be recorded on a storage medium, or be implemented as computer code that is originally stored in a remote storage medium or a non-transitory machine-readable storage medium and downloaded through a network and will be stored in a local storage medium, so that the method described herein can be stored as such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only memory, a random access memory, a flash memory, a hard disk, or a solid-state drive, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by the computer, the processor, or the hardware, the method shown in the above embodiments is implemented.

[0194] A part of the present invention can be applied as a computer program product, for example, computer program instructions. When executed by a computer, through the operation of the computer, the methods and / or technical solutions according to the present invention can be invoked or provided. Those skilled in the art should be able to understand that the forms in which computer program instructions exist in a computer-readable medium include, but are not limited to, source files, executable files, installation package files, etc. Correspondingly, the ways in which computer program instructions are executed by a computer include, but are not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Herein, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible by the computer.

[0195] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations all fall within the scope defined by the appended claims.

Claims

1. A method for querying service data, characterized in that The method is applied to a database management system, and the method includes: Receiving a save request; Extracting a view metadata name, at least one conditional field, and conditional configuration information corresponding to each conditional field from the save request, where the view metadata name, at least one conditional field, and the conditional configuration information corresponding to each conditional field are all input by a user in a view metadata design interface; Obtaining target view metadata corresponding to the view metadata name according to the view metadata name; Extracting a target database table name from the target view metadata; Generating a preliminary query statement corresponding to the view metadata name according to the target database table name, at least one conditional field, and the conditional configuration information corresponding to each conditional field; Receiving a query request; Parsing the query request to obtain a first view metadata name, at least one query parameter, and a conditional value and a conditional symbol corresponding to each query parameter; Determining a first preliminary query statement corresponding to the first view metadata name in the generated preliminary query statement according to the first view metadata name; Generating a target query statement according to the first preliminary query statement, at least one query parameter, and the conditional value and the conditional symbol corresponding to each query parameter; Executing the target query statement to obtain a first query data set; Determining target view metadata corresponding to the first view metadata name according to the first view metadata name; When it is determined that the target view metadata includes association relationship information, extracting an associated table name and at least one associated field name from the association relationship information; Determining a target associated table corresponding to the associated table name according to the associated table name; Determining at least one associated data corresponding to each piece of data in the first query data set in the target associated table according to each associated field name; Concatenating each piece of data and at least one associated data corresponding to each piece of data to obtain a second query data set.

2. The method according to claim 1, wherein The method further includes: Extracting the type of the target view metadata from the target view metadata; Encapsulating all the data in the second query data set according to the type of the target view metadata to obtain a return result.

3. A device for querying service data, characterized in that, The device is applied to a database management system, and the device includes: A receiving module, configured to receive a save request; An extraction module, configured to extract a view metadata name, at least one conditional field, and conditional configuration information corresponding to each conditional field from the save request, where the view metadata name, at least one conditional field, and the conditional configuration information corresponding to each conditional field are all input by a user in a view metadata design interface; A generation module, configured to obtain target view metadata corresponding to the view metadata name according to the view metadata name; extract a target database table name from the target view metadata; generate a preliminary query statement corresponding to the view metadata name according to the target database table name, at least one condition field, and condition configuration information corresponding to each condition field. The receiving module is further configured to receive a query request. A parsing module, configured to parse the query request to obtain a first view metadata name, at least one query parameter, and a condition value and a condition symbol corresponding to each query parameter. An obtaining module, configured to determine a first preliminary query statement corresponding to the first view metadata name in the generated preliminary query statements according to the first view metadata name. The generation module is further configured to generate a target query statement according to the first preliminary query statement, at least one query parameter, and a condition value and a condition symbol corresponding to each query parameter. An execution module, configured to execute the target query statement to obtain a first query data set; determine target view metadata corresponding to the first view metadata name according to the first view metadata name; when it is determined that the target view metadata includes association relationship information, extract an association table name and at least one association field name from the association relationship information; determine a target association table corresponding to the association table name according to the association table name; determine at least one piece of associated data corresponding to each piece of data in the first query data set in the target association table according to each association field name; splice each piece of data and at least one piece of associated data corresponding to each piece of data to obtain a second query data set.

4. A computer device, characterized in that, Comprising: A memory and a processor, the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the computer instructions to execute the method for querying service data according to claim 1 or 2.

5. A computer-readable storage medium, characterized in that, Computer instructions are stored on the computer-readable storage medium, and the computer instructions are used to cause a computer to execute the method for querying service data according to claim 1 or 2.

6. A computer program product, characterized in that, Comprising computer instructions, the computer instructions are used to cause a computer to execute the method for querying service data according to claim 1 or 2.

Citation Information

Patent Citations

  • Query page generating device and method

    CN102541529A

  • Cross-data-source database view visualization construction method and system

    CN115422167A