CN116628005A - Structured query statement processing method, device, equipment and storage medium - Google Patents

Structured query statement processing method, device, equipment and storage medium Download PDF

Info

Publication number
CN116628005A
CN116628005A CN202310593482.5A CN202310593482A CN116628005A CN 116628005 A CN116628005 A CN 116628005A CN 202310593482 A CN202310593482 A CN 202310593482A CN 116628005 A CN116628005 A CN 116628005A
Authority
CN
China
Prior art keywords
instruction
statement
preset
storage
stored
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
CN202310593482.5A
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.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen 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 Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN202310593482.5A priority Critical patent/CN116628005A/en
Publication of CN116628005A publication Critical patent/CN116628005A/en
Pending legal-status Critical Current

Links

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
    • 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/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

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

Abstract

The invention relates to financial science and technology and provides a structured query statement processing method, a device, equipment and a storage medium. The method identifies the marking state of an input instruction, reads a target instruction based on the input instruction if the marking state is not a preset state, writes the target instruction into a preset buffer area, detects whether a storage instruction is an end statement based on a preset ending symbol if the storage instruction in the preset buffer area is not a local command, extracts a server execution statement from the storage instruction based on the preset ending symbol if the storage instruction is the end statement, sends the server execution statement to a database server, receives an execution result generated by the database server based on the server execution statement, and improves the generation accuracy of the execution result. Furthermore, the present invention relates to blockchain techniques, and the execution results may be stored in the blockchain.

Description

Structured query statement processing method, device, equipment and storage medium
Technical Field
The present invention relates to the field of data processing and finance technologies, and in particular, to a method, an apparatus, a device, and a storage medium for processing a structured query statement.
Background
In the field of financial science and technology, with rapid development of computer technology, databases are increasingly widely used, for example, the databases may be applied to insurance systems, banking systems, transaction systems, order systems, and the like. In order to be able to reduce the network load brought by the process communication between clients on different machines and database servers, procedural languages are expanding accordingly. Typically, a procedural language will include multiple statements.
Currently, in order to improve the processing efficiency of the database server, it is generally required that the received user input sentence must be a single or multiple complete SQL sentences, or a single or multiple complete procedural language sentences supported by the database server, otherwise, the database server will alert about the grammar error. However, the user has a lot of randomness and complexity when inputting the sentences, and it is possible that one SQL sentence is input multiple times, it is also possible to input multiple SQL sentences at a time, and it is also possible to input one or more sentences in the procedural language at a time.
Therefore, how to accurately identify sentences that can be supported by the database server from the user input sentences becomes a technical problem to be solved.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a method, apparatus, device, and storage medium for processing a structured query term, which can accurately identify terms that can be supported by a database server from terms input by a user.
In one aspect, the present invention provides a method for processing a structured query term, which is applied to an electronic device, where the electronic device communicates with a database server, and the method for processing a structured query term includes:
in response to the sentence processing request, identifying a marking state of an input instruction read from a preset input interface;
if the marking state is not the preset state, reading a target instruction from the preset input interface based on the input instruction, and writing the target instruction into a preset buffer zone;
if the storage instruction in the preset buffer zone is not a local command, detecting whether the storage instruction is an end statement or not based on a preset ending symbol;
if the storage instruction is an ending statement, extracting a server execution statement from the storage instruction based on the preset ending symbol;
and sending the server execution statement to the database server, and receiving an execution result generated by the database server based on the server execution statement.
According to a preferred embodiment of the present invention, the identifying, in response to the sentence processing request, the tag state of the input instruction read from the preset input interface includes:
screening a target log from the read logs of the preset input interface based on the generation moment of the statement processing request;
acquiring a reading instruction from the target log;
based on the reading instruction, acquiring the input instruction from the preset input interface;
detecting whether an interrupt signal is included in the input instruction;
and if the input instruction comprises the interrupt signal, determining the marking state as the preset state.
According to a preferred embodiment of the present invention, the preset ending symbol includes a first ending symbol and a second ending symbol, and the detecting whether the storage instruction is an ending sentence based on the preset ending symbol includes:
if the system configuration ending symbol of the preset input interface is initial configuration, detecting whether the storage instruction comprises the first ending symbol;
if the stored instruction comprises the first ending symbol, performing lexical analysis on the stored instruction to obtain a plurality of instruction keywords;
acquiring target keywords from the plurality of instruction keywords;
Detecting whether the storage instruction is a procedural statement according to the target keyword;
if the storage instruction is a procedural statement, determining that the storage instruction is not an ending statement; or alternatively
And if the storage instruction is not a procedural statement or the storage instruction comprises the second ending symbol, determining the storage instruction as an ending statement.
According to a preferred embodiment of the present invention, the detecting whether the stored instruction is a procedural statement according to the target keyword includes:
when the target keyword is a first preset keyword, detecting whether the storage instruction contains a packet statement or not;
if the storage instruction does not contain the packet statement, detecting whether the storage instruction contains a custom function statement or not;
if the storage instruction does not comprise the custom function statement, detecting whether the storage instruction comprises a storage creation statement or not;
if the storage instruction does not include the storage creation statement, detecting whether the storage instruction includes a trigger creation statement;
if the stored instruction does not include the trigger creation statement, determining that the stored instruction is not a procedural statement; or alternatively
If the storage instruction contains the packet statement, the custom function statement or the trigger creation statement, determining that the storage instruction is a procedural statement.
According to a preferred embodiment of the present invention, the detecting whether the stored instruction is a procedural statement according to the target keyword further includes:
when the target keyword is a second preset keyword, detecting whether the stored instruction contains anonymous block sentences based on the second preset keyword or not;
if the stored instruction does not contain the anonymous block statement based on the second preset keyword, determining that the stored instruction is not a procedural statement; or alternatively
And if the stored instruction contains anonymous block statements based on the second preset keywords, determining the stored instruction as a procedural statement.
According to a preferred embodiment of the present invention, the detecting whether the stored instruction is a procedural statement according to the target keyword further includes:
when the target keyword is a third preset keyword, detecting whether the stored instruction contains anonymous block sentences based on the third preset keyword or not;
if the stored instruction does not contain the anonymous block statement based on the third preset keyword, determining that the stored instruction is not a procedural statement; or alternatively
And if the stored instruction contains anonymous block sentences based on the third preset keywords, determining the stored instruction as a procedural sentence.
According to a preferred embodiment of the present invention, the extracting the server execution statement from the stored instruction based on the preset terminator includes:
if the system configuration ending symbol is the initial configuration or the second ending symbol, extracting an instruction with a character position before the ending position of the second ending symbol from the stored instruction as the server execution statement; or alternatively
And if the system configuration ending symbol is the first ending symbol, extracting the server execution statement from the storage instruction based on the first ending symbol.
On the other hand, the invention also provides a structured query sentence processing device, which is operated on an electronic device, wherein the electronic device is communicated with a database server, and the structured query sentence processing device comprises:
the identification unit is used for responding to the sentence processing request and identifying the marking state of the input instruction read from the preset input interface;
the writing unit is used for reading a target instruction from the preset input interface based on the input instruction and writing the target instruction into a preset buffer zone if the marking state is not a preset state;
The detection unit is used for detecting whether the storage instruction in the preset buffer area is an end statement or not based on a preset ending symbol if the storage instruction in the preset buffer area is not a local command;
the extraction unit is used for extracting a server execution statement from the storage instruction based on the preset ending symbol if the storage instruction is an ending statement;
and the receiving unit is used for sending the server execution statement to the database server and receiving an execution result generated by the database server based on the server execution statement.
In another aspect, the present application also proposes an electronic device, including:
a memory storing computer readable instructions; and
And a processor executing the computer readable instructions stored in the memory to implement the structured query statement processing method.
In another aspect, the present application also proposes a computer readable storage medium having stored therein computer readable instructions that are executed by a processor in an electronic device to implement the structured query statement processing method.
According to the technical scheme, the marking state of the input instruction is identified, whether the input instruction is a complete structured query statement can be detected according to comparison between the marking state and the preset state, further, when the marking state is not the preset state, the input instruction is not the complete structured query statement, the target instruction is read from the preset input interface and written into the preset buffer area through the input instruction, the electronic equipment can conveniently send a plurality of complete structured query statements to the database server for processing, network burden caused by process communication between clients on different machines and the database server is reduced, unnecessary process communication can be avoided by detecting whether the storage instruction is a local command, when the storage instruction is not the local command and the storage instruction is an end statement, the server execution statement is extracted through the end symbol, a plurality of complete structured query statements supported by the database server can be accurately extracted, and therefore, the error execution of the database server can be avoided. According to the application, through the preset ending symbol, a user can set ending sentences in different scenes according to own habits, so that sentence interaction in multiple scenes is satisfied.
Drawings
FIG. 1 is a diagram of an application environment for a structured query statement processing method of the present invention.
FIG. 2 is a flow chart of a preferred embodiment of the structured query statement processing method of the present invention.
FIG. 3 is a flow chart of detecting whether the store instruction is a procedural statement in the structured query statement processing method of the present invention.
FIG. 4 is a functional block diagram of a preferred embodiment of the structured query statement processing apparatus of the present invention.
FIG. 5 is a schematic diagram of an electronic device implementing a preferred embodiment of the method for processing a structured query statement according to the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in detail with reference to the accompanying drawings and specific embodiments.
As shown in FIG. 1, an application environment diagram of the structured query statement processing method of the present invention is shown. The structured query statement processing method is applied to the electronic equipment 1, and the electronic equipment 1 is communicated with a database server. The electronic device 1 may be a client, and any user may input a query instruction in the electronic device 1. The database servers are mainly responsible for transactions and data access between databases.
FIG. 2 is a flow chart of a preferred embodiment of the structured query statement processing method of the present invention. The order of the steps in the flowchart may be changed and some steps may be omitted according to various needs.
The structured query term processing method is applied to one or more electronic devices, wherein the electronic devices are devices capable of automatically performing numerical calculation and/or information processing according to preset or stored computer readable instructions, and the hardware of the electronic devices comprises, but is not limited to, microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASICs), programmable gate arrays (Field-Programmable Gate Array, FPGAs), digital signal processors (Digital Signal Processor, DSPs), embedded devices and the like.
The electronic device may be any electronic product that can interact with a user in a human-computer manner, such as a personal computer, tablet computer, smart phone, personal digital assistant (Personal Digital Assistant, PDA), game console, interactive internet protocol television (Internet Protocol Television, IPTV), smart wearable device, etc.
The electronic device may comprise a network device and/or a user device. Wherein the network device includes, but is not limited to, a single network electronic device, a group of electronic devices made up of multiple network electronic devices, or a Cloud based Cloud Computing (Cloud Computing) made up of a large number of hosts or network electronic devices.
The network in which the electronic device is located includes, but is not limited to: the internet, wide area networks, metropolitan area networks, local area networks, virtual private networks (Virtual Private Network, VPN), etc.
101, in response to a sentence processing request, identifying a marking state of an input instruction read from a preset input interface.
In at least one embodiment of the invention, the statement processing request may trigger generation when there is a need to process a structured query statement. Wherein, the structured query statement requirement may include a query requirement of user table information, and the like.
The preset input interface is a display interface for a user to input a structured query term in the electronic device.
The input instruction refers to an instruction at the next row position of the target log in the preset input interface. The target log is a reading instruction corresponding to a time corresponding to the electronic device when reading the sentence from the preset input interface and a time corresponding to a time when the sentence processing request is generated, wherein the time corresponds to the minimum difference between the time and the time.
The marking state includes an exit state, a state to be input, and the like.
In at least one embodiment of the present invention, the electronic device identifying the tag state of the input instruction read from the preset input interface in response to the sentence processing request includes:
Screening a target log from the read logs of the preset input interface based on the generation moment of the statement processing request;
acquiring a reading instruction from the target log;
based on the reading instruction, acquiring the input instruction from the preset input interface;
detecting whether an interrupt signal is included in the input instruction;
and if the interrupt signal is included in the input instruction, determining the marking state as a preset state.
The generation time refers to a time corresponding to the generation of the sentence processing request.
The reading log refers to log information generated when the electronic equipment reads an instruction from the preset input interface.
The read instruction refers to a specific statement instruction contained in the target log.
The interrupt signal may be any character representing an interrupt, for example, the interrupt signal may be stop or the like.
The preset state is typically set to an exit state.
The target log can be reasonably screened out through the generation moment, the reading instruction can be accurately obtained through the target log, the input instruction can be accurately obtained through the reading instruction, and the identification accuracy of the marking state can be improved by judging whether the input instruction comprises the interrupt signal or not.
In this embodiment, the electronic device reads each line of instructions in the preset input interface when reading the sentence instructions in the preset input interface each time.
In other embodiments, if the interrupt signal is not included in the input instruction, it is determined that the flag state is not the preset state.
102, if the marking state is not the preset state, reading a target instruction from the preset input interface based on the input instruction, and writing the target instruction into a preset buffer zone.
In at least one embodiment of the present invention, the target instruction refers to a sentence instruction in a position next to the input instruction in the preset input interface.
The preset BUFFER may be a BUFFER.
103, if the stored instruction in the preset buffer zone is not a local command, detecting whether the stored instruction is an end statement or not based on a preset ending symbol.
In at least one embodiment of the present invention, the store instruction refers to all instruction statements stored in the preset buffer.
In at least one embodiment of the present invention, before detecting whether the stored instruction is an end statement based on a preset terminator, the method further comprises:
Detecting whether the first character of the storage instruction is a configuration character;
if the first character of the storage instruction is the configuration character, determining that the storage instruction is a local command; or alternatively
And if the first character of the storage instruction is not the configuration character, determining that the storage instruction is not a local command.
Wherein, the configuration character can be set as follows: "\".
Through the configuration characters, whether the storage instruction is a local command can be rapidly identified.
In at least one embodiment of the present invention, the preset terminator includes a first terminator and a second terminator. For example, the first terminator may be set to "; the second terminator may be set to "/".
In at least one embodiment of the present invention, the electronic device detecting whether the stored instruction is an end statement based on a preset end symbol includes:
if the system configuration ending symbol of the preset input interface is initial configuration, detecting whether the storage instruction comprises the first ending symbol;
if the stored instruction comprises the first ending symbol, performing lexical analysis on the stored instruction to obtain a plurality of instruction keywords;
Acquiring target keywords from the plurality of instruction keywords;
detecting whether the storage instruction is a procedural statement according to the target keyword;
if the storage instruction is a procedural statement, determining that the storage instruction is not an ending statement; or alternatively
And if the storage instruction is not a procedural statement or the storage instruction comprises the second ending symbol, determining the storage instruction as an ending statement.
Wherein the initial configuration may be set to "auto".
The plurality of instruction keywords may be obtained after the storing instruction is executed based on the Flex tool.
The target keyword is typically the first instruction keyword in the stored instruction.
The procedural statements may include for loop statements, while loop statements, and the like.
By combining the system configuration ending symbol, the first ending symbol and the second ending symbol, whether the storage instruction is an ending sentence can be accurately identified, and by setting the system configuration ending symbol as the initial configuration, the ending of a single sentence structured sentence and multiple sentences of a procedural language can be automatically identified, so that the usability of a user on the preset input interface is improved.
Specifically, the electronic device detecting whether the stored instruction is a procedural statement according to the target keyword includes:
when the target keyword is a first preset keyword, detecting whether the storage instruction contains a packet statement or not;
if the storage instruction does not contain the packet statement, detecting whether the storage instruction contains a custom function statement or not;
if the storage instruction does not comprise the custom function statement, detecting whether the storage instruction comprises a storage creation statement or not;
if the storage instruction does not include the storage creation statement, detecting whether the storage instruction includes a trigger creation statement;
if the stored instruction does not include the trigger creation statement, determining that the stored instruction is not a procedural statement; or alternatively
If the storage instruction contains the packet statement, the custom function statement or the trigger creation statement, determining that the storage instruction is a procedural statement.
The first preset keyword may be set as a CREATE keyword.
The packet statement may be set to a CREATEPACKAGE statement.
The custom FUNCTION statement may be set as a CREATE FUNCTION statement.
The store creation statement may be set to a CREATE process statement.
The trigger creation statement may be set to a CREATE TRIGGER statement.
In this embodiment, when the target keyword is a first preset keyword, whether the storage instruction is a procedural statement may be accurately determined by detecting whether the storage instruction includes the packet statement, the custom function statement, and the trigger creation statement.
Specifically, the electronic device detecting whether the stored instruction is a procedural statement according to the target keyword further includes:
when the target keyword is a second preset keyword, detecting whether the stored instruction contains anonymous block sentences based on the second preset keyword or not;
if the stored instruction does not contain the anonymous block statement based on the second preset keyword, determining that the stored instruction is not a procedural statement; or alternatively
And if the stored instruction contains anonymous block statements based on the second preset keywords, determining the stored instruction as a procedural statement.
Wherein the second preset keyword may be set as a DECALRE keyword.
In this embodiment, when the target keyword is the second preset keyword, whether the storage instruction is a procedural statement may be accurately determined by detecting whether the storage instruction includes an anonymous block statement based on the second preset keyword.
Specifically, the electronic device detecting whether the stored instruction is a procedural statement according to the target keyword further includes:
when the target keyword is a third preset keyword, detecting whether the stored instruction contains anonymous block sentences based on the third preset keyword or not;
if the stored instruction does not contain the anonymous block statement based on the third preset keyword, determining that the stored instruction is not a procedural statement; or alternatively
And if the stored instruction contains anonymous block sentences based on the third preset keywords, determining the stored instruction as a procedural sentence.
Wherein, the third preset keyword may be set as a BEGIN keyword.
In this embodiment, when the target keyword is the third preset keyword, whether the storage instruction is a procedural statement may be accurately determined by detecting whether the storage instruction includes an anonymous block statement based on the third preset keyword.
FIG. 3 is a flow chart of the method for processing a structured query statement according to the present invention for detecting whether the stored instruction is a procedural statement.
In fig. 3, the target keyword of the storage instruction is the first Token, when the first Token is the CREATE keyword, detecting whether the storage instruction includes the CREATEPACKAGE statement, if not, detecting whether the storage instruction includes the CREATE FUNCTION statement, if not, detecting whether the storage instruction includes the CREATE TRIGGER statement, and if not, determining that the storage instruction is not a procedural statement; if the store instruction includes the CREATEPACKAGE statement, the CREATE FUNCTION statement, the CREATE process statement, or the CREATE TRIGGER statement, then the store instruction is determined to be a procedural statement.
When the first Token is the DECALRE keyword, detecting whether the stored instruction comprises an anonymous block statement of the DECALRE keyword, if not, determining that the stored instruction is not a procedural statement; and if the storage instruction comprises the anonymous block statement of the DECARRE key word, determining the storage instruction as a procedural statement.
When the first Token is the BEGIN keyword, detecting whether the stored instruction comprises an anonymous block statement of the BEGIN keyword, if not, determining that the stored instruction is not a procedural statement; and if the storage instruction comprises the anonymous block statement of the BEGIN keyword, determining the storage instruction as a procedural statement.
And when the first Token is other keywords, determining that the stored instruction is not a procedural statement.
In at least one embodiment of the present invention, the electronic device detecting whether the stored instruction is an end statement based on a preset end symbol further includes:
if the system configuration ending symbol is the first ending symbol, detecting whether the first ending symbol is included in the storage instruction;
if the stored instruction comprises the first ending symbol, determining the stored instruction as an ending sentence; or alternatively
And if the first ending symbol is not included in the storage instruction, determining that the storage instruction is not an ending statement.
By self-defining the system configuration ending symbol, the user can designate different sentence ending symbols by himself, thereby meeting the real-time interactive input of sentences of different ending symbols in various scenes.
In at least one embodiment of the present invention, the electronic device detecting whether the stored instruction is an end statement based on a preset end symbol further includes:
if the system configuration ending symbol is the second ending symbol, detecting whether the second ending symbol is included in the storage instruction;
if the stored instruction comprises the second ending symbol, determining the stored instruction as an ending sentence; or alternatively
And if the second ending symbol is not included in the storage instruction, determining that the storage instruction is not an ending statement.
In at least one embodiment of the present invention, if the stored instruction is not an end statement, the electronic device reads a next line statement of the target instruction from the preset input interface.
104, if the stored instruction is an end statement, extracting a server execution statement from the stored instruction based on the preset ending symbol.
In at least one embodiment of the present invention, the server execution statement may be a single-sentence structured statement or a multi-sentence in procedural language.
In at least one embodiment of the present invention, the electronic device extracting the server execution statement from the stored instruction based on the preset terminator includes:
if the system configuration ending symbol is the initial configuration or the second ending symbol, extracting an instruction with a character position before the ending position of the second ending symbol from the stored instruction as the server execution statement; or alternatively
And if the system configuration ending symbol is the first ending symbol, extracting the server execution statement from the storage instruction based on the first ending symbol.
By the implementation mode, the server execution statement can be accurately extracted from the storage instruction.
And 105, sending the server execution statement to the database server, and receiving an execution result generated by the database server based on the server execution statement.
It should be emphasized that, to further ensure the privacy and security of the execution results, the execution results may also be stored in a node of a blockchain.
In at least one embodiment of the present application, the execution result refers to a result generated after the database runs the server execution statement. For example, the server execution statement may be information of all user tables, and the execution result is: information of all user tables, wherein the information of the user tables may include data information of transaction data, payment data, business data, purchase data, and the like.
According to the technical scheme, the marking state of the input instruction is identified, whether the input instruction is a complete structured query statement can be detected according to comparison between the marking state and the preset state, further, when the marking state is not the preset state, the input instruction is not the complete structured query statement, the target instruction is read from the preset input interface and written into the preset buffer area through the input instruction, the electronic equipment can conveniently send a plurality of complete structured query statements to the database server for processing, network burden caused by process communication between clients on different machines and the database server is reduced, unnecessary process communication can be avoided by detecting whether the storage instruction is a local command, when the storage instruction is not the local command and the storage instruction is an end statement, the server execution statement is extracted through the end symbol, a plurality of complete structured query statements supported by the database server can be accurately extracted, and therefore, the error execution of the database server can be avoided. According to the application, through the preset ending symbol, a user can set ending sentences in different scenes according to own habits, so that sentence interaction in multiple scenes is satisfied.
FIG. 4 is a functional block diagram of a preferred embodiment of the structured query statement processing apparatus of the present invention. The structured query term processing device 11 includes an identification unit 110, a writing unit 111, a detection unit 112, an extraction unit 113, and a receiving unit 114. The module/unit referred to herein is a series of computer readable instructions capable of being retrieved by the processor 13 and performing a fixed function and stored in the memory 12. In the present embodiment, the functions of the respective modules/units will be described in detail in the following embodiments.
The structured query statement processing means 11 is run on an electronic device which is in communication with a database server.
An identification unit 110 for identifying a mark state of an input instruction read from a preset input interface in response to a sentence processing request;
a writing unit 111, configured to read a target instruction from the preset input interface based on the input instruction and write the target instruction into a preset buffer area if the marking state is not a preset state;
a detecting unit 112, configured to detect whether the stored instruction in the preset buffer is an end statement based on a preset ending symbol if the stored instruction is not a local command;
An extracting unit 113, configured to extract a server execution statement from the storage instruction based on the preset ending symbol if the storage instruction is an ending statement;
and a receiving unit 114, configured to send the server execution statement to the database server, and receive an execution result generated by the database server based on the server execution statement.
In at least one embodiment of the present invention, the identifying unit 110 is further configured to screen out a target log from the read logs of the preset input interface based on a generation time of the sentence processing request;
acquiring a reading instruction from the target log;
based on the reading instruction, acquiring the input instruction from the preset input interface;
detecting whether an interrupt signal is included in the input instruction;
and if the input instruction comprises the interrupt signal, determining the marking state as the preset state.
In at least one embodiment of the present invention, the preset ending symbol includes a first ending symbol and a second ending symbol, and the detecting unit 112 is further configured to detect whether the storage instruction includes the first ending symbol if the system configuration ending symbol of the preset input interface is an initial configuration;
If the stored instruction comprises the first ending symbol, performing lexical analysis on the stored instruction to obtain a plurality of instruction keywords;
acquiring target keywords from the plurality of instruction keywords;
detecting whether the storage instruction is a procedural statement according to the target keyword;
if the storage instruction is a procedural statement, determining that the storage instruction is not an ending statement; or alternatively
And if the storage instruction is not a procedural statement or the storage instruction comprises the second ending symbol, determining the storage instruction as an ending statement.
In at least one embodiment of the present invention, the detecting unit 112 is further configured to detect whether the stored instruction includes a packet statement when the target keyword is a first preset keyword;
if the storage instruction does not contain the packet statement, detecting whether the storage instruction contains a custom function statement or not;
if the storage instruction does not comprise the custom function statement, detecting whether the storage instruction comprises a storage creation statement or not;
if the storage instruction does not include the storage creation statement, detecting whether the storage instruction includes a trigger creation statement;
If the stored instruction does not include the trigger creation statement, determining that the stored instruction is not a procedural statement; or alternatively
If the storage instruction contains the packet statement, the custom function statement or the trigger creation statement, determining that the storage instruction is a procedural statement.
In at least one embodiment of the present invention, the detecting unit 112 is further configured to detect, when the target keyword is a second preset keyword, whether the stored instruction includes an anonymous block statement based on the second preset keyword;
if the stored instruction does not contain the anonymous block statement based on the second preset keyword, determining that the stored instruction is not a procedural statement; or alternatively
And if the stored instruction contains anonymous block statements based on the second preset keywords, determining the stored instruction as a procedural statement.
In at least one embodiment of the present invention, the detecting unit 112 is further configured to detect, when the target keyword is a third preset keyword, whether the stored instruction includes an anonymous block statement based on the third preset keyword;
if the stored instruction does not contain the anonymous block statement based on the third preset keyword, determining that the stored instruction is not a procedural statement; or alternatively
And if the stored instruction contains anonymous block sentences based on the third preset keywords, determining the stored instruction as a procedural sentence.
In at least one embodiment of the present application, the extracting unit 113 is further configured to extract, from the stored instruction, an instruction with a character position before an end position of the second terminator as the server execution statement, if the system configuration terminator is the initial configuration or the second terminator; or alternatively
And if the system configuration ending symbol is the first ending symbol, extracting the server execution statement from the storage instruction based on the first ending symbol.
According to the technical scheme, the marking state of the input instruction is identified, whether the input instruction is a complete structured query statement can be detected according to comparison between the marking state and the preset state, further, when the marking state is not the preset state, the input instruction is not the complete structured query statement, the target instruction is read from the preset input interface and written into the preset buffer area through the input instruction, the electronic equipment can conveniently send a plurality of complete structured query statements to the database server for processing, network burden caused by process communication between clients on different machines and the database server is reduced, unnecessary process communication can be avoided by detecting whether the storage instruction is a local command, when the storage instruction is not the local command and the storage instruction is an end statement, the server execution statement is extracted through the end symbol, a plurality of complete structured query statements supported by the database server can be accurately extracted, and therefore, the error execution of the database server can be avoided. According to the application, through the preset ending symbol, a user can set ending sentences in different scenes according to own habits, so that sentence interaction in multiple scenes is satisfied.
Fig. 5 is a schematic structural diagram of an electronic device according to a preferred embodiment of the present invention for implementing the method for processing a structured query statement.
In one embodiment of the invention, the electronic device 1 includes, but is not limited to, a memory 12, a processor 13, and computer readable instructions, such as a structured query statement processing program, stored in the memory 12 and executable on the processor 13.
It will be appreciated by those skilled in the art that the schematic diagram is merely an example of the electronic device 1 and does not constitute a limitation of the electronic device 1, and may include more or less components than illustrated, or may combine certain components, or different components, e.g. the electronic device 1 may further include input-output devices, network access devices, buses, etc.
The processor 13 may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. The general purpose processor may be a microprocessor or the processor may be any conventional processor, etc., and the processor 13 is an operation core and a control center of the electronic device 1, connects various parts of the entire electronic device 1 using various interfaces and lines, and executes an operating system of the electronic device 1 and various installed applications, program codes, etc.
Illustratively, the computer readable instructions may be partitioned into one or more modules/units that are stored in the memory 12 and executed by the processor 13 to complete the present invention. The one or more modules/units may be a series of computer readable instructions capable of performing a specific function, the computer readable instructions describing a process of executing the computer readable instructions in the electronic device 1. For example, the computer readable instructions may be divided into an identification unit 110, a writing unit 111, a detection unit 112, an extraction unit 113, and a receiving unit 114.
The memory 12 may be used to store the computer readable instructions and/or modules, and the processor 13 may implement various functions of the electronic device 1 by executing or executing the computer readable instructions and/or modules stored in the memory 12 and invoking data stored in the memory 12. The memory 12 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program (such as a sound playing function, an image playing function, etc.) required for at least one function, and the like; the storage data area may store data created according to the use of the electronic device, etc. Memory 12 may include non-volatile and volatile memory, such as: a hard disk, memory, plug-in hard disk, smart Media Card (SMC), secure Digital (SD) Card, flash Card (Flash Card), at least one disk storage device, flash memory device, or other storage device.
The memory 12 may be an external memory and/or an internal memory of the electronic device 1. Further, the memory 12 may be a physical memory, such as a memory bank, a TF Card (Trans-flash Card), or the like.
The integrated modules/units of the electronic device 1 may be stored in a computer readable storage medium if implemented in the form of software functional units and sold or used as separate products. Based on such understanding, the present invention may also be implemented by implementing all or part of the processes in the methods of the embodiments described above, by instructing the associated hardware by means of computer readable instructions, which may be stored in a computer readable storage medium, the computer readable instructions, when executed by a processor, implementing the steps of the respective method embodiments described above.
Wherein the computer readable instructions comprise computer readable instruction code which may be in the form of source code, object code, executable files, or in some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying the computer readable instruction code, a recording medium, a USB flash disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory).
The blockchain is a novel application mode of computer technologies such as distributed structured query statement processing, point-to-point transmission, consensus mechanism, encryption algorithm and the like. The Blockchain (Blockchain), which is essentially a decentralised database, is a string of data blocks that are generated by cryptographic means in association, each data block containing a batch of information of network transactions for verifying the validity of the information (anti-counterfeiting) and generating the next block. The blockchain may include a blockchain underlying platform, a platform product services layer, an application services layer, and the like.
In connection with fig. 2, the memory 12 in the electronic device 1 stores computer readable instructions implementing a structured query statement processing method, the processor 13 being executable to implement:
in response to the sentence processing request, identifying a marking state of an input instruction read from a preset input interface;
if the marking state is not the preset state, reading a target instruction from the preset input interface based on the input instruction, and writing the target instruction into a preset buffer zone;
if the storage instruction in the preset buffer zone is not a local command, detecting whether the storage instruction is an end statement or not based on a preset ending symbol;
If the storage instruction is an ending statement, extracting a server execution statement from the storage instruction based on the preset ending symbol;
and sending the server execution statement to a database server, and receiving an execution result generated by the database server based on the server execution statement.
In particular, the specific implementation method of the processor 13 on the computer readable instructions may refer to the description of the relevant steps in the corresponding embodiment of fig. 1, which is not repeated herein.
In the several embodiments provided in the present invention, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is merely a logical function division, and there may be other manners of division when actually implemented.
The computer readable storage medium has stored thereon computer readable instructions, wherein the computer readable instructions when executed by the processor 13 are configured to implement the steps of:
in response to the sentence processing request, identifying a marking state of an input instruction read from a preset input interface;
if the marking state is not the preset state, reading a target instruction from the preset input interface based on the input instruction, and writing the target instruction into a preset buffer zone;
If the storage instruction in the preset buffer zone is not a local command, detecting whether the storage instruction is an end statement or not based on a preset ending symbol;
if the storage instruction is an ending statement, extracting a server execution statement from the storage instruction based on the preset ending symbol;
and sending the server execution statement to a database server, and receiving an execution result generated by the database server based on the server execution statement.
The modules described as separate components may or may not be physically separate, and components shown as modules may or may not be physical units, may be located in one place, or may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional module in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units can be realized in a form of hardware or a form of hardware and a form of software functional modules.
The present embodiments are, therefore, to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned.
Furthermore, it is evident that the word "comprising" does not exclude other elements or steps, and that the singular does not exclude a plurality. The units or means may also be implemented by one unit or means in software or hardware. The terms first, second, etc. are used to denote a name, but not any particular order.
Finally, it should be noted that the above-mentioned embodiments are merely for illustrating the technical solution of the present invention and not for limiting the same, and although the present invention has been described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications and equivalents may be made to the technical solution of the present invention without departing from the spirit and scope of the technical solution of the present invention.

Claims (10)

1. A structured query term processing method applied to an electronic device, wherein the electronic device is in communication with a database server, the structured query term processing method comprising:
In response to the sentence processing request, identifying a marking state of an input instruction read from a preset input interface;
if the marking state is not the preset state, reading a target instruction from the preset input interface based on the input instruction, and writing the target instruction into a preset buffer zone;
if the storage instruction in the preset buffer zone is not a local command, detecting whether the storage instruction is an end statement or not based on a preset ending symbol;
if the storage instruction is an ending statement, extracting a server execution statement from the storage instruction based on the preset ending symbol;
and sending the server execution statement to the database server, and receiving an execution result generated by the database server based on the server execution statement.
2. The structured query statement processing method of claim 1, wherein identifying the tag state of the input instruction read from the preset input interface in response to the statement processing request comprises:
screening a target log from the read logs of the preset input interface based on the generation moment of the statement processing request;
acquiring a reading instruction from the target log;
Based on the reading instruction, acquiring the input instruction from the preset input interface;
detecting whether an interrupt signal is included in the input instruction;
and if the input instruction comprises the interrupt signal, determining the marking state as the preset state.
3. The structured query statement processing method of claim 1, wherein the preset ending symbol comprises a first ending symbol and a second ending symbol, and wherein detecting whether the store instruction is an ending statement based on the preset ending symbol comprises:
if the system configuration ending symbol of the preset input interface is initial configuration, detecting whether the storage instruction comprises the first ending symbol;
if the stored instruction comprises the first ending symbol, performing lexical analysis on the stored instruction to obtain a plurality of instruction keywords;
acquiring target keywords from the plurality of instruction keywords;
detecting whether the storage instruction is a procedural statement according to the target keyword;
if the storage instruction is a procedural statement, determining that the storage instruction is not an ending statement; or alternatively
And if the storage instruction is not a procedural statement or the storage instruction comprises the second ending symbol, determining the storage instruction as an ending statement.
4. The structured query statement processing method of claim 3, wherein said detecting whether the store instruction is a procedural statement based on the target keyword comprises:
when the target keyword is a first preset keyword, detecting whether the storage instruction contains a packet statement or not;
if the storage instruction does not contain the packet statement, detecting whether the storage instruction contains a custom function statement or not;
if the storage instruction does not comprise the custom function statement, detecting whether the storage instruction comprises a storage creation statement or not;
if the storage instruction does not include the storage creation statement, detecting whether the storage instruction includes a trigger creation statement;
if the stored instruction does not include the trigger creation statement, determining that the stored instruction is not a procedural statement; or alternatively
If the storage instruction contains the packet statement, the custom function statement or the trigger creation statement, determining that the storage instruction is a procedural statement.
5. The structured query statement processing method of claim 3, wherein said detecting whether the store instruction is a procedural statement based on the target keyword further comprises:
When the target keyword is a second preset keyword, detecting whether the stored instruction contains anonymous block sentences based on the second preset keyword or not;
if the stored instruction does not contain the anonymous block statement based on the second preset keyword, determining that the stored instruction is not a procedural statement; or alternatively
And if the stored instruction contains anonymous block statements based on the second preset keywords, determining the stored instruction as a procedural statement.
6. The structured query statement processing method of claim 3, wherein said detecting whether the store instruction is a procedural statement based on the target keyword further comprises:
when the target keyword is a third preset keyword, detecting whether the stored instruction contains anonymous block sentences based on the third preset keyword or not;
if the stored instruction does not contain the anonymous block statement based on the third preset keyword, determining that the stored instruction is not a procedural statement; or alternatively
And if the stored instruction contains anonymous block sentences based on the third preset keywords, determining the stored instruction as a procedural sentence.
7. The structured query term processing method of claim 3 wherein said extracting server execution terms from said stored instructions based on said preset ending symbol comprises:
If the system configuration ending symbol is the initial configuration or the second ending symbol, extracting an instruction with a character position before the ending position of the second ending symbol from the stored instruction as the server execution statement; or alternatively
And if the system configuration ending symbol is the first ending symbol, extracting the server execution statement from the storage instruction based on the first ending symbol.
8. A structured query statement processing apparatus operable on an electronic device, the electronic device in communication with a database server, the structured query statement processing apparatus comprising:
the identification unit is used for responding to the sentence processing request and identifying the marking state of the input instruction read from the preset input interface;
the writing unit is used for reading a target instruction from the preset input interface based on the input instruction and writing the target instruction into a preset buffer zone if the marking state is not a preset state;
the detection unit is used for detecting whether the storage instruction in the preset buffer area is an end statement or not based on a preset ending symbol if the storage instruction in the preset buffer area is not a local command;
The extraction unit is used for extracting a server execution statement from the storage instruction based on the preset ending symbol if the storage instruction is an ending statement;
and the receiving unit is used for sending the server execution statement to the database server and receiving an execution result generated by the database server based on the server execution statement.
9. An electronic device, the electronic device comprising:
a memory storing computer readable instructions; and
A processor executing computer readable instructions stored in the memory to implement the structured query statement processing method of any one of claims 1 to 7.
10. A computer-readable storage medium, characterized by: stored in the computer readable storage medium are computer readable instructions that are executed by a processor in an electronic device to implement the structured query statement processing method of any one of claims 1 to 7.
CN202310593482.5A 2023-05-24 2023-05-24 Structured query statement processing method, device, equipment and storage medium Pending CN116628005A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310593482.5A CN116628005A (en) 2023-05-24 2023-05-24 Structured query statement processing method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310593482.5A CN116628005A (en) 2023-05-24 2023-05-24 Structured query statement processing method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116628005A true CN116628005A (en) 2023-08-22

Family

ID=87641275

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310593482.5A Pending CN116628005A (en) 2023-05-24 2023-05-24 Structured query statement processing method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116628005A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118203842A (en) * 2024-03-20 2024-06-18 北京畅游创想软件技术有限公司 Server data processing method, related equipment and double-circulation buffer system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118203842A (en) * 2024-03-20 2024-06-18 北京畅游创想软件技术有限公司 Server data processing method, related equipment and double-circulation buffer system

Similar Documents

Publication Publication Date Title
CN112417096B (en) Question-answer pair matching method, device, electronic equipment and storage medium
CN112686036B (en) Risk text recognition method and device, computer equipment and storage medium
CN112183091A (en) Question and answer pair generation method and device, electronic equipment and readable storage medium
CN111797351A (en) Page data management method and device, electronic equipment and medium
CN112632163B (en) Big data report export method and related equipment
CN112053143B (en) Fund routing method, apparatus, electronic device and storage medium
CN116628005A (en) Structured query statement processing method, device, equipment and storage medium
CN116089535A (en) Data synchronization method, device, equipment and storage medium
CN112711398A (en) Method, device and equipment for generating buried point file and storage medium
CN114418398A (en) Scene task development method, device, equipment and storage medium
CN113420143B (en) Method, device, equipment and storage medium for generating document abstract
CN114329095A (en) System logic diagram generation method, device, equipment and storage medium
CN112199483B (en) Information input assisting method and device, electronic equipment and storage medium
CN111933241B (en) Medical data analysis method, device, electronic equipment and storage medium
US11803796B2 (en) System, method, electronic device, and storage medium for identifying risk event based on social information
CN112819305A (en) Service index analysis method, device, equipment and storage medium
CN113627186B (en) Entity relation detection method based on artificial intelligence and related equipment
CN115952201A (en) Data query method, device, system and storage medium
CN114187050A (en) Card and ticket issuing monitoring method, device, equipment and storage medium
CN114943474A (en) Research and development workload detection method, device, equipment and storage medium
CN111679862A (en) Cloud host shutdown method and device, electronic equipment and medium
CN113282218A (en) Multi-dimensional report generation method, device, equipment and storage medium
CN113326365A (en) Reply statement generation method, device, equipment and storage medium
CN114490260B (en) System index generation method, device, proxy server and storage medium
CN114398104B (en) Script processing method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination