CN106649736B - Automatic number generation method in general database - Google Patents

Automatic number generation method in general database Download PDF

Info

Publication number
CN106649736B
CN106649736B CN201611209107.2A CN201611209107A CN106649736B CN 106649736 B CN106649736 B CN 106649736B CN 201611209107 A CN201611209107 A CN 201611209107A CN 106649736 B CN106649736 B CN 106649736B
Authority
CN
China
Prior art keywords
automatic
database
generation method
number generation
generated
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.)
Active
Application number
CN201611209107.2A
Other languages
Chinese (zh)
Other versions
CN106649736A (en
Inventor
曹亮
舒红平
刘魁
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chengdu University of Information Technology
Original Assignee
Chengdu University of Information Technology
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 Chengdu University of Information Technology filed Critical Chengdu University of Information Technology
Priority to CN201611209107.2A priority Critical patent/CN106649736B/en
Publication of CN106649736A publication Critical patent/CN106649736A/en
Application granted granted Critical
Publication of CN106649736B publication Critical patent/CN106649736B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases

Landscapes

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

Abstract

The invention discloses an automatic number generation method in a general database, which acquires the current number in a specified database; according to the set step length, carrying out self-increment on the basis of the current number to obtain a generated number; outputting the generated serial number and storing the serial number into a specified relational database; the method comprises the following steps: (1) appointing a service table needing to generate a number and a corresponding field; (2) setting an automatic numbering rule format; (3) setting the step length of automatic numbering; (4) processing rules; (5) dynamically generating a query statement; (6) generating a number; (7) and outputting the generated number and saving the number to a specified relational database. The method is simple, is easy to operate, and improves the generation efficiency of the serial number.

Description

Automatic number generation method in general database
Technical Field
The invention belongs to the technical field of data processing, and particularly relates to an automatic number generation method in a general database.
Background
When a number is generated, due to operations such as multi-user concurrency, manual modification, batch processing and the like, abnormal data such as a call number, a double number and the like are often generated, a general number generation technology only processes the concurrent situation, and a perfect mechanism is lacked to control the validity of the number under various possible situations. In the technology of generating the numbers of the related forms, a client/server system respectively providing display for generating preview numbers and storing formal numbers is provided, so that the problem of abnormal numbers possibly occurring in a network concurrent environment is solved, but a method for guaranteeing the validity of the numbers under abnormal business processes such as manual modification and batch processing is not provided, and an abnormal processing measure after error data occurs is also not provided.
According to the above contents, the form types of different services in the enterprise management software, different user requirements and application scenarios need a more complete number generation method, but the current technology is difficult to achieve the following technical effects:
1. adaptability of numbering rules: the rules can be flexibly configured or expanded to adapt to different user scenes and different application scenes;
2. validity of generation number: the method generates rules predefined by the numbering rules, guarantees uniqueness and continuity in the service data, and can accurately and unmistakably reflect corresponding service meanings.
Disclosure of Invention
The invention aims to provide a method for generating automatic numbers in a general database, and aims to solve the problems of universality, effectiveness and continuity of automatic numbers in different databases.
The invention is realized in such a way that an automatic number generation method in a general database obtains the current number in a specified database; according to the set step length, carrying out self-increment on the basis of the current number to obtain a generated number; and outputting the generated number and saving the number to a specified relational database.
Further, the method for generating the automatic number in the universal database comprises the following steps:
(1) appointing a service table needing to generate a number and a corresponding field;
(2) setting an automatic numbering rule format;
(3) setting the step length of automatic numbering;
(4) processing rules;
(5) dynamically generating a query statement;
(6) generating a number;
(7) and outputting the generated number and saving the number to a specified relational database.
Further, the setting of the format of the automatic numbering rule includes:
a plurality of n represents a self-increasing sequence;
yyyy represents year;
mm represents a month;
dd denotes day;
ww represents weeks;
hh represents hours;
mi represents a point;
ss denotes seconds.
Further, the rule processing includes:
formatting dates, and combining different formats according to the year, month and day;
and acquiring the starting position, the ending position and the length of the self-increment sequence in the rule format in the automatic numbering rule format.
Further, the dynamically generating a query statement comprises:
a service table with the specified number to be generated is taken as a data table to be inquired;
intercepting a field corresponding to a service table which is appointed to generate a number according to the initial position and the ending position of the acquired self-increment sequence, and solving the maximum field;
and acquiring the character content before the self-increment sequence and the character content after the self-increment sequence according to the initial position and the ending position of the replaced code and the self-increment sequence, and taking the acquired two character contents as the query content of the field generating the number.
Further, the number generation includes:
acquiring the maximum number in the current service table according to the dynamic query statement;
accumulating the generated numbers according to the set step length of the automatic numbers;
the data length can be specified for each numbering rule parameter, and when the specified data length is less than the set length, the data length can be automatically filled by using a specific character.
The invention also aims to provide an oracle database automatic number generation method applying the automatic number generation method in the general database.
The invention also aims to provide an automatic serial number generation method for the mysql database, which applies the automatic serial number generation method in the universal database.
The invention also aims to provide an automatic serial number generation method of the sqlserver database, which applies the automatic serial number generation method in the universal database.
The invention also aims to provide a db2 database automatic number generation method applying the automatic number generation method in the universal database.
The automatic number generation method in the general database effectively solves the influence of number skipping and number duplication caused by concurrent operation of number generation in the prior art; the invention can ensure the adaptability of the numbering rules, namely the numbering rules can be flexibly changed or expanded according to different user requirements and different scenes, and can also ensure the validity of the generated numbers, namely the generated numbers accord with the predefined numbering rules, thereby ensuring the uniqueness and the continuity in the service data. The invention can be used as a component for developers across databases.
Drawings
Fig. 1 is a flowchart of an automatic number generation method in a universal database according to an embodiment of the present invention.
Fig. 2 is a flowchart of example 1 according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is further described in detail with reference to the following embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The method comprises the steps of obtaining a current number in a designated database; the specified database is a common relational database, such as oracle, mysql, sqlserver, db2 and the like; according to the set step length, carrying out self-increment on the basis of the current number to obtain a generated number; and outputting the generated number and storing the number into the specified relational database.
The following detailed description of the principles of the invention is provided in connection with the accompanying drawings.
As shown in fig. 1, the method for generating an automatic number in a universal database according to an embodiment of the present invention includes the following steps:
s101: appointing a service table needing to generate a number and a corresponding field;
s102: setting an automatic numbering rule format;
s103: setting the step length of automatic numbering;
s104: processing rules;
s105: dynamically generating a query statement;
s106: generating a number;
s107: and outputting the generated number and saving the number to a specified relational database.
The application of the principles of the present invention will now be further described with reference to specific embodiments
Example 1:
as shown in fig. 2, the method for generating an automatic number in a universal database according to an embodiment of the present invention includes the following steps:
1. appointing a service table needing to generate a number and a corresponding field; automatically generating CONTRACT numbers according to rules if necessary, wherein the generated CONTRACT numbers correspond to a CONTRACT table (T _ CONTRACT) and a corresponding CONTRACT number field (CONTRACT _ SNO)
2. Setting an automatic numbering rule format; the rule format is YYYMM-NNNN, as numbered 201606-.
a) Wherein in the regular format, a plurality of n represents a self-increment sequence;
b) yyyy represents year;
c) mm represents a month;
d) dd denotes day;
e) ww represents weeks;
f) hh represents hours;
g) mi represents a point;
h) ss denotes second;
3. setting the step length of automatic numbering; setting the step size to 1 as required by the example, it means that every time a contract number is added, the accumulation is 1, the accumulated content is only performed in NNNN, if YYYYMM occurs, the recounting is performed, such as 201606-.
4. Processing rules;
the 4.1 date is formatted, and different formats are combined according to the year, month, day and the like, such as '1970-01-01', and is formatted into '197001' according to 'yyyymm'; (decision rule: decide if yyyy is in the automatic numbering rule format, if it occurs, replace it with the current year; other time-related symbols are processed using the same method);
replacing the information of yyy, mm, dd, ww, hh, mi, ss by an alternative method as required by the examples, such as 201608-NNNNNN after replacing with the current time, and 201608-
4.2, acquiring the starting position, the ending position and the length of the self-increment sequence (n) in the rule format in the automatic numbering rule format;
according to the example, the starting position, the ending position and the length of n in the rule format are inquired by using an inquiry method, for example, the starting position is 7, the ending position is 10, and the length is 4
5. Dynamically generating query statements
5.1, a service table with the specified number to be generated is taken as a data table to be inquired;
5.2 intercepting the corresponding field of the business table which is appointed to generate the number according to the initial position and the ending position of the self-increment sequence obtained in the step 4.2, and solving the maximum value;
the dynamic statements are stitched using a standard structured query language,
and 5.3, acquiring the character content before the self-increment sequence and the character content after the self-increment sequence according to the code after 4.1 replacements and the starting position and the ending position of the self-increment sequence in 4.2, and taking the two acquired character contents as the query content of the field for generating the number.
According to the information needed by the example and generated in the previous steps, the following structured query language is dynamically generated,
select max(to_mumber(substr(CONTRACT_SNO,7,4)))maxcolname from T_CONTRACT where CONTRACT_SNO like‘%201608-%’
6. number generation
6.1 obtaining the maximum number in the current business table according to the dynamic query statement of 5; obtaining the current maximum number, e.g. 0003, as required by the instance
6.2 according to the step length of the set automatic number in the step 3, accumulating the generated number; after the redundant 0 is replaced according to the requirement of the example, the type is carried out according to the step length of 1 to obtain 4
And 6.3, the data length of each numbering rule parameter can be specified in the generated number, and when the specified data is less than the set length, the data can be automatically supplemented by using a specific character. Formatting the parameter value '4' according to a rule of '4-bit prefix' required by an example to obtain '0004';
7. and outputting the generated number and storing the number into the specified relational database.
The current contract number 201608-0004 is obtained by combining 201608-generated in 4.1 and 0004 generated in 6.3 according to the requirement of the example, and the number is stored in the designated relational database according to the business requirement.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents and improvements made within the spirit and principle of the present invention are intended to be included within the scope of the present invention.

Claims (9)

1. The automatic number generation method in the general database is characterized in that the automatic number generation method in the general database acquires the current number in the appointed database; according to the set step length, carrying out self-increment on the basis of the current number to obtain a generated number; outputting the generated serial number and storing the serial number into a specified relational database;
the method for generating the automatic number in the universal database comprises the following steps:
(1) appointing a service table needing to generate a number and a corresponding field;
(2) setting an automatic numbering rule format;
(3) setting the step length of automatic numbering;
(4) processing rules;
(5) dynamically generating a query statement;
(6) generating a number;
(7) and outputting the generated number and saving the number to a specified relational database.
2. The method for automatic numbering generation in a universal database according to claim 1, wherein said setting the format of the automatic numbering rule comprises:
a plurality of n represents a self-increasing sequence;
yyyy represents year;
mm represents a month;
dd denotes day;
ww represents weeks;
hh represents hours;
mi represents a point;
ss denotes seconds.
3. The method for automatic number generation in a universal database according to claim 1, wherein the rule processing comprises:
formatting dates, and combining different formats according to the year, month and day;
and acquiring the starting position, the ending position and the length of the self-increment sequence in the rule format in the automatic numbering rule format.
4. The method of automatic number generation in a universal database as claimed in claim 1, wherein said dynamically generating a query statement comprises:
a service table with the specified number to be generated is taken as a data table to be inquired;
intercepting a field corresponding to a service table which is appointed to generate a number according to the initial position and the ending position of the acquired self-increment sequence, and solving the maximum field;
and acquiring the character content before the self-increment sequence and the character content after the self-increment sequence according to the initial position and the ending position of the replaced code and the self-increment sequence, and taking the acquired two character contents as the query content of the field generating the number.
5. The method for automatic number generation in a universal database according to claim 1, wherein the number generation comprises:
acquiring the maximum number in the current service table according to the dynamic query statement;
accumulating the generated numbers according to the set step length of the automatic numbers;
the data length can be specified for each numbering rule parameter, and when the specified data length is less than the set length, the data length can be automatically filled by using a specific character.
6. An oracle database automatic number generation method applying the automatic number generation method in the universal database according to any one of claims 1 to 5.
7. An automatic serial number generation method for mysql database, which applies the automatic serial number generation method in the universal database according to any one of claims 1 to 5.
8. An automatic serial number generation method of an sqlserver database, which applies the automatic serial number generation method in the universal database according to any one of claims 1 to 5.
9. A db2 database automatic numbering generation method applying the automatic numbering generation method in the universal database according to any one of claims 1-5.
CN201611209107.2A 2016-12-23 2016-12-23 Automatic number generation method in general database Active CN106649736B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611209107.2A CN106649736B (en) 2016-12-23 2016-12-23 Automatic number generation method in general database

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611209107.2A CN106649736B (en) 2016-12-23 2016-12-23 Automatic number generation method in general database

Publications (2)

Publication Number Publication Date
CN106649736A CN106649736A (en) 2017-05-10
CN106649736B true CN106649736B (en) 2020-04-17

Family

ID=58828251

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611209107.2A Active CN106649736B (en) 2016-12-23 2016-12-23 Automatic number generation method in general database

Country Status (1)

Country Link
CN (1) CN106649736B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107908772B (en) * 2017-11-30 2020-10-30 中国人民解放军陆军工程大学 WebSQL multifunctional sequence realization method and device
CN108763172A (en) * 2018-05-18 2018-11-06 郑州云海信息技术有限公司 The method and device of customization sequence number is automatically generated under a kind of linux system
CN112632117A (en) * 2020-12-30 2021-04-09 广州华多网络科技有限公司 Method and device for processing serial number data, electronic equipment and storage medium
CN114615232B (en) * 2022-05-12 2022-08-12 南京赛宁信息技术有限公司 Method and system for generating visitor identification of active defense gateway
CN115510815B (en) * 2022-11-17 2023-03-28 山东未来网络研究院(紫金山实验室工业互联网创新应用基地) Rule-based identification generation method and apparatus

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103092886A (en) * 2011-11-07 2013-05-08 中国移动通信集团公司 Achieving method, device and system for data query operation
CN105589894A (en) * 2014-11-13 2016-05-18 腾讯数码(深圳)有限公司 Document index establishing method and device as well as document retrieving method and device
CN105786882A (en) * 2014-12-24 2016-07-20 阿里巴巴集团控股有限公司 Data table identifier generation method and device, data writing method and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103092886A (en) * 2011-11-07 2013-05-08 中国移动通信集团公司 Achieving method, device and system for data query operation
CN105589894A (en) * 2014-11-13 2016-05-18 腾讯数码(深圳)有限公司 Document index establishing method and device as well as document retrieving method and device
CN105786882A (en) * 2014-12-24 2016-07-20 阿里巴巴集团控股有限公司 Data table identifier generation method and device, data writing method and device

Also Published As

Publication number Publication date
CN106649736A (en) 2017-05-10

Similar Documents

Publication Publication Date Title
CN106649736B (en) Automatic number generation method in general database
CN109359939A (en) Business datum method of calibration, device, computer equipment and storage medium
CN110647562B (en) Data query method and device, electronic equipment and storage medium
US20240126655A1 (en) Data lineage based multi-data store recovery
CN110019200B (en) Index establishing and using method and device
CN104461531A (en) Implementing method for self-defined functions of reporting system
CN111784318A (en) Data processing method and device, electronic equipment and storage medium
KR102011354B1 (en) Aggregation of large amounts of temporal data from multiple overlapping sources
US11321193B2 (en) Database restoration across cloud environments
CN110109981B (en) Information display method and device for work queue, computer equipment and storage medium
US20210216516A1 (en) Management of a secondary vertex index for a graph
US10303667B2 (en) Infinite versioning by automatic coalescing
US11263264B2 (en) Management of graphs using secondary index vertices
CN110751452B (en) Workflow management system, method and storage medium
CN111858596A (en) Data acquisition method and device, computer equipment and storage medium
CN116414914A (en) Data synchronization method and device, processor and electronic equipment
CN109298925A (en) A kind of start by set date method, system and the relevant apparatus of periodic duty
CN114064678A (en) Event data processing method and device and terminal equipment
CN114036132A (en) Object information processing method and device, storage medium and electronic equipment
CN111813769B (en) Data processing method and device
CN114501383A (en) Data access method for Internet of vehicles cloud
CN113407546A (en) Rule configuration method suitable for various scenes
CN107844491B (en) Method and equipment for realizing strong consistency read operation in distributed system
JP5444388B2 (en) Batch processing parameter creation system, batch processing parameter creation method, and batch processing parameter creation program
CN114741401B (en) Data synchronization method, device and medium based on update time and primary key

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
GR01 Patent grant
GR01 Patent grant