CN103744891A - Method and system for data query - Google Patents

Method and system for data query Download PDF

Info

Publication number
CN103744891A
CN103744891A CN201310718464.1A CN201310718464A CN103744891A CN 103744891 A CN103744891 A CN 103744891A CN 201310718464 A CN201310718464 A CN 201310718464A CN 103744891 A CN103744891 A CN 103744891A
Authority
CN
China
Prior art keywords
query
querying condition
parameter
argument
sql
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201310718464.1A
Other languages
Chinese (zh)
Other versions
CN103744891B (en
Inventor
赵守来
赵雨佳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Datang Software Technologies Co Ltd
Original Assignee
Datang Software Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Datang Software Technologies Co Ltd filed Critical Datang Software Technologies Co Ltd
Priority to CN201310718464.1A priority Critical patent/CN103744891B/en
Publication of CN103744891A publication Critical patent/CN103744891A/en
Application granted granted Critical
Publication of CN103744891B publication Critical patent/CN103744891B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Mathematical Physics (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a method and system for data query to solve the problem of difficulty and low efficiency in existing data query. The method comprises the steps of receiving data query requirements, and enabling the data query requirements to carry query parameters; matching a preset structured query language (SQL) according to the query parameters; adopting a regular expressions to replace the structured query language (SQL), and generating an engine parameter for inquiring the query parameters; and sending the engine parameter to a report engine so as to obtain query data results. The engine parameter can be automatically generated for all query conditions of the requirements to perform query, and the method and system for data query are convenient to use and high in query efficiency.

Description

A kind of data enquire method and system
Technical field
The present invention relates to technical field of data processing, particularly relate to a kind of data enquire method and system.
Background technology
JasperReport is powerful a, report-building tool flexibly, can show abundant content of pages, and to portable document format (the Portable Document Format of converting, PDF), HTML (Hypertext Markup Language) (Hyper Text Mark-up Language, HTML) form, or extend markup language (Extensible Markup Language, XML) form.This storehouse is write as by Java completely, can, at various java applications, comprise Java 2 Platform Enterprise Edition (Java2Platform Enterprise Edition, J2EE), in internet (Web) application program, generates dynamic content.
JasperReport increases income, also has a relevant engineering IReport that increases income, this is a patterned aid, because spendable class libraries is only provided JasperReport, does not provide better developing instrument, and the appearance of IReport has solved this difficult problem.They are used in conjunction with and will raise the efficiency greatly.
JasperReport can be used as and builds table engine, and parameter (Parameters) is the object reference that passes to form filling operation, and parameter Main Function is passed to Report Engine in the data that those can not be obtained from report data source.For example, the user name of carrying out form filling process is passed to Report Engine, if allow user name be presented on form or at the title (title) of form, above change dynamically user name, it can be passed to Report Engine at form with parameter.
But, JasperReport in Structured Query Language (SQL) (Structured Query Language, SQL) statement, only provide two kinds of parameter P{} and { }, and Report Engine first process $ P! { } parameter is quoted, by obtaining most important SQL query by their value, when resolve { } afterwards, Report Engine just can be quoted remaining common $ P{} parameter to pass to General Parameters, and Report Engine can be carried out nested query.
Due to needs according to $ P{} or $ P! { } parameter could be carried out data query by JsperReport, therefore SQL statement is formed to above-mentioned parameter form more loaded down with trivial details, often only can unconditionally inquire about, if carry out condition query, also only need to adopt multiple parameters to carry out simple condition query, use very inconveniently, and affect search efficiency.
Summary of the invention
The invention provides a kind of data enquire method and system, to solve in available data inquiry, inquire about difficulty and the lower problem of efficiency.
In order to address the above problem, the embodiment of the invention discloses a kind of data enquire method, comprising:
Receive data query request, in described data query request, carry query argument;
According to described query argument, mate preset structured query sentence SQL;
Adopt regular expression to replace described structured query sentence SQL, generate the engine parameters of a described query argument of inquiry;
Send to Report Engine to obtain the data result of inquiry described engine parameters.
In optional embodiment of the present invention, the described query argument of described foundation mates preset structured query sentence SQL, comprising: from described query argument, obtain at least one statement parameter; Respectively each described statement parameter is mated, determine the structured query sentence SQL to parameter name is inquired about in described query argument.
In optional embodiment of the present invention, described employing regular expression is replaced described structured query sentence SQL, the engine parameters of query argument described in generated query, comprise: adopt regular expression to obtain the querying condition in described structured query sentence SQL, and according to parameter name and parameter value in described query argument, described querying condition is replaced; According to the querying condition after replacing, generate the engine parameters of a described query argument of inquiry.
In optional embodiment of the present invention, described employing regular expression obtains the querying condition in described structured query sentence SQL, and according to parameter name and parameter value in described query argument, described querying condition is replaced, comprise: adopt regular expression to mate the form of each described structured query sentence SQL, from described structured query sentence SQL, obtain querying condition respectively; Determine the parameter name that described structured query sentence SQL will inquire about, obtain the parameter value of described parameter name correspondence in described query argument; Adopt described parameter value to replace described querying condition.
In optional embodiment of the present invention, described query argument comprises at least one parameter statement; The described engine parameters that generates a described query argument of inquiry according to the querying condition after replacing, comprising: obtain the querying condition after at least one replacement, each querying condition is assembled to the engine parameters that generates a described query argument of inquiry.
In optional embodiment of the present invention, described employing regular expression also comprises before obtaining the querying condition in described structured query sentence SQL: judge whether described parameter value is empty; When described parameter value is not sky, carry out the step that described querying condition is replaced; When described parameter value is sky, described querying condition is replaced into preset empty condition.
In optional embodiment of the present invention, in described structured query sentence SQL, contain following at least one: the interval condition of the query relation sign of each querying condition, each querying condition, database transfer function and other are mingled with condition.
The embodiment of the present invention also provides a kind of data query system, comprising:
Receiver module, for receiving data query request, carries query argument in described data query request;
Matching module, for mating preset structured query sentence SQL according to described query argument;
Replacement module, for adopting regular expression to replace described structured query sentence SQL, generates the engine parameters of a described query argument of inquiry;
Enquiry module, for sending to described engine parameters Report Engine to obtain the data result of inquiry.
In optional embodiment of the present invention, described matching module, comprising: obtain submodule, for obtaining at least one statement parameter from described query argument; Matched sub-block, for respectively each described statement parameter being mated, determines the structured query sentence SQL to parameter name is inquired about in described query argument.
In optional embodiment of the present invention, described replacement module, comprise: replace submodule, for adopting regular expression to obtain the querying condition of described structured query sentence SQL, and according to parameter name and parameter value in described query argument, described querying condition is replaced; Generate submodule, for generate the engine parameters of a described query argument of inquiry according to the querying condition after replacing.
In optional embodiment of the present invention, described replacement submodule for adopting regular expression to mate the form of each described structured query sentence SQL, obtains querying condition respectively from described structured query sentence SQL; Determine the parameter name that described structured query sentence SQL will inquire about, obtain the parameter value of described parameter name correspondence in described query argument; Adopt described parameter value to replace described querying condition.
In optional embodiment of the present invention, described query argument comprises at least one parameter statement; Described generation submodule, for obtaining the querying condition after at least one replacement, assembles each querying condition the engine parameters that generates a described query argument of inquiry.
In optional embodiment of the present invention, described replacement module, also comprises: parameter value judges submodule, for judging whether described parameter value is empty; When described parameter value is not sky, triggers replacement submodule and carry out the replacement to described querying condition; When described parameter value is sky, triggers replacement submodule described querying condition is replaced into preset empty condition.
In optional embodiment of the present invention, in described structured query sentence SQL, contain following at least one: the interval condition of the query relation sign of each querying condition, each querying condition, database transfer function and other are mingled with condition.
Compared with prior art, the present invention includes following advantage:
The present invention can be mated preset SQL statement according to the query argument in the data query request receiving, then adopt regular expression to replace SQL statement SQL, the engine parameters of query argument described in generated query, then sends to this engine parameters Report Engine to obtain the data result of inquiry.Thereby can automatically generate an engine parameters to all querying conditions of request, inquire about, easy to use, search efficiency is higher.
Accompanying drawing explanation
Fig. 1 is the data enquire method process flow diagram that the embodiment of the present invention one provides;
Fig. 2 is the data enquire method process flow diagram that the embodiment of the present invention two provides
Fig. 3 is the data query schematic diagram that the embodiment of the present invention two provides;
Fig. 4 is the data query system structural drawing that the embodiment of the present invention three provides;
Fig. 5 is the optional structural drawing of data query system that the embodiment of the present invention three provides.
Embodiment
For above-mentioned purpose of the present invention, feature and advantage can be become apparent more, below in conjunction with the drawings and specific embodiments, the present invention is further detailed explanation.
The embodiment of the present invention provides a kind of data enquire method, can mate preset SQL statement according to the query argument in the data query request receiving, then adopt regular expression to replace SQL statement SQL, the engine parameters of query argument described in generated query, then sends to this engine parameters Report Engine to obtain the data result of inquiry.Thereby can automatically generate an engine parameters to all querying conditions of request, inquire about, easy to use, search efficiency is higher.
Embodiment mono-
With reference to Fig. 1, provided the data enquire method process flow diagram that the embodiment of the present invention one provides.
Step 101, receives data query request.
User is when carrying out data query, in the form operation page, can dynamically represent the information that inquiry is relevant, user can input the relevant information that will inquire about, as inquired about which parameter, and thereby the parameter value of this parameter etc. carries out condition query, then click and inquire about.
This form operation page can, according to the Information generation data query request of user's input, carry query argument in this data query request, by this query argument, can carry out condition query.Then the form operation page sends to data query system by data query request, and data query system obtains query argument from data query request.
Step 102, mates preset SQL statement according to described query argument.
Multiple SQL statement that the embodiment of the present invention is pre-configured, for carrying out the condition query of various ways, has configured the querying condition that at least one parameter name is inquired about in each SQL statement.
Thereby receiving after the query argument of page transmission, can be according to this query argument coupling SQL statement.For example in this query argument, configure by the parameter name that will inquire about, thereby according to this parameter name coupling SQL statement, and for example this query argument has identified the SQL statement that will mate.
Step 103, adopts regular expression to replace described SQL statement, generates the engine parameters of a described query argument of inquiry.
The embodiment of the present invention is pre-configured regular expression, wherein, regular expression can be used as a kind of logical formula to string operation, exactly with some specific characters that define in advance and the combination of these specific characters, form one " regular character string ", this " regular character string " is used for expressing a kind of filter logic to character string.
By regular expression, can from character string, obtain the specific part of wanting, therefore can adopt regular expression to filter to obtain querying condition to SQL statement, and then this querying condition is replaced, generate an engine parameters that can adopt JasperReport query argument to be carried out to data base querying.
Step 104, sends to Report Engine to obtain the data result of inquiry described engine parameters.
Data query system sends to Report Engine by engine parameters, Report Engine is used this engine parameters Query Database, and then receives the data that database returns, then feeds back to data query system, data query system by data feedback to user, as shown in the form operation page.
In sum, according to the query argument in the data query request receiving, mate preset SQL statement, then adopt regular expression to replace SQL statement SQL, the engine parameters of query argument described in generated query, then sends to this engine parameters Report Engine to obtain the data result of inquiry.Thereby can automatically generate an engine parameters to all querying conditions of request, inquire about, easy to use, search efficiency is higher.
Embodiment bis-
On the basis of above-described embodiment, the present embodiment is further discussed the querying method of data in detail.
With reference to Fig. 2, provided the data enquire method process flow diagram that the embodiment of the present invention two provides.
Step 201, receives data query request, obtains query argument from inquiry request.
In the present embodiment, above-mentioned steps 101 is mated preset SQL statement according to described query argument and is further comprised step 202 and step 203.
Step 202 is obtained at least one statement parameter from described query argument.
Step 203, mates each described statement parameter respectively, determines the SQL statement to parameter name is inquired about in described query argument.
In the embodiment of the present invention, query argument comprises parameter name, parameter value and statement parameter, and wherein, statement parameter is for obtaining the SQL statement that this parameter name and parameter value are inquired about.And owing to can multiple queries condition be inquired about simultaneously, therefore query argument comprises at least one group of parameter group consisting of parameter name, parameter value and statement parameter.
Thereby can from query argument, obtain at least one statement parameter, then each statement parameter be mated respectively, obtain the SQL statement of mating with this statement parameter, this SQL statement is for inquiring about the parameter name of this parameter value corresponding to this statement parameter.
For example, one group of parameter group in query argument, parameter is by name: String name=" a.clumn1 "; Parameter value is: String value=" 6 "; Parameter statement is sql=ProcessorUtil.buildSql (name, value, sql), adopts above-mentioned parameter group to have the replacement of the usual terms of value.
Corresponding matching to the SQL statement of the usual terms that has value be: String sql=" select*from table a where@a.clumn1=#a.clumn1#@".
Step 204, judges whether described SQL statement is empty.
After matching SQL statement, also to judge whether this SQL statement is empty, to determine whether carrying out by this SQL statement inquiry of data.
If so, be that described SQL statement is empty, perform step 205; If not, described SQL statement is not empty, performs step 206.
Step 205, returns to null character string.
If SQL statement is empty, adopt this SQL statement can not inquire data, therefore can return to null character string to the page,
Also can further point out and cannot inquire about or inquire about less than data etc.
Step 206, judges whether described parameter value is empty.
Get after the querying condition in SQL statement, can judge whether the parameter value in query argument is empty.
If so, be that described parameter value is sky, execution step 207; If not, described parameter value is not empty, performs step 208.
Step 207, is replaced into preset empty condition by described querying condition.
Step 208, adopts regular expression to obtain the querying condition in this SQL statement.
If SQL statement is not empty, in SQL statement, contain the querying condition of this inquiry, according to this condition, carry out the inquiry of database, but because JasperReport can not directly resolve this SQL statement, therefore will carry out SQL statement changes, to adopt regular expression to obtain the querying condition in SQL statement, the follow-up engine parameters that can be identified by JasperReport that builds according to this querying condition.
In optional embodiment of the present invention, adopt regular expression to obtain the querying condition in this SQL statement, comprising: adopt regular expression to mate the form of each SQL statement, from this SQL statement, obtain querying condition respectively.
By regular expression, can from character string, obtain the specific part of wanting, as querying condition, therefore regular expression can be configured to determine the wherein position at querying condition place by the form of SQL statement, thereby obtains querying condition.
Take the SQL statement of the above-mentioned usual terms that has value as example, the parameter value of each querying condition is used " # " to be surrounded, as: #a.clumn1#; Each querying condition is used "@" symbol to be surrounded, as :@a.clumn1=#a.clumn1#@.
When using regular expression to mate it, first the special character ". " of processing parameter title the inside, then using #param.name# replacement value is not empty parameter, and using regular expression@[^@] * param.name[^@] * (#param.name#) [^@] *@mates whole querying condition, and remove "@" symbol on both sides, thereby can determine that by "@" symbol the querying condition in this SQL statement is a.clumn1=#a.clumn1#.
Wherein, because character is to have particular meaning at regular expression as ". " conventionally, and in SQL statement, can often use character ". " to represent attaching relation, what represent such as a.name is exactly the name field of showing a, therefore in order to avoid a conflict, need to carry out escape processing to it.
Therefore,, if the parameter value in query argument is empty in above-mentioned steps 207, querying condition is replaced into preset empty condition, as 1=1.
Determine after querying condition, if the parameter value in this query argument is empty, use regular expression@[^@] * param.name[^@] querying condition in * (#param.name#) [^@] *@coupling SQL statement, then querying condition is replaced as " 1=1 ".
Step 209, replaces described querying condition according to parameter name and parameter value in described query argument.
In optional embodiment of the present invention, according to parameter name and parameter value in described query argument, described querying condition is replaced, being comprised: determine the parameter name that SQL statement will be inquired about, obtain the parameter value of described parameter name correspondence in described query argument; Adopt described parameter value to replace described querying condition.
If the parameter value in query argument is not empty, can adopt this parameter to replace querying condition, owing to may comprising multiple queries condition in SQL statement, in each querying condition, also may comprise multiple parameter names, therefore after matching querying condition, also to determine the parameters name that will inquire about in this querying condition, then obtain successively the parameter value of each parameter name correspondence in described query argument, then adopt this parameter value to replace parameter value corresponding in querying condition.
The querying condition of going up after example is replaced is a.clumn1=6, and the replacement result of corresponding SQL statement is select*from table a where a.clumn1=6.
Step 210, generates an engine parameters of inquiring about described query argument according to the querying condition after replacing.
Then the engine parameters that generates a described query argument of inquiry according to the querying condition after replacing, the replacement result that is about to SQL statement forms the engine parameters that can identify of JasperReport, as the replacement result relationSql of SQL statement just with $ P! { form of relationSql} is imported Report Engine into.
In optional embodiment of the present invention, the described engine parameters that generates a described query argument of inquiry according to the querying condition after replacing, comprise: obtain the querying condition after at least one replacement, each querying condition is assembled to the engine parameters that generates a described query argument of inquiry.
The embodiment of the present invention is in order to carry out fast data query, and make Query Result more precisely or scope larger, therefore query argument comprises parameter group at least first, the SQL statement of a data query use may be obtained multiple queries condition, obtain after the querying condition after at least one replacement, the engine parameters that the querying condition assembling after each replacement can be generated to a described query argument of inquiry, wherein has certain relation, as AND, OR etc. between each query statement.More than one sometimes of the querying condition of complicated SQL statement, and arrange a lot, also have much other conditions that is mingled with, sequence, in outer connection, connect all kinds of conditions such as combination, therefore the condition of many complexity all to be wanted to correct being spliced in different conditional statements, then be formed an engine parameters and inquire about.
Prior art is when carrying out data query, to assemble SQL statement according to querying condition, realize above-mentioned multiple relation and just must increase the relation between querying condition, also may there is the sequential organization of priority, as used () certain partial condition to be bracketed to change the priority of this condition, realize very complicatedly, even can not realize, therefore the correctness of SQL statement splicing is not known where to begin.And also there are interval condition, database transfer function etc., disparate databases transfer function is different, therefore database transfer function must IF for different databases in layoutprocedure ... ELSE, integrate that to write code very complicated, and the database of UNKNOWN TYPE is also needed to modify.Therefore prior art can only realize the form of simple queries condition, or without the form of querying condition, concerning enterprise's application, most function has no idea to realize at all so.
In the embodiment of the present invention, in SQL statement, contain following at least one: the interval condition of the query relation sign of each querying condition, each querying condition, database transfer function and other are mingled with condition.
Wherein, the query relation sign of each querying condition is for representing the query relation between each querying condition, as AND, OR etc.The interval condition of each querying condition is for representing the interval condition of querying condition, wherein, interval condition has been divided again multiple, time interval, between digital block etc., and interval literary style difference, some use BETWEEN ... AND, the combination that No. >=<, some uses.Database transfer function refers to the function using in inquired about database.Other are mingled with condition and comprise sequence, connect all kinds of conditions such as combination in outer connection.
In above-mentioned SQL statement, contained all kinds of conditions, transfer function etc. can identify in query argument, as identified the contents such as the relation of each statement in statement parameter.
For example, when carrying out data query, in query argument, may require the query relation that contains each querying condition in SQL statement simultaneously, interval condition, database transfer function and parameter value are the contents such as sky, the corresponding SQL statement obtaining of replacing can be: elect*from table a where a.clumn1=6and1=1and to_char (a.date, ' yyyy')=' 20130219'and1=1or a.date2between to_date (' 20130219') and to_date (' 20130220') or a.date3>=to_date (' 20130219') or a.date4<=to_date (' 20130219') or1=1or a.date6>=to_date (' 20130219') and a.date6<=to_date (' 20130220') or a.date7>=to_date (' 20130219') and1=1or1=1and a.date8<=to_date (' 20130220') or1=1and1=1.The SQL statement again replacement being obtained with $ P! { form of relationSql} is imported Report Engine into.
Step 211, sends to Report Engine to obtain the data result of inquiry described engine parameters.
Based on above-described embodiment, known when carrying out data query, the processing procedure between each system as shown in Figure 3.
The form operation page is obtaining after user's input, composition data inquiry request sends to data query system, data query system is according to this data query acquisition request query argument, and then the SQL storing in system is replaced, the engine parameters that regeneration Report Engine can be identified, then engine parameters is sent to Report Engine, Report Engine is inquired about database according to this engine parameters, obtain the data that database returns, then by data feedback to data query system, by data query system by this data feedback to report page to feed back to user.Thereby can, not changing on the basis of original SQL statement, replace dynamically the constituent of SQL, realize Report Engine data side is inquired about.
In sum, the embodiment of the present invention can in dynamic condition query realize simply, do not need to record too much identity property, and can be applicable to various databases under the prerequisite of not revising code, there is versatility.
Secondly, can realize easily various complex query conditions, as querying condition group, grouping, sequence etc., and can show purpose of design, check SQL source code, convenient test.And only need transmit an engine parameters and carry out data query, make data query more simple, convenient, improve the search efficiency of data, the comprehensive and accuracy of data query.
Embodiment tri-
On the basis of above-described embodiment, the present embodiment also provides a kind of data query system.
With reference to Fig. 4, provided the data query system structural drawing that the embodiment of the present invention three provides.
This data query system comprises: receiver module 401, matching module 402, replacement module 403 and enquiry module 404.
Wherein, receiver module 401, for receiving data query request, carries query argument in described data query request; Matching module 402, for mating preset SQL statement according to described query argument; Replacement module 403, for adopting regular expression to replace SQL statement, generates the engine parameters of a described query argument of inquiry; Enquiry module 404, for sending to described engine parameters Report Engine to obtain the data result of inquiry.
In sum, according to the query argument in the data query request receiving, mate preset SQL statement, then adopt regular expression to replace SQL statement SQL, the engine parameters of query argument described in generated query, then sends to this engine parameters Report Engine to obtain the data result of inquiry.Thereby can automatically generate an engine parameters to all querying conditions of request, inquire about, easy to use, search efficiency is higher.
With reference to Fig. 5, provided the optional structural drawing of data query system that the embodiment of the present invention three provides.
In optional embodiment of the present invention, matching module 402, comprising: obtain submodule 4021, matched sub-block 4022.
Wherein, obtain submodule 4021, for obtaining at least one statement parameter from described query argument; Matched sub-block 4022, for respectively each described statement parameter being mated, determines the SQL statement to parameter name is inquired about in described query argument.
In optional embodiment of the present invention, described replacement module 403, comprising: parameter value judges submodule 4031, replaces submodule 4032 and generates submodule 4033.
Wherein, replace submodule 4032, for adopting regular expression to obtain the querying condition of described SQL statement, and according to parameter name and parameter value in described query argument, described querying condition is replaced; Generate submodule 4033, for generate the engine parameters of a described query argument of inquiry according to the querying condition after replacing.Parameter value judges submodule 4031, for judging whether described parameter value is empty; When described parameter value is not sky, triggers replacement submodule and carry out the replacement to described querying condition; When described parameter value is sky, triggers replacement submodule described querying condition is replaced into preset empty condition.
In optional embodiment of the present invention, described replacement submodule 4032 for adopting regular expression to mate the form of each described SQL statement, obtains querying condition respectively from described SQL statement; Determine the parameter name that described SQL statement will be inquired about, obtain the parameter value of described parameter name correspondence in described query argument; Adopt described parameter value to replace described querying condition.
In optional embodiment of the present invention, described query argument comprises at least one parameter statement; Described generation submodule 4033, for obtaining the querying condition after at least one replacement, assembles each querying condition the engine parameters that generates a described query argument of inquiry.
In optional embodiment of the present invention, in SQL statement, contain following at least one: the interval condition of the query relation sign of each querying condition, each querying condition, database transfer function and other are mingled with condition.
In sum, the embodiment of the present invention can in dynamic condition query realize simply, do not need to record too much identity property, and can be applicable to various databases under the prerequisite of not revising code, there is versatility.
Secondly, can realize easily various complex query conditions, as querying condition group, grouping, sequence etc., and can show purpose of design, check SQL source code, convenient test.And only need transmit an engine parameters and carry out data query, make data query more simple, convenient, improve the search efficiency of data, the comprehensive and accuracy of data query.
For system embodiment, because it is substantially similar to embodiment of the method, so description is fairly simple, relevant part is referring to the part explanation of embodiment of the method.
Each embodiment in this instructions all adopts the mode of going forward one by one to describe, and each embodiment stresses is and the difference of other embodiment, between each embodiment identical similar part mutually referring to.
The present invention can describe in the general context of the computer executable instructions of being carried out by computing machine, for example program module.Usually, program module comprises and carries out particular task or realize routine, program, object, assembly, data structure of particular abstract data type etc.Also can in distributed computing environment, put into practice the present invention, in these distributed computing environment, by the teleprocessing equipment being connected by communication network, be executed the task.In distributed computing environment, program module can be arranged in the local and remote computer-readable storage medium including memory device.
Finally, also it should be noted that, in this article, relational terms such as the first and second grades is only used for an entity or operation to separate with another entity or operational zone, and not necessarily requires or imply and between these entities or operation, have the relation of any this reality or sequentially.And, term " comprises ", " comprising " or its any other variant are intended to contain comprising of nonexcludability, thereby the process, method, commodity or the equipment that make to comprise a series of key elements not only comprise those key elements, but also comprise other key elements of clearly not listing, or be also included as the intrinsic key element of this process, method, commodity or equipment.The in the situation that of more restrictions not, the key element being limited by statement " comprising ... ", and be not precluded within process, method, commodity or the equipment that comprises described key element and also have other identical element.
Above to a kind of data enquire method provided by the present invention and system, be described in detail, applied specific case herein principle of the present invention and embodiment are set forth, the explanation of above embodiment is just for helping to understand method of the present invention and core concept thereof; , for one of ordinary skill in the art, according to thought of the present invention, all will change in specific embodiments and applications, in sum, this description should not be construed as limitation of the present invention meanwhile.

Claims (14)

1. a data enquire method, is characterized in that, comprising:
Receive data query request, in described data query request, carry query argument;
According to described query argument, mate preset structured query sentence SQL;
Adopt regular expression to replace described structured query sentence SQL, generate the engine parameters of a described query argument of inquiry;
Send to Report Engine to obtain the data result of inquiry described engine parameters.
2. method according to claim 1, is characterized in that, the described query argument of described foundation mates preset structured query sentence SQL, comprising:
From described query argument, obtain at least one statement parameter;
Respectively each described statement parameter is mated, determine the structured query sentence SQL to parameter name is inquired about in described query argument.
3. method according to claim 1, is characterized in that, described employing regular expression is replaced described structured query sentence SQL, and the engine parameters of query argument described in generated query, comprising:
Adopt regular expression to obtain the querying condition in described structured query sentence SQL, and according to parameter name and parameter value in described query argument, described querying condition is replaced;
According to the querying condition after replacing, generate the engine parameters of a described query argument of inquiry.
4. method according to claim 3, is characterized in that, described employing regular expression obtains the querying condition in described structured query sentence SQL, and according to parameter name and parameter value in described query argument, described querying condition is replaced, and comprising:
Adopt regular expression to mate the form of each described structured query sentence SQL, from described structured query sentence SQL, obtain querying condition respectively;
Determine the parameter name that described structured query sentence SQL will inquire about, obtain the parameter value of described parameter name correspondence in described query argument;
Adopt described parameter value to replace described querying condition.
5. method according to claim 3, is characterized in that, described query argument comprises at least one parameter statement; The described engine parameters that generates a described query argument of inquiry according to the querying condition after replacing, comprising:
Obtain the querying condition after at least one replacement, each querying condition is assembled to the engine parameters that generates a described query argument of inquiry.
6. method according to claim 3, is characterized in that, described employing regular expression also comprises before obtaining the querying condition in described structured query sentence SQL:
Judge whether described parameter value is empty;
When described parameter value is not sky, carry out the step that described querying condition is replaced;
When described parameter value is sky, described querying condition is replaced into preset empty condition.
7. according to the arbitrary described method of claim 1 to 6, it is characterized in that, in described structured query sentence SQL, contain following at least one: the interval condition of the query relation sign of each querying condition, each querying condition, database transfer function and other are mingled with condition.
8. a data query system, is characterized in that, comprising:
Receiver module, for receiving data query request, carries query argument in described data query request;
Matching module, for mating preset structured query sentence SQL according to described query argument;
Replacement module, for adopting regular expression to replace described structured query sentence SQL, generates the engine parameters of a described query argument of inquiry;
Enquiry module, for sending to described engine parameters Report Engine to obtain the data result of inquiry.
9. system according to claim 8, is characterized in that, described matching module, comprising:
Obtain submodule, for obtaining at least one statement parameter from described query argument;
Matched sub-block, for respectively each described statement parameter being mated, determines the structured query sentence SQL to parameter name is inquired about in described query argument.
10. system according to claim 8, is characterized in that, described replacement module, comprising:
Replace submodule, for adopting regular expression to obtain the querying condition of described structured query sentence SQL, and according to parameter name and parameter value in described query argument, described querying condition is replaced;
Generate submodule, for generate the engine parameters of a described query argument of inquiry according to the querying condition after replacing.
11. systems according to claim 10, is characterized in that:
Described replacement submodule for adopting regular expression to mate the form of each described structured query sentence SQL, obtains querying condition respectively from described structured query sentence SQL; Determine the parameter name that described structured query sentence SQL will inquire about, obtain the parameter value of described parameter name correspondence in described query argument; Adopt described parameter value to replace described querying condition.
12. systems according to claim 10, is characterized in that, described query argument comprises at least one parameter statement;
Described generation submodule, for obtaining the querying condition after at least one replacement, assembles each querying condition the engine parameters that generates a described query argument of inquiry.
13. systems according to claim 10, is characterized in that, described replacement module, also comprises:
Parameter value judges submodule, for judging whether described parameter value is empty; When described parameter value is not sky, triggers replacement submodule and carry out the replacement to described querying condition; When described parameter value is sky, triggers replacement submodule described querying condition is replaced into preset empty condition.
System described in 14. according to Claim 8 to 13 are arbitrary, it is characterized in that, in described structured query sentence SQL, contain following at least one: the interval condition of the query relation sign of each querying condition, each querying condition, database transfer function and other are mingled with condition.
CN201310718464.1A 2013-12-23 2013-12-23 A kind of data query method and system Expired - Fee Related CN103744891B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310718464.1A CN103744891B (en) 2013-12-23 2013-12-23 A kind of data query method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310718464.1A CN103744891B (en) 2013-12-23 2013-12-23 A kind of data query method and system

Publications (2)

Publication Number Publication Date
CN103744891A true CN103744891A (en) 2014-04-23
CN103744891B CN103744891B (en) 2017-10-10

Family

ID=50501909

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310718464.1A Expired - Fee Related CN103744891B (en) 2013-12-23 2013-12-23 A kind of data query method and system

Country Status (1)

Country Link
CN (1) CN103744891B (en)

Cited By (24)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104536987A (en) * 2014-12-08 2015-04-22 联动优势电子商务有限公司 Data query method and device
CN104809254A (en) * 2015-05-19 2015-07-29 郑州悉知信息技术有限公司 Data query method and device
CN105824637A (en) * 2016-03-17 2016-08-03 中国银行股份有限公司 Customized query method and system
CN106611031A (en) * 2015-10-27 2017-05-03 北京国双科技有限公司 Data query method and device
CN106708864A (en) * 2015-11-13 2017-05-24 北京国双科技有限公司 Query framework-based data query method and apparatus
CN106708917A (en) * 2016-06-30 2017-05-24 腾讯科技(深圳)有限公司 Data processing method and device and OLAP system
CN106777076A (en) * 2016-12-13 2017-05-31 广东金赋科技股份有限公司 A kind of SQL limits inquiry clause generation method and combinational logic filter
CN106991276A (en) * 2017-03-17 2017-07-28 浙江大学 A kind of data-interface dynamic creation method based on openEHR templates
CN107256249A (en) * 2017-06-08 2017-10-17 北京小度信息科技有限公司 A kind of data base query method, device, electronic equipment and computer-readable storage medium
CN107463662A (en) * 2017-07-31 2017-12-12 拉卡拉支付股份有限公司 A kind of dynamic Sql querying methods, device
CN107480280A (en) * 2017-08-22 2017-12-15 金蝶软件(中国)有限公司 The method and relevant device of a kind of data processing
CN107609109A (en) * 2017-09-13 2018-01-19 山东浪潮云服务信息科技有限公司 A kind of report form generation method, device and system
CN108255882A (en) * 2016-12-29 2018-07-06 北京国双科技有限公司 Data query method and device
CN108388589A (en) * 2018-01-30 2018-08-10 福建星瑞格软件有限公司 A kind of device that database sql query statements automatically generate
CN108460092A (en) * 2018-01-30 2018-08-28 福建星瑞格软件有限公司 Include the sql query statements automatic generation method and system of database built-in function
CN109063136A (en) * 2018-08-03 2018-12-21 北京大米未来科技有限公司 Non-relational database inquiry system and method
CN109542931A (en) * 2018-11-23 2019-03-29 四川长虹电器股份有限公司 A method of the accurate search efficiency of sql database is improved based on regular expression
CN110019306A (en) * 2017-12-27 2019-07-16 航天信息股份有限公司 A kind of SQL statement lookup method and system based on XML format file
CN110232178A (en) * 2019-05-29 2019-09-13 北京中亦安图科技股份有限公司 Report generation method and device
CN110858202A (en) * 2018-08-21 2020-03-03 北京京东尚科信息技术有限公司 Method and device for generating where clause in database query statement
CN112988781A (en) * 2021-02-02 2021-06-18 北京金山云网络技术有限公司 Data query method and device, electronic equipment and computer readable storage medium
CN113064914A (en) * 2021-04-22 2021-07-02 中国工商银行股份有限公司 Data extraction method and device
CN113342821A (en) * 2021-06-29 2021-09-03 深圳前海微众银行股份有限公司 Report configuration method, device, equipment and computer storage medium
CN113590650A (en) * 2021-08-04 2021-11-02 中国工商银行股份有限公司 Feature expression based structured query statement discrimination method and device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101021875A (en) * 2007-03-22 2007-08-22 金蝶软件(中国)有限公司 Object-oriented data bank access method and system
US20080120326A1 (en) * 2006-11-20 2008-05-22 Oracle International Corporation Query generation
CN101645074A (en) * 2009-09-07 2010-02-10 浪潮集团山东通用软件有限公司 Method for accessing relational databases of different types

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080120326A1 (en) * 2006-11-20 2008-05-22 Oracle International Corporation Query generation
CN101021875A (en) * 2007-03-22 2007-08-22 金蝶软件(中国)有限公司 Object-oriented data bank access method and system
CN101645074A (en) * 2009-09-07 2010-02-10 浪潮集团山东通用软件有限公司 Method for accessing relational databases of different types

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
王小鉴: "SQL参数化查询详解", 《电脑编程技巧与维》 *
王广柱 等: "ASP进行动态和参数化数据查询", 《微电子学与计算机》 *

Cited By (31)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104536987B (en) * 2014-12-08 2017-12-05 联动优势电子商务有限公司 A kind of method and device for inquiring about data
CN104536987A (en) * 2014-12-08 2015-04-22 联动优势电子商务有限公司 Data query method and device
CN104809254A (en) * 2015-05-19 2015-07-29 郑州悉知信息技术有限公司 Data query method and device
CN106611031A (en) * 2015-10-27 2017-05-03 北京国双科技有限公司 Data query method and device
CN106708864A (en) * 2015-11-13 2017-05-24 北京国双科技有限公司 Query framework-based data query method and apparatus
CN105824637B (en) * 2016-03-17 2019-03-12 中国银行股份有限公司 Method for inquiring customization and system
CN105824637A (en) * 2016-03-17 2016-08-03 中国银行股份有限公司 Customized query method and system
CN106708917A (en) * 2016-06-30 2017-05-24 腾讯科技(深圳)有限公司 Data processing method and device and OLAP system
CN106777076A (en) * 2016-12-13 2017-05-31 广东金赋科技股份有限公司 A kind of SQL limits inquiry clause generation method and combinational logic filter
CN106777076B (en) * 2016-12-13 2020-05-05 广东金赋科技股份有限公司 SQL limited query clause generation method and combinational logic filter
CN108255882A (en) * 2016-12-29 2018-07-06 北京国双科技有限公司 Data query method and device
CN106991276A (en) * 2017-03-17 2017-07-28 浙江大学 A kind of data-interface dynamic creation method based on openEHR templates
CN106991276B (en) * 2017-03-17 2020-01-21 浙江大学 Data interface dynamic generation method based on openEHR template
CN107256249A (en) * 2017-06-08 2017-10-17 北京小度信息科技有限公司 A kind of data base query method, device, electronic equipment and computer-readable storage medium
CN107463662B (en) * 2017-07-31 2019-12-10 拉卡拉支付股份有限公司 Dynamic Sql query method and device
CN107463662A (en) * 2017-07-31 2017-12-12 拉卡拉支付股份有限公司 A kind of dynamic Sql querying methods, device
CN107480280A (en) * 2017-08-22 2017-12-15 金蝶软件(中国)有限公司 The method and relevant device of a kind of data processing
CN107609109A (en) * 2017-09-13 2018-01-19 山东浪潮云服务信息科技有限公司 A kind of report form generation method, device and system
CN110019306A (en) * 2017-12-27 2019-07-16 航天信息股份有限公司 A kind of SQL statement lookup method and system based on XML format file
CN108388589A (en) * 2018-01-30 2018-08-10 福建星瑞格软件有限公司 A kind of device that database sql query statements automatically generate
CN108460092B (en) * 2018-01-30 2022-09-16 福建星瑞格软件有限公司 Automatic generation method and system for sql query statement containing database built-in function
CN108388589B (en) * 2018-01-30 2022-09-16 福建星瑞格软件有限公司 Device for automatically generating sql query statement of database
CN108460092A (en) * 2018-01-30 2018-08-28 福建星瑞格软件有限公司 Include the sql query statements automatic generation method and system of database built-in function
CN109063136A (en) * 2018-08-03 2018-12-21 北京大米未来科技有限公司 Non-relational database inquiry system and method
CN110858202A (en) * 2018-08-21 2020-03-03 北京京东尚科信息技术有限公司 Method and device for generating where clause in database query statement
CN109542931A (en) * 2018-11-23 2019-03-29 四川长虹电器股份有限公司 A method of the accurate search efficiency of sql database is improved based on regular expression
CN110232178A (en) * 2019-05-29 2019-09-13 北京中亦安图科技股份有限公司 Report generation method and device
CN112988781A (en) * 2021-02-02 2021-06-18 北京金山云网络技术有限公司 Data query method and device, electronic equipment and computer readable storage medium
CN113064914A (en) * 2021-04-22 2021-07-02 中国工商银行股份有限公司 Data extraction method and device
CN113342821A (en) * 2021-06-29 2021-09-03 深圳前海微众银行股份有限公司 Report configuration method, device, equipment and computer storage medium
CN113590650A (en) * 2021-08-04 2021-11-02 中国工商银行股份有限公司 Feature expression based structured query statement discrimination method and device

Also Published As

Publication number Publication date
CN103744891B (en) 2017-10-10

Similar Documents

Publication Publication Date Title
CN103744891A (en) Method and system for data query
US7877726B2 (en) Semantic system for integrating software components
US8103705B2 (en) System and method for storing text annotations with associated type information in a structured data store
Lanthaler et al. A semantic description language for restful data services to combat semaphobia
US20130166563A1 (en) Integration of Text Analysis and Search Functionality
CN102270137B (en) Method for acquiring ADL (architecture description language) and modeling tool
US8756407B2 (en) Configuration rule prototyping tool
WO2013181588A2 (en) Defining and mapping application interface semantics
Minadakis et al. X3ML Framework: An Effective Suite for Supporting Data Mappings.
CN105975489A (en) Metadata-based online SQL code completion method
CN104573053B (en) A kind of configuration item template dynamic customization method based on XML
CN110083749A (en) The retrieval quickly developed for software, multiplexing, environmental structure system and method
Haider et al. CSV2RDF: Generating RDF data from CSV file using semantic web technologies
CN112882844A (en) Network front-end and back-end based joint debugging method and device and storage medium
CN115016784B (en) Low code application multiplexing method, application analysis system, equipment and storage medium
CN115481288A (en) Method and device for realizing conversion from online interface document to offline interface document
US9471640B2 (en) Automatic conversion of units of measure during data stream processing
CN108319466A (en) A kind of restoration methods and device of configuration information
US8762433B1 (en) Integration architecture for software and hardware development
Jennings Professional ADO. NET 3.5 with LINQ and the Entity Framework
CN111782195B (en) Query method for splicing SQL based on adding notes on request parameters
Brambilla et al. Model-driven development of Web Services and hypertext applications
CN102486731A (en) Method, device and system for enhancing visualization of software call stack of software
Kuckertz et al. A Metadata-Based Ecosystem to Improve the FAIRness of Research Software
US20070174251A1 (en) System and method for analyzing commands for searching data

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20171010

CF01 Termination of patent right due to non-payment of annual fee