CN102253984A - Query sentence processing device and query sentence processing method - Google Patents

Query sentence processing device and query sentence processing method Download PDF

Info

Publication number
CN102253984A
CN102253984A CN2011101774735A CN201110177473A CN102253984A CN 102253984 A CN102253984 A CN 102253984A CN 2011101774735 A CN2011101774735 A CN 2011101774735A CN 201110177473 A CN201110177473 A CN 201110177473A CN 102253984 A CN102253984 A CN 102253984A
Authority
CN
China
Prior art keywords
query statement
self
rule
function
result
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.)
Pending
Application number
CN2011101774735A
Other languages
Chinese (zh)
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.)
Yonyou Software Co Ltd
Original Assignee
Yonyou Software 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 Yonyou Software Co Ltd filed Critical Yonyou Software Co Ltd
Priority to CN2011101774735A priority Critical patent/CN102253984A/en
Publication of CN102253984A publication Critical patent/CN102253984A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a query sentence processing device and a query sentence processing method. The query sentence processing device comprises a rule definition module 102, a syntactic analysis module 104 and a rule processing module 106, wherein the rule definition module 102 is used for setting a rule for processing self-defined elements; the syntactic analysis module 104 is used for analyzing an expression to acquire the self-defined elements in the module 104; and the rule processing module 106 is used for processing the self-defined elements according to the rule and forming query sentences by using a processing result of the elements. By a preset rule, the elements of the expression are converted into an identifiable form of the current database, so that the expression can be applied to any database.

Description

Query statement treating apparatus and query statement disposal route
Technical field
The present invention relates to field of computer technology, in particular to a kind of query statement treating apparatus and a kind of query statement disposal route.
Background technology
In the database application exploitation, our product often need be supported different databases, for example: Oracle, DB2, SQL Server etc.Though each database product is all supported standard sql syntax gauge, all expands on this basis, formed the grammer and the function of own uniqueness.Though these special grammar help giving full play to the performance of each database product itself, and be unfavorable for the database application exploitation, how support heterogeneous database to become a problem.In the prior art, have following dual mode to solve this type of problem usually:
1. for the static sql in the code, can provide different sql versions to support at the disparate databases type;
2. for the system that uses the O/R mapping framework, can be by O/R framework support database difference to a certain extent.
The problem of scheme 1 is that ease for use is not enough.The problem of scheme 2 is to support comprehensive inadequately, and for example: complex report form sql statement can't generate based on the O/R framework.
Therefore, the method for a kind of query language based on extension example such as sql statement of demand can effectively solve the heterogeneous database problem, and the ease for use of service-oriented can also be provided, and supports the optimization of query statement to a certain extent.
Summary of the invention
Technical matters to be solved by this invention is, a kind of method of the query language based on extension example such as sql statement is provided, can effectively solve the heterogeneous database problem, the ease for use of service-oriented can also be provided, and support the optimization of query statement to a certain extent.
In view of this, the invention provides a kind of query statement treating apparatus, comprising: the rule definition module is provided with the rule that self-defined element is handled; The syntax parsing module is resolved expression formula, obtains self-defined element wherein; The rule treatments module is handled self-defined element according to rule, and uses the result of element to form query statement.By this technical scheme, by predetermined rule, convert the element of expression formula to current database discernible form, can make expression formula be applicable to any database.
In technique scheme, preferably, when the rule treatments module is self-defining function at self-defined element, according to rule, the function that self-defining function is handled corresponding current database type is as result, or obtain self-defining function call the result as result.By this technical scheme, the user can use the function that can realize required function in expression formula, and function is easy to use.
In technique scheme, preferably, also comprise: modular converter is converted to character string forms with each element of query statement.By this technical scheme, guaranteed to carry out smoothly after query statement can send to database.
In technique scheme, preferably, also comprise: optimal module also is optimized query statement.By this technical scheme, can make formation query statement structure more reasonable, be not easy more to make mistakes.
In technique scheme, preferably, query statement is optimized specifically comprises: it is nested to eliminate redundant subquery; Remove invalid bracket; Remove invalid association.In fact, the mode of optimization query statement has multiple, is not limited to above list several.
The present invention also provides a kind of query statement disposal route, comprising: step 202 is provided with the rule that self-defined element is handled; Step 204 is resolved expression formula, obtains self-defined element wherein; Step 206 is handled self-defined element according to rule, and uses the result of element to form query statement.By this technical scheme, by predetermined rule, convert the element of expression formula to current database discernible form, can make expression formula be applicable to any database.
In technique scheme, preferably, in step 206, when self-defined element is self-defining function, according to rule, the function that self-defining function is handled corresponding current database type is as result, or obtain self-defining function call the result as result.By this technical scheme, the user can use the function that can realize required function in expression formula, and function is easy to use.
In technique scheme, preferably, also comprise: each element of query statement is converted to character string forms.By this technical scheme, guaranteed to carry out smoothly after query statement can send to database.
In technique scheme, preferably, in step 206, also query statement is optimized.By this technical scheme, can make formation query statement structure more reasonable, be not easy more to make mistakes.
In technique scheme, preferably, in step 206, query statement is optimized specifically comprises: it is nested to eliminate redundant subquery; Remove invalid bracket; Remove invalid association.In fact, the mode of optimization query statement has multiple, is not limited to above list several.
By above technical scheme, can realize a kind of query statement treating apparatus and a kind of query statement disposal route, can effectively solve the heterogeneous database problem, the ease for use of service-oriented can also be provided, and support the optimization of query statement to a certain extent.
Description of drawings
Fig. 1 is the block diagram of query statement treating apparatus according to an embodiment of the invention;
Fig. 2 is the process flow diagram of query statement disposal route according to an embodiment of the invention;
Fig. 3 is the block diagram of query statement treating apparatus according to an embodiment of the invention;
Fig. 4 is the module diagram of query statement treating apparatus according to an embodiment of the invention;
Fig. 5 is the module diagram of query statement treating apparatus according to an embodiment of the invention.
Embodiment
In order more to be expressly understood above-mentioned purpose of the present invention, feature and advantage, the present invention is further described in detail below in conjunction with the drawings and specific embodiments.
Set forth a lot of details in the following description so that fully understand the present invention, still, the present invention can also adopt other to be different from other modes described here and implement, and therefore, the present invention is not limited to the restriction of following public specific embodiment.
Fig. 1 is the block diagram of query statement treating apparatus according to an embodiment of the invention.
As shown in Figure 1, the invention provides a kind of query statement treating apparatus 100, comprising: rule definition module 102 is provided with the rule that self-defined element is handled; Syntax parsing module 104 is resolved expression formula, obtains self-defined element wherein; Rule treatments module 106 is handled self-defined element according to rule, and uses the result of element to form query statement.By this technical scheme, by predetermined rule, convert the element of expression formula to current database discernible form, can make expression formula be applicable to any database.
In technique scheme, when rule treatments module 106 is self-defining function at self-defined element, according to rule, the function that self-defining function is handled corresponding current database type is as result, or obtain self-defining function call the result as result.By this technical scheme, the user can use the function that can realize required function in expression formula, and function is easy to use.
In technique scheme, also comprise: modular converter 108 is converted to character string forms with each element of query statement.By this technical scheme, guaranteed to carry out smoothly after query statement can send to database.
In technique scheme, also comprise: optimal module 110 also is optimized query statement.By this technical scheme, can make formation query statement structure more reasonable, be not easy more to make mistakes.
In technique scheme, query statement is optimized specifically comprises: it is nested to eliminate redundant subquery; Remove invalid bracket; Remove invalid association.In fact, the mode of optimization query statement has multiple, is not limited to above list several.
Fig. 2 is the process flow diagram of query statement disposal route according to an embodiment of the invention.
As shown in Figure 2, the present invention also provides a kind of query statement disposal route, comprising: step 202 is provided with the rule that self-defined element is handled; Step 204 is resolved expression formula, obtains self-defined element wherein; Step 206 is handled self-defined element according to rule, and uses the result of element to form query statement.By this technical scheme, by predetermined rule, convert the element of expression formula to current database discernible form, can make expression formula be applicable to any database.
In technique scheme, in step 206, when self-defined element was self-defining function, according to rule, the function that self-defining function is handled corresponding current database type was as result, or obtain self-defining function call the result as result.By this technical scheme, the user can use the function that can realize required function in expression formula, and function is easy to use.
In technique scheme, also comprise: each element of query statement is converted to character string forms.By this technical scheme, guaranteed to carry out smoothly after query statement can send to database.
In technique scheme, in step 206, also query statement is optimized.By this technical scheme, can make formation query statement structure more reasonable, be not easy more to make mistakes.
In technique scheme, in step 206, query statement is optimized specifically comprises: it is nested to eliminate redundant subquery; Remove invalid bracket; Remove invalid association.In fact, the mode of optimization query statement has multiple, is not limited to above list several.
Fig. 3 is the block diagram of query statement treating apparatus according to an embodiment of the invention.
Based on the sql language, present embodiment provides a kind of query statement treating apparatus, can realize function expansion, rule expansion etc.Based on these expansions, can realize encapsulating business complexity, can call execution complicated business logic by enough sql statements, thereby enlarge the function of sql statement.The concrete module of this device is as shown in Figure 3:
Syntax parsing device 302:
Syntax parsing device 302 generates based on JavaCC.This resolver 302 can carry out lexical analysis, grammatical analysis to the sql expression formula, and then each element objectization of sql expression formula, is beneficial to carry out follow-up operation to each element.
Rule processor 304:
Expansion based on the sql statement is to realize by rule processor 304.Rule processor is handled self-defining function, customized expression, the final sql statement that forms towards concrete database.
The rule support expansion that is provided with, custom rule is registrable in configuration file.As shown in Figure 4, thereby rule processor 304 can read the rule that this document loads all configurations, and when carrying out, rule processor can call each rule successively.
It is one important in the rule treatments that functional rule is handled, and the expansion execution of function all is based on this rule and handles.
In the present embodiment, provide expansion, the login mechanism of function equally, the Function Processor 402 in the rule processor 302 can load this configuration file, reads the function expansion of all definition.When executable expressions was resolved, each element of traversal visit expression formula if be judged to be spread function, then can call the actuator of this function and handle.
The developer realizes that self-defining function only need do following steps: realize the interface of function, and register in configuration file.Then, just can in expression formula, directly use this function.For instance, obtain the function of string length, function name is different in each database.Being len () among the SqlServer, is length () among DB2, the Oracle.At this class database difference, can use self-defining function length () to realize, in expression formula, directly use length (), during the sql object of rule processor in handling expression formula, can traversal visit each sql element, if have access to length () function, this function will be converted to the function of current database type.
Sql optimizer 306:
Be optimized at the sql statement, for example: eliminate the redundant nested sql of the flattening statement of subquery, remove invalid bracket, remove invalid join association etc.
Sql converter 308:
Final sql object is translated as the sql statement of character string forms.Also promptly travel through each element in the visit expression formula, return the character string forms of each element, be spliced into complete sql statement.
Though it should be noted that and adopt the sql statement to describe among the above embodiment, in fact, the multiple query language that carries out database manipulation all is suitable for technical scheme of the present invention.
According to above technical scheme, can realize a kind of query statement treating apparatus and a kind of query statement method, be characterized in:
Support heterogeneous database:
At database difference, especially function difference provides unified function processing scheme.Use these functions when writing expression formula, resolver can be translated into concrete database dialect.
Service-oriented:
Support expansion, the developer can be encapsulated as the function with specific transactions implication to complicated sql expression formula or complicated business logic, when writing expression formula, at identity logic, can directly use this function, when simplifying the sql expression formula, more give prominence to traffic performance.For instance, can realize a kind of function of getting the quantity available of certain material of storehouse, called after getQuantity (storehouse coding, material code).This function has been arranged, just can directly write following expression and come query-relevant data:
Select*from getQuantity (storehouse coding, material code)
Certainly, this function can also be used in combination with other sql elements and realize more complicated function.
Ease for use:
The user can directly use the elements such as function of syntax rule support when writing the sql statement, database difference, professional function processing etc. can all transfer to resolver and rule processor is handled.
Sql optimizes:
Our analytics engine support sql to a certain extent optimizes.For example: the bracket that redundant subquery is nested, invalid, invalid association etc.
The decoupling zero of code and sql statement:
When using, always keep away the nested coupling of unavoidable sql statement and code in the development data storehouse.Especially in splicing complex report form sql statement process, always be mingled with the code of service logic.Utilize our extension mechanism, can be encapsulated into code logic in the function realization, directly this function of spelling gets final product in sq statement l.So just can reduce the coupling of code and sql statement, make that the sql structure is more clear, purpose is clearer and more definite.
The above is the preferred embodiments of the present invention only, is not limited to the present invention, and for a person skilled in the art, the present invention can have various changes and variation.Within the spirit and principles in the present invention all, any modification of being done, be equal to replacement, improvement etc., all should be included within protection scope of the present invention.

Claims (10)

1. a query statement treating apparatus is characterized in that, comprising:
The rule definition module is provided with the rule that self-defined element is handled;
The syntax parsing module is resolved expression formula, obtains described self-defined element wherein;
The rule treatments module is handled described self-defined element according to described rule, and uses the result of described element to form query statement.
2. query statement treating apparatus according to claim 1, it is characterized in that, when described rule treatments module is self-defining function at described self-defined element, according to described rule, the function that described self-defining function is handled corresponding current database type is as described result, or obtain described self-defining function call the result as described result.
3. query statement treating apparatus according to claim 1 is characterized in that, also comprises:
Modular converter is converted to character string forms with each element of described query statement.
4. according to each described query statement treating apparatus in the claim 1 to 3, it is characterized in that, also comprise:
Optimal module also is optimized described query statement.
5. query statement treating apparatus according to claim 4 is characterized in that, described query statement is optimized specifically comprise:
It is nested to eliminate redundant subquery;
Remove invalid bracket;
Remove invalid association.
6. a query statement disposal route is characterized in that, comprising:
Step 202 is provided with the rule that self-defined element is handled;
Step 204 is resolved expression formula, obtains described self-defined element wherein;
Step 206 is handled described self-defined element according to described rule, and uses the result of described element to form query statement.
7. query statement disposal route according to claim 6, it is characterized in that, in described step 206, when described self-defined element is self-defining function, according to described rule, the function that described self-defining function is handled corresponding current database type is as described result, or obtain described self-defining function call the result as described result.
8. query statement disposal route according to claim 6 is characterized in that, also comprises:
Each element of described query statement is converted to character string forms.
9. according to each described query statement disposal route in the claim 6 to 8, it is characterized in that, in described step 206, also described query statement is optimized.
10. query statement disposal route according to claim 9 is characterized in that, in described step 206, described query statement is optimized specifically comprises:
It is nested to eliminate redundant subquery;
Remove invalid bracket;
Remove invalid association.
CN2011101774735A 2011-06-28 2011-06-28 Query sentence processing device and query sentence processing method Pending CN102253984A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2011101774735A CN102253984A (en) 2011-06-28 2011-06-28 Query sentence processing device and query sentence processing method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2011101774735A CN102253984A (en) 2011-06-28 2011-06-28 Query sentence processing device and query sentence processing method

Publications (1)

Publication Number Publication Date
CN102253984A true CN102253984A (en) 2011-11-23

Family

ID=44981248

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2011101774735A Pending CN102253984A (en) 2011-06-28 2011-06-28 Query sentence processing device and query sentence processing method

Country Status (1)

Country Link
CN (1) CN102253984A (en)

Cited By (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102902778A (en) * 2012-09-28 2013-01-30 用友软件股份有限公司 Query sentence optimization device and query sentence optimization method
CN103186579A (en) * 2011-12-29 2013-07-03 北京亿阳信通科技有限公司 Database function-based rule implementation and application method and device
WO2013164832A1 (en) * 2012-04-30 2013-11-07 Hewlett-Packard Development Company, L.P. Storage and evaluation of expressions
CN103902543A (en) * 2012-12-25 2014-07-02 华为技术有限公司 Database inquiry method and device and database system
CN104615713A (en) * 2015-02-05 2015-05-13 浪潮通用软件有限公司 SQL executing method and device based on multiple database types
CN105183809A (en) * 2015-08-26 2015-12-23 成都布林特信息技术有限公司 Cloud platform data query method
CN105718593A (en) * 2016-01-28 2016-06-29 长春师范大学 Database query optimization method and system
CN106126540A (en) * 2016-06-15 2016-11-16 中国传媒大学 Data base access system and access method thereof
CN106407302A (en) * 2016-08-30 2017-02-15 东华大学 Method for supporting function of calling specific functions of middleware database through simple SQL
CN103823815B (en) * 2012-11-19 2017-05-17 中国联合网络通信集团有限公司 server and database access method
CN107451149A (en) * 2016-05-31 2017-12-08 北京京东尚科信息技术有限公司 The monitoring method and its device of data on flows query task
CN107832387A (en) * 2017-10-31 2018-03-23 北京酷我科技有限公司 A kind of SQL statement analytic method based on FMDB
CN108446289A (en) * 2017-09-26 2018-08-24 北京中安智达科技有限公司 A kind of data retrieval method for supporting heterogeneous database
CN110704472A (en) * 2019-08-27 2020-01-17 北京数知科技股份有限公司 Data query statistical method and device
CN114586021A (en) * 2019-10-23 2022-06-03 聪丰罗株式会社 Information output device, information output method, and information output program

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101158975A (en) * 2007-11-21 2008-04-09 金蝶软件(中国)有限公司 Method and system for accessing distinct type data-base

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101158975A (en) * 2007-11-21 2008-04-09 金蝶软件(中国)有限公司 Method and system for accessing distinct type data-base

Cited By (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103186579A (en) * 2011-12-29 2013-07-03 北京亿阳信通科技有限公司 Database function-based rule implementation and application method and device
WO2013164832A1 (en) * 2012-04-30 2013-11-07 Hewlett-Packard Development Company, L.P. Storage and evaluation of expressions
CN102902778A (en) * 2012-09-28 2013-01-30 用友软件股份有限公司 Query sentence optimization device and query sentence optimization method
CN103823815B (en) * 2012-11-19 2017-05-17 中国联合网络通信集团有限公司 server and database access method
CN103902543A (en) * 2012-12-25 2014-07-02 华为技术有限公司 Database inquiry method and device and database system
CN104615713A (en) * 2015-02-05 2015-05-13 浪潮通用软件有限公司 SQL executing method and device based on multiple database types
CN105183809A (en) * 2015-08-26 2015-12-23 成都布林特信息技术有限公司 Cloud platform data query method
CN105718593A (en) * 2016-01-28 2016-06-29 长春师范大学 Database query optimization method and system
CN105718593B (en) * 2016-01-28 2019-04-16 长春师范大学 A kind of database inquiry optimization method and system
CN107451149A (en) * 2016-05-31 2017-12-08 北京京东尚科信息技术有限公司 The monitoring method and its device of data on flows query task
CN106126540A (en) * 2016-06-15 2016-11-16 中国传媒大学 Data base access system and access method thereof
CN106126540B (en) * 2016-06-15 2019-07-09 中国传媒大学 Data base access system and its access method
CN106407302A (en) * 2016-08-30 2017-02-15 东华大学 Method for supporting function of calling specific functions of middleware database through simple SQL
CN108446289A (en) * 2017-09-26 2018-08-24 北京中安智达科技有限公司 A kind of data retrieval method for supporting heterogeneous database
CN107832387A (en) * 2017-10-31 2018-03-23 北京酷我科技有限公司 A kind of SQL statement analytic method based on FMDB
CN107832387B (en) * 2017-10-31 2021-07-13 北京酷我科技有限公司 SQL statement analysis method based on FMDB
CN110704472A (en) * 2019-08-27 2020-01-17 北京数知科技股份有限公司 Data query statistical method and device
CN114586021A (en) * 2019-10-23 2022-06-03 聪丰罗株式会社 Information output device, information output method, and information output program
CN114586021B (en) * 2019-10-23 2022-12-09 聪丰罗株式会社 Information output device, information output method, and recording medium
US11599536B2 (en) 2019-10-23 2023-03-07 Soppra Corporation Information output device, information output method, and information output program

Similar Documents

Publication Publication Date Title
CN102253984A (en) Query sentence processing device and query sentence processing method
US10776189B2 (en) API query
Sporny et al. JSON-LD 1.1
Grau et al. OWL 2: The next step for OWL
CN1906609B (en) System for data format conversion for use in data centers
US20170103167A1 (en) Blockchain system for natural language processing
US9870203B2 (en) Consumption layer for business entities
CN103425726B (en) Open data are accessed using business intelligence tool
JP6720641B2 (en) Data constraint of multilingual data tier
CN109491989B (en) Data processing method and device, electronic equipment and storage medium
US20130086100A1 (en) Method and System Providing Document Semantic Validation and Reporting of Schema Violations
Kellogg et al. Json-ld 1.1–a json-based serialization for linked data
BRPI0708827A2 (en) extensible query language with support for rich data types
US10614062B2 (en) Data model extension generation
US20230120592A1 (en) Query Generation and Processing System
CN102520963A (en) Method and system for realizing service logic processing based on strongly-typed relation mapping
CN111782195A (en) Query method based on adding annotation on request parameter and splicing into SQL
CN107832055A (en) A kind of MQL language translations are the method for sql like language
Marx et al. RDB2RDF: A relational to RDF plug‐in for Eclipse
CN115390936A (en) Unified verification method, device, equipment and storage medium
CN104317935A (en) Method and system for generating HTML (hypertext markup language) pages from XML (extensible markup language) bill files in batches
Kirchhoff et al. Semantic description of OData services
US20190073356A1 (en) Methods and systems for implied graph patterns in property chains
US10984195B2 (en) Methods and systems for using implied properties to make a controlled-english modelling language more natural
Morishima et al. A data modeling and query processing scheme for integration of structured document repositories and relational databases

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C12 Rejection of a patent application after its publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20111123