Data processing method, device, electronic device and storage medium
By analyzing and merging the operation statements of database script files from the code repository of the business management system and generating the target script file, the problem of low efficiency of database table updates and upgrades in the business management system is solved, and faster and more accurate database table updates and upgrades are achieved.
Patent Information
- Application Number
- CN202311077722.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-24
- Publication Date
- 2025-08-29
- Estimated Expiration
- 2043-08-24
AI Technical Summary
In the business management system, as the insurance business volume increases, the efficiency of updating and upgrading database tables decreases, mainly due to the large number of merged script files and the presence of redundancy, resulting in an increase in execution time.
By obtaining script files from the code repository of the business management system, parsing and merging operation statements for the target business data table, generating the target script file, and running the file to update and upgrade the database table.
Improve the efficiency of updating and upgrading database tables, ensure the accuracy and simplicity of operation statements, reduce redundant operations, and improve the speed and accuracy of data processing.
Smart Images

Figure CN117076472B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing, and in particular to a data processing method, device, electronic device and storage medium. Background Art
[0002] With rising socioeconomic levels, more and more people are purchasing personal insurance, particularly health insurance. In business management systems like sales expense management systems, database table updates and upgrades are typically achieved by executing database scripts. Database scripts are often distributed across multiple script files. For convenience, these script files need to be merged into a single, integrated script file. This integrated script file can then be executed to update and upgrade database tables.
[0003] However, as the volume of insurance business increases, the number of script files that need to be merged in the business management system is very large, resulting in a very large number of scripts contained in the overall script file, and there may be redundant scripts, etc., which requires more time to execute the overall script file, thereby reducing the efficiency of updating and upgrading the database table. Summary of the Invention
[0004] The purpose of the embodiments of the present application is to provide a data processing method, device, electronic device and storage medium for solving the problem of reduced efficiency in updating and upgrading database tables in current business management systems.
[0005] In order to achieve the above objectives, the embodiments of the present application adopt the following technical solutions:
[0006] In a first aspect, an embodiment of the present application provides a data processing method, which is applied to a business management system, wherein the business management system includes an Informix database, and the method includes:
[0007] Obtaining a script file required to execute an update task on the database from a code repository of the business management system, the script file including operation statements for a business data table in the database, the business data table being used to record business data required to execute a target business;
[0008] Parsing the script file, and obtaining a target operation statement for a target business data table from the script file, where the target business data table is any business data table in the database;
[0009] The acquired target operation statements are merged to obtain a target script file corresponding to the target business data table, and the target script file is run to update the target business data table.
[0010] In a second aspect, an embodiment of the present application provides a data processing device applied to a business management system, wherein the business management system includes an Informix database, including:
[0011] an acquisition unit, configured to acquire, from a code repository of the business management system, a script file required for executing an update task on the database, the script file including operation statements for a business data table in the database, the business data table being used to record business data required for executing a target business;
[0012] The acquisition unit is further configured to parse the script file and acquire a target operation statement for a target business data table from the script file, where the target business data table is any business data table in the database;
[0013] The merging unit is used to merge the acquired target operation statements to obtain a target script file corresponding to the target business data table, and run the target script file to update the target business data table.
[0014] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the method described in the first aspect.
[0015] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to execute the method described in the first aspect.
[0016] At least one of the above-mentioned technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects: by obtaining the script file required to execute the update task on the database from the code repository of the business management system, parsing the script file, obtaining the target operation statement for the target business data table from the script file, and merging the obtained target operation statements, not only can the redundant operation statements in the script file be cleared, making the target script file more concise and intuitive, but also the merged target script file only contains the operation statements for the target business data table and these operation statements are concentrated together, avoiding the mutual influence caused by the long intervals between different operation statements, which is conducive to improving the update accuracy of the target business data table; further, by running the target script file, the update and upgrade of the target business data table in the database can be quickly and accurately realized; for each business data table in the database, the corresponding script text can be established and run in the above-mentioned manner, thereby improving the efficiency and accuracy of database table updates and upgrades in the business management system. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0018] Figure 1 A flowchart of a data processing method provided in one embodiment of the present application;
[0019] Figure 2 A schematic diagram of a structure of a target operation statement provided in one embodiment of the present application;
[0020] Figure 3 A schematic diagram of a structure for merging target operation statements provided in one embodiment of the present application;
[0021] Figure 4 A schematic diagram of a data processing flow for an application scenario of a data processing method provided in one embodiment of the present application;
[0022] Figure 5 A schematic structural diagram of a data processing device provided in accordance with an embodiment of the present application;
[0023] Figure 6 A schematic structural diagram of an electronic device provided in accordance with an embodiment of the present application. DETAILED DESCRIPTION
[0024] To make the purpose, technical solutions, and advantages of this application more clear, the technical solutions of this application will be clearly and completely described below in conjunction with the specific embodiments of this application and the corresponding drawings. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0025] The terms "first," "second," and the like in this specification and claims are used to distinguish similar objects and are not intended to describe a particular order or precedence. It should be understood that such terms are interchangeable, where appropriate, so that the embodiments of the present application may be implemented in an order other than that illustrated or described herein. Furthermore, the term "and / or" in this specification and claims refers to at least one of the connected objects, and the character " / " generally indicates that the connected objects are in an "or" relationship.
[0026] The following describes in detail the technical solutions provided by various embodiments of the present application in conjunction with the accompanying drawings.
[0027] See also Figure 1, is a flow chart of a data processing method provided in one embodiment of the present application. The data processing method provided in one embodiment of the present application is applied to a business management system, the business management system including an Informix database, and the method may include the following steps:
[0028] S102: Obtain a script file required for executing a database update task from a code repository of the business management system.
[0029] The business management system may include, but is not limited to, systems such as a sales expense management system and an insurance claims management system. The database within the business management system may include, but is not limited to, an Informix database. The database may contain multiple business data tables, which are used to record the business data required to execute the target business.
[0030] The target business may include, but is not limited to, insurance sales business, insurance claims business and other businesses. The business data required to execute different target businesses are different. For example, the data required to execute the insurance sales business include the time of the insurance event, the type of insurance, the insurance institution, the insurance sales channel, the salesperson, the user's location area, the user's age area, or the insurance payment method, the policy commission of the issuing officer and other data. Another example: the data required to execute the insurance claims business include the policy number, insurance product type, policyholder information, insured person information, time and place of the accident, cause of the accident, degree of injury, doctor's diagnosis report, medical expenses details, vehicle registration certificate, driving license, accident scene photos, repair report, insured person's bank account number, payment amount, payment method and other data.
[0031] It should be understood that a database is a system or software that stores structured data, equivalent to an electronic data storage warehouse, where large amounts of data are stored in a certain structure in the database's data tables. The Informix database, a relational database management system developed and maintained by Informix Software, an IBM subsidiary, supports multiple platforms and operating systems and provides high-performance data management and processing capabilities. For this reason, the embodiments of this application preferably use the Informix database, but specific configurations can also be made based on actual needs.
[0032] A script file is a text file containing operational statements written in a query language. These statements are used to perform operations on business data tables in a database. When performing database update tasks, such as adding, deleting, querying, or modifying data in a database's business data tables, the corresponding script file needs to be run. By executing the operational statements in the script file, data processing is performed to complete the database update and upgrade.
[0033] The present invention adopts the informix database, and the data specifically includes commonly used business data in the insurance industry, including: the time of occurrence of the insurance event, the insurance type, the insurance institution, the insurance sales channel, the salesperson, the user's location area, the user's age area, or the insurance payment method, the policy commission of the policy issuer, etc.
[0034] It should be understood that when the operation statement is written in the corresponding query language, the corresponding script file also has a corresponding file format. For example, common query languages include Structured Query Language (SQL), Not Only SQL (NoSQL), XML Query Language (XQuery), SPARQL Protocol and RDF Query Language (SPARQL), etc. Among them, SQL is the most widely used standard query language, particularly suitable for relational databases, and can provide powerful and universal functions, making it the preferred query language across platforms and database types. If the operation statement is written in SQL, the corresponding script file is an SQL file, which is a universal database script file format that can be executed on the database client and affect the database table structure. Based on this, the embodiment of the present application gives priority to using the SQL query language. Of course, in the actual application process of the embodiment of the present application, the method can also select a suitable query language to access and operate the database according to actual needs. The embodiment of the present application is not specifically limited to this.
[0035] Among them, the business management system may also include a code warehouse. In the embodiment of the present application, script files are usually stored in a code warehouse, which is a platform for centrally storing and managing source code. For example, common code warehouses include Git (Global Information Tracker), GitHub, GitLab, Bitbucket, etc., among which Git is an open source distributed version control system that can effectively and quickly handle version management of projects from very small to very large. Based on this, the embodiment of the present application gives priority to using Git. Of course, in the actual application process of the embodiment method of the present application, a suitable code warehouse platform can also be selected according to actual needs to store and manage source code, and the embodiment method of the present application does not specifically limit this.
[0036] It should be understood that when the embodiments of the present application obtain script files from the code repository of the business management system, a single script file or multiple script files may be used, and these script files are arranged in a certain order, such as the time order in which they were written. When the script files are run, they are also executed in the same order. The operation statements in any script file may target multiple business data tables, and the operation statements for the same business data table may not be in the same script file, but may be distributed across multiple script files.
[0037] S104: Parse the script file and obtain target operation statements for the target business data table from the script file.
[0038] The target business data table is any business data table in the database that needs to be updated and upgraded, and the target operation statement is an operation language for the target business data table.
[0039] When updating and upgrading the database, the business data table that needs to be updated and upgraded in the database is determined as the target business data table. By parsing the script file, the operation statements in the script file are parsed into operation statements that can be used for database updating and upgrading, and the target operation statements for the target business data table are obtained from the script file. The target business data table is processed through the target operation language, thereby realizing the update and upgrade of the database.
[0040] Specifically, the embodiment of the present application will provide a detailed description of the process of parsing a script file and obtaining target operation statements of a target business data table from the script file.
[0041] In an optional implementation, the above S104 may include the following steps:
[0042] S142: Divide the operation statements in the script file into multiple groups according to the delimiters in the script file.
[0043] S144 , searching each group of operation statements according to the table name of the target business data table to obtain at least one group of operation statements containing the table name.
[0044] S146: Use at least one group of operation statements containing the table name as target operation statements.
[0045] Among them, the delimiter is a symbol for dividing the operation statements in the embodiment of the present application, such as: ";". The operation statements are divided into multiple groups by the delimiter. The multiple groups here can be for a single script file, and the table name contained in each group of operation statements is the same. According to the table name of the target business data table, a group of operation statements with the same table name as the target business data table is searched from the multiple groups of operation statements and used as the target operation statements. The multiple groups here can also be for multiple script files, and the operation statements in each script file are divided by delimiters. The divided operation statements in each script file can be regarded as a group of operation statements. According to the table name of the target business data table, in each group of operation statements, the operation statements with the same table name as the target business data table are searched out, and the searched operation statements are used as a group of operation statements to obtain the target operation statements. For example, the following shows the content of the script file divided by the delimiter, i.e., ";", which contains 8 operation statements for table1, table2, and table3, i.e., operation statements for table 1, table 2, and table 3.
[0046] CREATE TABLE table2(columnA CHAR(8),columnB INT,columnC DATE);
[0047] ALTER TABLE table1 ADD columnD DECIMAL(8,6);
[0048] ALTER TABLE table2 DROP columnB;
[0049] Insert into table1 values('a',current,10);
[0050] Insert into table2 values('b',current,20);
[0051] Create unique index table2idx1 on table2(columnAASC);
[0052] Delete from table3 where columnA'a';
[0053] ALTER TABLE table3 RENAME tableY;
[0054] For example: Figure 2 As shown, assuming that the script files obtained from the code repository are 0001.sql~9999.sql, Table 2 is determined as the target business data table, and after division, the operation statements containing Table 2 exist in the script files 0002.sql, 0003.sql, 9997.sql, and 9999.sql, then the operation statements containing Table 2 are found and saved in the TBALE2.sql file, that is, the target operation statements for the target business data table are obtained.
[0055] The embodiment of the present application divides the script in the script file into multiple operation statements for different business data tables by using delimiters, and searches the script file for an operation statement with the same table name as the target business data table according to the table name of the business data table contained in each operation statement, so as to serve as the target operation statement for the target business data table. The target operation statement can then be used to process data on the target business data table, thereby avoiding the need to run a large number of script files and execute a large number of operation statements in the script files to process data on the target business data table during database updates and upgrades, thereby saving the time for running the script files and executing the operation statements, and thus improving the efficiency of business data processing.
[0056] S106 , merging the acquired target operation statements to obtain a target script file corresponding to the target business data table, and running the target script file to update the target business data table.
[0057] The target script file is a text file that processes data for the target business data table. By merging the acquired target operation statements, a target script file corresponding to the target business data table is obtained. By running the target script file, the target business data table is updated to update and upgrade the database.
[0058] The embodiment of the present application obtains the script file required for executing the update task on the database from the code repository of the business management system, parses the script file, obtains the target operation statement for the target business data table from the script file, and merges the obtained target operation statement. This not only removes the redundant operation statements in the script file, making the target script file more concise and intuitive, but also makes the merged target script file contain only the operation statements for the target business data table and these operation statements are concentrated together, avoiding the mutual influence caused by the long distance between different operation statements, thereby facilitating the improvement of the update accuracy of the target business data table; further, by running the target script file, the update and upgrade of the target business data table in the database can be achieved quickly and accurately; for each business data table in the database, the corresponding script text can be established and run in the above manner, thereby improving the efficiency and accuracy of the update and upgrade of the database table in the business management system. Specifically, the embodiment of the present application will explain in detail the process of merging the obtained target operation statements to obtain the target script file corresponding to the target business data table.
[0059] In an optional implementation, the above S106 may include the following steps:
[0060] S162: Determine the execution order of the target operation statements in the script file.
[0061] S164: Based on the execution order and the operation information of the target operation statements, the target operation statements are merged to obtain a target script file.
[0062] Wherein, execution order refers to the order in which the operation statements are executed when the script file is run. Generally, the operation statement at the front of the script file will be executed first. To determine the execution order of the operation language, common technical means can be used to confirm, such as: by scanning the script file, starting from the operation statement at the front of the script file, using a separator as a boundary, marking each operation statement to distinguish the order between each operation statement. Of course, a more convenient way can also be used to confirm according to actual conditions, and the embodiments of the present application do not specifically limit this.
[0063] The operation information is the relevant information of the target business data table targeted when the operation statement is executed, including the table name of the target business data table, the relevant data in the target business data table, and other information.
[0064] The embodiment of the present application confirms the execution order of the target operation statements in the text file to ensure the validity of the target operation statement merging, merges the target operation statements according to the execution order and operation information of the target operation statements, and saves the merged operation statements in the SQL file, that is, obtains the target script file.
[0065] Optionally, the merging of target operation statements based on the execution order and the operation information executed by the target operation statements may include the following steps:
[0066] Determine the priority of the target operation statement according to the preset priority configuration information;
[0067] The target operation statements are merged based on their priorities, execution order, and operation information.
[0068] The priority configuration information includes priorities corresponding to various operation statements. The priorities corresponding to different operation statements have corresponding level values. The larger the priority level value, the higher the priority of the operation statement, or the smaller the priority level value, the lower the priority of the operation statement. For example, the priority configuration information shown in Table 1 is preset so that the larger the priority level value, the higher the priority of the operation statement. For example, the second and fifth rows in the table are used as an example. The priority level value of the operation statement CREATE TABLE in the first row is 1, while the priority level value of the operation statement CREATE*INDEX in the fifth row is 3, which is higher than the priority level value of CREATE TABLE. Therefore, the priority of the operation statement CREATE*INDEX is higher. The operation statement CREATE TABLE in Table 1 is used to create a data table; INSERT is used to insert a field into a data table; DELETE is used to delete a field in a data table or delete any operation statement before the operation statement; CREATE*INDEX is used to create an index; ALTER*ADD is used to add fields, records, etc.; ALTER*DROP is used to delete fields, indexes, records, etc.; and DROP TABLE* is used to delete a data table. It should be understood that Table 1 only lists several common SQL operation statements.
[0069] It should be understood that the priority of the operation statement is a pre-set merging rule. In actual application, it can be preset accordingly based on actual needs and convenience. The embodiment of the present application does not specifically limit this. In addition, the above examples are intended to illustrate the priority relationship corresponding to various operation statements and should not be understood as limiting the embodiment of the present application.
[0070] Table 1 Priority configuration information
[0071] Operation Statement Priority CREATE TABLE 1 INSERT 2 DELETE 2 CREATE *INDEX 3 ALTER *ADD 3 ALTER * DROP 4 DROP TABLE * 4 … …
[0072] The embodiment of the present application presets corresponding priorities for the operation statements to facilitate priority comparison of the operation statements to achieve a merging effect, such as an operation statement with a high priority at a later position can affect or eliminate an operation statement with a low priority at a previous position.
[0073] Optionally, the above-mentioned merging of target operation statements based on the priority, execution order, and operation information of the target operation statements may include the following steps: repeatedly performing the following merging operation on the acquired target operation statements in the execution order until the acquired target operation statements are completely merged:
[0074] According to the priority and operation information of the i-th target operation statement and the priority and operation information of the i+1-th target operation statement, the i-th target operation statement and the i+1-th target operation statement are merged, and the merged operation statement is used as the new i+1-th target operation statement, where i is a positive integer.
[0075] Optionally, when the priority of the (i+1)th target operation statement is higher than the priority of the (i)th target operation statement, merging the (i+1)th target operation statement with the (i+1)th target operation statement according to the priority and operation information of the (i)th target operation statement and the priority and operation information of the (i+1)th target operation statement may include the following steps:
[0076] If the i-th target operation statement is used to create a data table and the i+1-th target operation statement is used to delete or add fields in the data table created by the i-th target operation statement, then according to the fields operated by the i+1-th target operation statement, the fields of the data table created by the i-th target operation statement are updated, and the i+1-th target operation statement is deleted; or,
[0077] If the i-th target operation statement is used to create a data table, and the i+1-th target operation statement is used to insert records or add indexes to the data table created by the i-th target operation statement, then the fields operated by the i+1-th target operation statement are concatenated with the i-th target operation statement; or,
[0078] If the i-th target operation statement and the i+1-th target operation statement perform opposite operations, and the i-th object set is the same as the i+1-th object set, then delete the i-th target operation statement and the i+1-th target operation statement; or,
[0079] If the i-th target operation statement and the i+1-th target operation statement perform opposite operations, and the i+1-th object set is part of the i-th object set, then the i-th object set is updated to the difference between the i-th object set and the i+1-th object set, and the i+1-th target operation statement is deleted; or,
[0080] If the i-th target operation statement and the i+1-th target operation statement perform opposite operations, and the i-th object set is part of the i+1-th object set, then the i+1-th object set is updated to the difference between the i-th object set and the i+1-th object set, and the i-th target operation statement is deleted; or,
[0081] If the i-th target operation statement and the i+1-th target operation statement perform opposite operations, and the i-th object set partially overlaps with the i+1-th object set, then obtain the intersection of the i-th object set and the i+1-th object set, use the difference between the i-th object set and the intersection as the new i-th object set, and use the difference between the i+1-th object set and the intersection as the new i+1-th object set;
[0082] Among them, the i-th object set contains the objects operated by the i-th target operation statement, and the i+1-th object set contains the objects operated by the i+1-th target operation statement.
[0083] The operation information of the target operation statement includes the field operated by the target operation statement.
[0084] It should be understood that in the embodiments of the present application, an object set includes at least fields, records, and indexes. A field is the content of a table header in a data table; a record is the data record in a data table, corresponding to the table header, and includes the data in each row, excluding the table header; an index is like a table of contents in a book, allowing for quick location of a specific item in a data table and facilitating data query.
[0085] In order to more clearly understand the embodiment method of the present application, a specific example will be given here to illustrate how to merge the i-th target operation statement and the i+1-th target operation statement based on the difference between the i-th object set and the i+1-th object set when the operations performed by the i-th target operation statement and the i+1-th target operation statement are opposite. This should not be understood as a limitation of the embodiment method of the present application.
[0086] Example: Assume that the i-th target operation statement is used to delete a field in the created data table, and the i+1-th target operation statement is used to add a field in the same data table. If the i-th target operation statement and the i+1-th target operation statement perform opposite operations, for example, the i+1-th object set contains field B, the i-th object set contains fields A and B, and the i+1-th object set is part of the i-th object set, then the field added by the i+1-th target operation statement is one of the fields deleted by the i-th target operation statement, then the i-th object set needs to be Update to the difference between the i-th object set and the i+1-th object set, that is, after the update, the field contained in the i-th object set is A, and the i+1-th target operation statement is deleted. The updated i-th target operation statement is used as the new i+1-th statement. In this way, when running the target script file, when executing the new i+1-th target operation statement, field A is deleted in the corresponding data table, and the effect of executing the original i-th target operation statement and i+1-th target operation statement can be achieved, thereby reducing the running time of the target script file and improving data processing efficiency; or
[0087] Assuming that the i-th target operation statement is used to delete a field in the created data table, and the i+1-th target operation statement is used to add a field in the same data table, then if the i-th target operation statement and the i+1-th target operation statement perform opposite operations, assuming that the i+1-th object set contains fields A and B, the i-th object set contains field A, and the i-th object set is part of the i+1-th object set, then the field deleted by the i-th target operation statement is one of the fields added by the i+1-th target operation statement, then the i+1-th object set needs to be updated to the difference between the i-th object set and the i+1-th object set, that is, the field contained in the i+1-th object set after the update is B, and the i-th target operation statement is deleted. In this way, when the target script file is run, when the updated i+1-th target operation statement is executed, field B can be added to the corresponding data table; or,
[0088] Assume that the i-th target operation statement is used to delete a field in the created data table, and the i+1-th target operation statement is used to add a field in the same data table. If the i-th and i+1-th target operation statements perform opposite operations, and the i+1-th object set contains fields B and C, and the i-th object set contains fields A and B, and the i-th and i+1-th object sets partially overlap, meaning both contain field B, and their intersection is B, then the difference between the i-th object set and the intersection, A, needs to be used as the new i-th object set, and the difference between the i+1-th object set and the intersection, C, needs to be used as the new i+1-th object set. This way, when the target script file is run, the number of fields deleted and added correspondingly when the updated i-th and i+1-th target operation statements are executed is reduced, thereby improving data processing efficiency.
[0089] The embodiment of the present application merges the i-th and i+1-th target operation statements according to the execution order of the target operation statements until all the target operation statements are merged. It can be seen intuitively from the above example that the number of merged operation statements is reduced as a whole, and redundant scripts are removed. When running the target script file later and executing the operation statements in the target script file, the running time can be reduced to improve data processing efficiency.
[0090] In order to more clearly understand the process of merging target operation statements in the embodiment method of the present application, specific SQL operation statements will be used for illustration here, which should not be understood as a limitation on the embodiment method of the present application.
[0091] For example Figure 3 As shown in the figure, assume that the script file where the target operation statements corresponding to the target business data table 2 are located is TABLE2.sql. The target operation statements include table creation statements, adding field statements, reducing field statements, inserting data statements, adding index statements, deleting data names, modifying name statements, etc. Among them, the statements at the front are table creation statements, followed by adding field statements, and they are executed in order from top to bottom. First, the table creation statement: CREATE TABLE table2(
[0092] columnACHAR(8),
[0093] columnB INT,
[0094] columnC DATE
[0095] ); and add a column statement: ALTER TABLE table2 ADD columnD DECIMAL (8, 6); after merging, the operation statement is: CREATE TABLE table2 (
[0096] columnACHAR(8),
[0097] columnB INT,
[0098] columnC DATE
[0099] columnD DECIMAL(8,6)
[0100] ); By comparing before and after the merger, it can be seen that the field content after ADD in the add field statement, that is, columnDDECIMAL(8,6), is added to the table created by the table creation statement, and the add field statement is deleted, and the merged statement is used as the i+1th target operation statement. In order to distinguish the operation statements obtained by each merger, the new i+1th target operation statement is referred to as merge statement 1 here to distinguish it from the subsequent merged operation statements. This should not be understood as a limitation of the method of the embodiment of the present application, and the following description process will not repeat this content;
[0101] Then merge the merge statement 1 with the reduce field statement: ALTER TABLE table2 DROP columnB; and delete the field from the data table according to the field content after DROP in the reduce field statement, that is, columnB, to obtain the merged target operation statement, that is, merge statement 2: CREATE TABLE table2(
[0102] columnA CHAR(8),
[0103] columnC DATE
[0104] columnD DECIMAL(8,6)
[0105] ); then merge statement 2 with the insert data statement: Insert into table2 values('a', current, 10);
[0106] Insert into table2 values('b', current, 20); splice to get merge statement 3: CREATE TABLE table2(
[0107] columnA CHAR(8),
[0108] columnC DATE
[0109] columnD DECIMAL(8,6) );
[0111] Insert into table2 values('a', current, 10);
[0112] Insert into table2 values('b', current, 20); Combine statement 3 with the add index statement: Create unique index table2idx1 on table2(
[0113] columnA ASC
[0114] ); splice to get merge statement 4: CREATE TABLE table2(
[0115] columnA CHAR(8),
[0116] columnC DATE
[0117] columnD DECIMAL(8,6) );
[0119] Insert into table2 values('a', current, 10);
[0120] Insert into table2 values('b', current; 20);
[0121] Create unique index table2idx1 on table2(
[0122] columnA ASC
[0123] ); Merge statement 4 with the delete data statement: Delete from table2 where columnA='a';. According to the field content in the delete data statement, that is, columnA='a', the operation statement is deleted from merge statement 4, and merge statement 5 is obtained: CREATE TABLE table2(
[0124] columnA CHAR(8),
[0125] columnC DATE
[0126] columnD DECIMAL(8,6) );
[0128] Insert into table2 values('b', current, 20);
[0129] Create unique index table2idx1 on table2(
[0130] columnA ASC
[0131] ); Merge statement 5 with the name modification statement: ALTER TABLE table2 RENAME tableY; and modify the table name table2 in merge statement 5 to tableY, obtaining merge statement 6: CREATE TABLE tableY(
[0132] columnA CHAR(8),
[0133] columnC DATE
[0134] columnD DECIMAL(8,6) );
[0136] Insert into tableY values('b', current, 20);
[0137] Create unique index tableYidx1 on tableY(
[0138] columnA ASC
[0139] ); If there are target operation statements, and so on, until the embodiment of the present application completes the merging of the target operation statements in the TABLE2.sql file.
[0140] The embodiment of the present application merges target operation statements in sequence according to their execution order, which can effectively eliminate redundant target operation statements to improve data processing efficiency.
[0141] As another embodiment of the present application, obtaining a script file required to perform an update task on a database from a code repository of a business management system may include the following steps: receiving a data processing request, the data processing request carrying code repository path information;
[0142] According to the code repository path information and the task information of the update task, the script file required to execute the update task on the database is obtained from the code repository through the specified interface component.
[0143] The data processing request also carries task information of the update task, including the name of the database and data table that need to be updated and upgraded.
[0144] The designated interface component is pre-developed based on the code repository being used. For example, when using a Git code repository, a corresponding API interface can be developed using a programming language such as Java. Through this developed API interface, the Git code repository can be accessed using the open-source Java language. The script file required to execute the database update task can then be retrieved from the code repository of the business management system based on the code repository path information and the task information of the update task.
[0145] The embodiment of the present application receives a data processing request, obtains a script file for executing the update task on the database from the code repository of the business management system through a specified interface component according to the code repository path information and update task information carried in the data processing request, thereby improving the reliability of database updates and upgrades and the validity of data.
[0146] The data processing method provided in the embodiment of the present application is described below using an actual application scenario, which should not be understood as a limitation on the method in the embodiment of the present application. Figure 4 A data processing flow diagram of an application scenario of a data processing method provided in an embodiment of the present application. Figure 4 The following figure shows an application scenario for database updates and upgrades in a sales expense management system. In this application scenario, first, the GIT code repository path and other information carried in the received data processing request is input into the sales expense management system. Script files 0001.sql to 9999.sql are obtained from the code repository and downloaded locally. The operation statements in each script file are split and grouped according to the business data tables TABLE1 to TABLE50 (i.e., the target business data tables) they operate on, using the delimiters in the script files. This results in SQL files corresponding to each target business data table, i.e., TABLE1.sql to TABLE50.sql. For each target business data table, the operation statements in the SQL file, i.e., the target operation statements, are merged to obtain the table1.sql to table50.sql files corresponding to each target business data table, i.e., the target script files. Finally, the target script files corresponding to each target business data table are merged to obtain the Upgrade.sql file. The Upgrade.sql file is then executed to update the target business data table, thereby updating and upgrading the database.
[0147] It should be understood that in the above application scenario, multiple script files are obtained from the code repository and multiple business data tables are updated, that is, there are multiple target business data tables. Finally, according to the file order of table1.sql to table50.sql, the operation statements for all target business data tables are concentrated in the Upgrade.sql file, and then the database is updated and upgraded by running the Upgrade.sql file.
[0148] The foregoing description of this specification describes specific embodiments. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that described in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order shown or the sequential order to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0149] With the above Figure 1 Corresponding to the data processing method shown, the present application embodiment also proposes a data processing device. Figure 5 , is a structural diagram of a data processing device 500 provided in one embodiment of the present application. Figure 5 As shown, the data processing device 500 is applied to a business management system, and the business management system includes an Informix database. The business processing device 500 includes:
[0150] An acquisition unit 510 is configured to acquire, from a code repository of the business management system, a script file required for executing an update task on the database, wherein the script file includes operation statements for a business data table in the database, wherein the business data table is used to record business data required for executing a business;
[0151] The acquisition unit 510 is further configured to parse the script file and acquire a target operation statement for a target business data table from the script file, where the target business data table is any business data table in the database;
[0152] The merging unit 520 is configured to merge the acquired target operation statements to obtain a target script file corresponding to the target business data table, and run the target script file to update the target business data table.
[0153] Optionally, when parsing the script file and obtaining target operation statements for the target business data table from the script file, the obtaining unit 510 may perform the following steps: dividing the operation statements in the script file into multiple groups according to delimiters in the script file;
[0154] Searching each group of operation statements according to the table name of the target business data table to obtain at least one group of operation statements containing the table name;
[0155] At least one group of operation statements containing the table name is used as the target operation statements.
[0156] Optionally, when merging the acquired target operation statements to obtain the target script file corresponding to the target business data table, the merging unit 520 may perform the following steps: determining the execution order of the target operation statements in the script file;
[0157] Based on the execution order and the operation information executed by the target operation statements, the target operation statements are merged to obtain the target script file.
[0158] Optionally, when merging the target operation statements based on the execution order and the operation information of the target operation statements, the merging unit 520 may perform the following steps: determining the priority of the target operation statement according to preset priority configuration information, the priority configuration information including priorities corresponding to multiple operation statements;
[0159] The target operation statements are merged based on the priorities of the target operation statements, the execution order, and the operation information.
[0160] Optionally, when merging the target operation statements based on the priority of the target operation statements, the execution order, and the operation information, the merging unit 520 may perform the following steps: repeatedly performing the following merging operation on the acquired target operation statements in the execution order until the acquired target operation statements are completely merged:
[0161] According to the priority and operation information of the i-th target operation statement and the priority and operation information of the i+1-th target operation statement, the i-th target operation statement and the i+1-th target operation statement are merged, and the merged operation statement is used as the new i+1-th target operation statement, where i is a positive integer.
[0162] Optionally, when the priority of the (i+1)th target operation statement is higher than the priority of the (i)th target operation statement, the merging unit 520 may perform the following steps when merging the (i+1)th target operation statement and the (i+1)th target operation statement based on the priority and operation information of the (i)th target operation statement and the priority and operation information of the (i+1)th target operation statement:
[0163] If the i-th target operation statement is used to create a data table and the i+1-th target operation statement is used to delete or add fields in the data table created by the i-th target operation statement, then according to the fields operated by the i+1-th target operation statement, the fields of the data table created by the i-th target operation statement are updated, and the i+1-th target operation statement is deleted; or
[0164] If the i-th target operation statement is used to create a data table and the i+1-th target operation statement is used to insert a record or add an index to the data table created by the i-th target operation statement, then the field operated by the i+1-th target operation statement is concatenated with the i-th target operation statement; or
[0165] If the operations performed by the i-th target operation statement and the i+1-th target operation statement are opposite, and the i-th object set is the same as the i+1-th object set, then delete the i-th target operation statement and the i+1-th target operation statement; or,
[0166] If the operations performed by the i-th target operation statement and the i+1-th target operation statement are opposite, and the i+1-th object set is part of the i-th object set, then the i-th object set is updated to the difference between the i-th object set and the i+1-th object set, and the i+1-th target operation statement is deleted; or
[0167] If the i-th target operation statement and the i+1-th target operation statement respectively perform opposite operations, and the i-th object set is part of the i+1-th object set, then the i+1-th object set is updated to the difference between the i-th object set and the i+1-th object set, and the i-th target operation statement is deleted; or,
[0168] If the i-th target operation statement and the i+1-th target operation statement respectively perform opposite operations, and the i-th object set partially overlaps with the i+1-th object set, obtaining the intersection of the i-th object set and the i+1-th object set, taking the difference between the i-th object set and the intersection as a new i-th object set, and taking the difference between the i+1-th object set and the intersection as a new i+1-th object set;
[0169] The i-th object set includes objects operated by the i-th target operation statement, and the i+1-th object set includes objects operated by the i+1-th target operation statement.
[0170] Optionally, when acquiring the script file required to execute the update task on the database from the code repository of the business management system, the acquiring unit 510 may perform the following steps: receiving a data processing request, the data processing request carrying the code repository path information;
[0171] According to the code repository path information and the task information of the update task, a script file required for executing the update task on the database is acquired from the code repository through a designated interface component.
[0172] Obviously, the data processing device provided in the embodiment of the present application can be used as Figure 1 The execution subject of the data processing method shown is, for example Figure 1 In the data processing method shown, step S102 can be performed by Figure 5 The acquisition unit 510 in the data processing device shown in FIG. 1 is executed, and step S104 can be performed by Figure 5 The acquisition unit 510 in the data processing device shown in FIG. 1 is executed, and step S106 can be performed by Figure 5 The merging unit 520 in the data processing apparatus shown is executed.
[0173] According to another embodiment of the present application, Figure 5 The various units in the data processing apparatus shown can be separately or all combined into one or several other units to constitute, or one (some) of the units can also be split into multiple smaller units in function to constitute, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application. The above-mentioned units are divided based on logical functions. In practical applications, the functions of a unit can also be implemented by multiple units, or the functions of multiple units can be implemented by one unit. In other embodiments of the present application, the data processing apparatus may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented by the collaboration of multiple units.
[0174] According to another embodiment of the present application, the program can be executed on a general computing device such as a computer including a central processing unit (CPU), a random access memory (RAM), a read-only memory (ROM), and other processing elements and storage elements. Figure 1 A computer program (including program code) for each step of the corresponding method shown in FIG. Figure 5The data processing device shown in and the data processing method of the embodiment of the present application are implemented. The computer program can be recorded on, for example, a computer-readable storage medium, and transferred to an electronic device through the computer-readable storage medium and run therein.
[0175] Figure 6 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. Figure 6 This electronic device is used in a business management system that includes an Informix database. At the hardware level, the electronic device includes a processor and, optionally, an internal bus, a network interface, and memory. The memory may include internal memory, such as high-speed random-access memory (RAM), or non-volatile memory, such as at least one disk drive. Of course, the electronic device may also include other hardware required for the business.
[0176] The processor, network interface, and memory can be interconnected via an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or one type of bus.
[0177] The memory is used to store programs. Specifically, the program may include program code, which includes computer operating instructions. The memory may include internal memory and non-volatile memory, and provides instructions and data to the processor.
[0178] The processor reads the corresponding computer program from the non-volatile memory into the internal memory and then runs it, forming a data processing device at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations:
[0179] Obtaining a script file required to execute an update task on the database from a code repository of the business management system, the script file including operation statements for a business data table in the database, the business data table being used to record business data required to execute a target business;
[0180] Parsing the script file, and obtaining a target operation statement for a target business data table from the script file, where the target business data table is any business data table in the database;
[0181] The acquired target operation statements are merged to obtain a target script file corresponding to the target business data table, and the target script file is run to update the target business data table.
[0182] The above application Figure 5 The methods performed by the data processing device disclosed in the illustrated embodiments can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by hardware integrated logic circuits in the processor or by software instructions. The above processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The various methods, steps, and logic block diagrams disclosed in the embodiments of this application can be implemented or executed. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in conjunction with the embodiments of this application can be directly implemented and executed by a hardware decoding processor, or by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium well-known in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. The storage medium is located in the memory, and the processor reads the information in the memory and, in conjunction with its hardware, completes the steps of the above method.
[0183] The electronic device may also perform Figure 1 Method, and realize the data processing device in Figure 1 、 Figure 5 The functions of the illustrated embodiment will not be described in detail in the embodiments of the present application.
[0184] Of course, in addition to software implementation, the electronic device of this application does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc. That is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0185] The embodiment of the present application also proposes a computer-readable storage medium, which is applied to a business management system, wherein the business management system includes an informix database, and the computer-readable storage medium stores one or more programs, wherein the one or more programs include instructions, which, when executed by a portable electronic device including multiple application programs, can enable the portable electronic device to execute Figure 1 The method of the embodiment shown is specifically used to perform the following operations:
[0186] Obtaining a script file required to execute an update task on the database from a code repository of the business management system, the script file including operation statements for a business data table in the database, the business data table being used to record business data required to execute a target business;
[0187] Parsing the script file, and obtaining a target operation statement for a target business data table from the script file, where the target business data table is any business data table in the database;
[0188] The acquired target operation statements are merged to obtain a target script file corresponding to the target business data table, and the target script file is run to update the target business data table.
[0189] In short, the above description is only a preferred embodiment of the present application and is not intended to limit the scope of protection of the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
[0190] The systems, devices, modules, or units described in the above embodiments may be implemented by computer chips or entities, or by products having certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0191] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0192] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
[0193] The various embodiments in this specification are described in a progressive manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the system embodiments are generally similar to the method embodiments, so the description is relatively simple. For relevant parts, refer to the description of the method embodiments.
Claims
1. A data processing method, applied to a business management system, characterized in that: The business management system includes an Informix database, and the method includes: Obtaining a script file required to execute an update task on the database from a code repository of the business management system, the script file including operation statements for a business data table in the database, the business data table being used to record business data required to execute a target business; Parsing the script file, and obtaining a target operation statement for a target business data table from the script file, where the target business data table is any business data table in the database; Merging the acquired target operation statements to obtain a target script file corresponding to the target business data table, and running the target script file to update the target business data table; The step of merging the acquired target operation statements to obtain a target script file corresponding to the target business data table includes: Determining the execution order of the target operation statements in the script file; Determining the priority of the target operation statement according to preset priority configuration information, wherein the priority configuration information includes priorities corresponding to multiple operation statements; Repeat the following merging operation on the acquired target operation statements in the execution order until the acquired target operation statements are merged: merge the i-th target operation statement and the i+1-th target operation statement according to the priority and operation information of the i-th target operation statement and the priority and operation information of the i+1-th target operation statement, and use the merged operation statement as the new i+1-th target operation statement, where i is a positive integer.
2. The method according to claim 1, characterized in that The step of parsing the script file and obtaining a target operation statement for a target business data table from the script file includes: Dividing the operation statements in the script file into multiple groups according to the delimiters in the script file; Searching each group of operation statements according to the table name of the target business data table to obtain at least one group of operation statements containing the table name; At least one group of operation statements containing the table name is used as the target operation statements.
3. The method according to claim 1, characterized in that In a case where the priority of the (i+1)th target operation statement is higher than the priority of the (i)th target operation statement, merging the (i+1)th target operation statement with the (i+1)th target operation statement according to the priority and operation information of the (i)th target operation statement and the priority and operation information of the (i+1)th target operation statement includes: If the i-th target operation statement is used to create a data table and the i+1-th target operation statement is used to delete or add fields in the data table created by the i-th target operation statement, then according to the fields operated by the i+1-th target operation statement, the fields of the data table created by the i-th target operation statement are updated, and the i+1-th target operation statement is deleted; or If the i-th target operation statement is used to create a data table and the i+1-th target operation statement is used to insert a record or add an index to the data table created by the i-th target operation statement, then the field operated by the i+1-th target operation statement is concatenated with the i-th target operation statement; or If the operations performed by the i-th target operation statement and the i+1-th target operation statement are opposite, and the i-th object set is the same as the i+1-th object set, then delete the i-th target operation statement and the i+1-th target operation statement; or, If the operations performed by the i-th target operation statement and the i+1-th target operation statement are opposite, and the i+1-th object set is part of the i-th object set, then the i-th object set is updated to the difference between the i-th object set and the i+1-th object set, and the i+1-th target operation statement is deleted; or If the i-th target operation statement and the i+1-th target operation statement respectively perform opposite operations, and the i-th object set is part of the i+1-th object set, then the i+1-th object set is updated to the difference between the i-th object set and the i+1-th object set, and the i-th target operation statement is deleted; or, If the i-th target operation statement and the i+1-th target operation statement respectively perform opposite operations, and the i-th object set partially overlaps with the i+1-th object set, obtaining the intersection of the i-th object set and the i+1-th object set, taking the difference between the i-th object set and the intersection as a new i-th object set, and taking the difference between the i+1-th object set and the intersection as a new i+1-th object set; The i-th object set includes objects operated by the i-th target operation statement, and the i+1-th object set includes objects operated by the i+1-th target operation statement.
4. The method according to any one of claims 1 to 3, characterized in that The step of obtaining the script file required for executing the update task on the database from the code repository of the business management system includes: receiving a data processing request, wherein the data processing request carries the code repository path information; According to the code repository path information and the task information of the update task, a script file required for executing the update task on the database is acquired from the code repository through a designated interface component.
5. A data processing device, applied to a business management system, characterized in that: The business management system includes an informix database, including: an acquisition unit, configured to acquire, from a code repository of the business management system, a script file required for executing an update task on the database, the script file including operation statements for a business data table in the database, the business data table being used to record business data required for executing a target business; The acquisition unit is further configured to parse the script file and acquire a target operation statement for a target business data table from the script file, where the target business data table is any business data table in the database; a merging unit, configured to merge the acquired target operation statements to obtain a target script file corresponding to the target business data table, and run the target script file to update the target business data table; The merging unit performs the following steps when merging the acquired target operation statements to obtain the target script file corresponding to the target business data table: Determining the execution order of the target operation statements in the script file; Determining the priority of the target operation statement according to preset priority configuration information, wherein the priority configuration information includes priorities corresponding to multiple operation statements; Repeat the following merging operation on the acquired target operation statements in the execution order until the acquired target operation statements are merged: merge the i-th target operation statement and the i+1-th target operation statement according to the priority and operation information of the i-th target operation statement and the priority and operation information of the i+1-th target operation statement, and use the merged operation statement as the new i+1-th target operation statement, where i is a positive integer.
6. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the method according to any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Report query method and system based on SQL statement
CN114238380A
Data acquisition method and device based on SQL statement integration, equipment and medium
CN114691714A