Method and system for accessing database interface layer by SAS language based on C + + middleware
By using C++ middleware to parse and convert SAS statements into database-recognizable statements, the connection and compatibility issues between SAS language analysis software and general databases are resolved. This enables efficient and stable data access and transmission, supports multi-platform deployment, and optimizes data processing efficiency and system stability.
Patent Information
- Application Number
- CN202511715625.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-21
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2045-11-21
AI Technical Summary
SAS language analysis software cannot directly and efficiently connect to general databases, resulting in problems such as syntax incompatibility, limited functionality, and poor performance, especially in scenarios with large data volumes and high-frequency access.
A C++ middleware is used to implement the database access interface layer for the SAS language. By segmenting and recognizing database information in SAS statements, a connection pool is established, and SAS statements are converted into database-recognizable statements. The C++ middleware is used for data type conversion and transmission to ensure efficient and secure data access.
It achieves high-performance, stable, and fully functional data interconnection between SAS language analysis software and general-purpose databases, supports multi-platform deployment, optimizes memory management and concurrency models, and ensures stable system operation.
Smart Images

Figure CN121166802A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of data switching, in particular to a method and system for accessing a database interface layer of SAS language based on C++ middleware. BACKGROUND
[0002] SAS language analysis software is a key tool for many subjects to carry out data-driven decision-making due to its excellent data processing, statistical modeling, data analysis and visualization capabilities. SAS software can realize data reading and writing, SQL query, data set import and other operations on foreign databases through its built-in libname statement, procsql process step, proc import process step and other components without additional complex adaptation.
[0003] However, the native support of SAS is only for specific databases such as Oracle and DB2 databases, and the native support for most general-purpose databases is very limited, which leads to multi-dimensional incompatibility problems when SAS software connects to general-purpose databases: first, the data type mapping does not match, and some numerical types and character types in general-purpose databases lack default adaptation rules for SAS language built-in data types such as NUM and CHAR, which easily causes data truncation and format disorder; second, special SQL syntax or functions are not recognized, such as input() / put() functions for numerical and character conversion and date format '15sep2025'd in SAS, which cannot be directly parsed by general-purpose databases, resulting in SQL statement execution failure; third, the storage procedures and transaction processing mechanisms specific to general-purpose databases are difficult to call through SAS, and there are obvious defects in function adaptation.
[0004] In order to solve the connection compatibility problem of general-purpose databases in the prior art, some users try to indirectly connect SAS and general-purpose databases through ODBC, JDBC and other general-purpose interfaces, but such methods have serious performance bottlenecks in large data volume and high frequency access scenarios, that is, there are fatal problems of complexity, inefficiency and poor stability, which greatly increase the technical difficulty, time cost and potential risk of SAS system migration.
[0005] In summary, there is an urgent need in the market to develop a solution that can efficiently, stably and functionally complete the interconnection between SAS language analysis software and general-purpose databases. SUMMARY
[0006] The present application relates to the field of data switching, in particular to a method and system for accessing a database interface layer of SAS language based on C++ middleware.
[0007] To achieve the above object, the technical solution provides a method for accessing a database interface layer by SAS language, comprising the following steps: S1: calling C++ middleware to obtain SAS statements of SAS language analysis class software; S2: identifying database information in the SAS statements by word segmentation, and calling a database connection module of the C++ middleware to establish a database connection pool based on the database information; S3: identifying the SAS statements by the C++ middleware and converting the SAS statements into database recognizable statements; S4: passing the database recognizable statements to corresponding databases through the database connection pool by the C++ middleware.
[0008] Further, the method for accessing the database interface layer by SAS language comprises additional steps: S5: the databases executing the database recognizable statements and returning original result sets to the C++ middleware; S6: converting data types of the original result sets into data types of the SAS statements by the C++ middleware and obtaining final result sets; S7: passing the final result sets to the SAS language analysis class software by the C++ middleware.
[0009] In addition, the technical solution provides a system for executing the method for accessing the database interface layer by SAS language, comprising SAS language analysis class software, C++ middleware and a general database, wherein the SAS language analysis class software communicates with the C++ middleware through TCP / IP protocol by using an I / O engine, and the C++ middleware communicates with the general database.
[0010] Compared with the prior art, the technical solution has the following characteristics and beneficial effects: The technical solution provides a method and system for accessing a database interface layer by SAS language based on C++ middleware, which realizes data connection between SAS language analysis software and a general database through the C++ middleware, so as to solve the defects of syntax incompatibility, limited functions and poor performance of the SAS language analysis software when it is connected with the general database. In addition, the technical solution realizes data conversion based on the C++ middleware, has technical advantages of high performance, cross-platform, high expansibility, safety and reliability, and easy deployment, that is, the technical solution can support mainstream operating systems such as Windows and Linux, and optimized memory management and concurrent models ensure high performance under large data volume. In addition, the C++ middleware is easy to deploy and has perfect security mechanisms and error processing to ensure stable operation of the conversion process. BRIEF DESCRIPTION OF DRAWINGS
[0011] Figure 1 is a flowchart of a method of the SAS language access database interface layer of Example One.
[0012] Figure 2 is a flowchart of a method of the SAS language access database interface layer of Example Two.
[0013] Figure 3 is a block diagram of a system for performing the method of the SAS language access database interface layer.
[0014] Figure 4 is a block diagram of an electronic device for performing the method of the SAS language access database interface layer. DETAILED DESCRIPTION
[0015] The exemplary embodiments will be described in detail herein with reference to the attached drawings. The description of the exemplary embodiments is intended to apply to all alternative embodiments, as would be understood by persons skilled in the art. To the extent that they do not particularize to one or more embodiments described herein, reference will be made to the appended claims as to their applicability.
[0016] It is noted that the steps of the methods of the respective embodiments are not necessarily performed in the order shown and described herein. In some other embodiments, the methods can include more or fewer steps than those described herein. Furthermore, a single step described herein can be broken down into multiple steps in other embodiments; and multiple steps described herein can be combined into a single step in other embodiments.
[0017] Example One The present solution provides a method of a SAS language access database interface layer based on C++ middleware, which can parse the SAS language and convert it into a general database recognizable statement, so as to realize the connection between the data of the SAS language analysis software and the general database.
[0018] As shown in Figure 1 The present solution provides a method of a SAS language access database interface layer, which includes the following steps: S1: calling C++ to obtain the SAS statement of the SAS language analysis class software; S2: identifying the database information in the SAS statement by word segmentation, and calling the database connection module of the C++ middleware to establish a database connection pool based on the database information; S3: identifying the SAS statement by the C++ middleware and converting the SAS statement into a database recognizable statement; S4: The database identifiable statement is transmitted to the corresponding database through the database connection pool by the C++ middleware.
[0019] The scheme realizes data docking between the SAS language analysis software and the general database by means of the C++ middleware, and constructs a full-process efficient data switching scheme by using a modern C++ technology stack, an efficient network communication protocol and a flexible data adaptation layer, thereby improving the compatibility of data docking and optimizing the data transmission and processing efficiency.
[0020] In step S1, the SAS language analysis software uses the built-in I / O engine to communicate with the C++ middleware through the TCP / IP protocol, and transmits the SAS statement to the C++ middleware, so as to realize complete transmission and accurate conversion of data.
[0021] In some embodiments, the SAS statement in step S1 is a data connection request statement or a data query statement, and the connection type and connection requirement of data access are specified in the SAS statement.
[0022] Specifically, when the SAS language analysis software performs a data access operation (such as reading database data or executing an SQL query), the built-in I / O engine is triggered, that is, the user specifies the target database type and operation requirement of data access by writing a libname statement, a proc sql process step, etc., at this time, the built-in I / O engine will mark these data connection request statements or data query statements containing business requirements as “instructions to be transmitted to the middleware”, so as to avoid confusion with other non-database access instructions in the SAS software.
[0023] Further, in some embodiments, the SAS language analysis software uses the built-in libname statement and the proc sql process step as the built-in I / O engine, wherein the libname statement is used to define the logical library name for the target database, which essentially declares the database location, type and access parameters to be connected to the SAS statement analysis software; the proc sql process step is a data query and operation module in the SAS statement that supports SQL syntax, which can initiate database connection through the connect to clause and perform data read / write through the select / insert SQL statement.
[0024] Further, when the built-in I / O engine of the SAS language analysis software is triggered and called, the SAS language analysis software establishes a connection-oriented communication link with the C++ middleware based on the TCP / IP protocol, so as to transmit the SAS language to the C++ middleware.
[0025] Specifically, first, the SAS language analysis software initiates a TCP connection request to the specified port of the C++ middleware. After verifying the legitimacy of the connection source, the C++ middleware establishes a two-way communication channel. During the transmission of SAS statements, the regularized SAS statements are first segmented according to the message length specified by the TCP protocol, and each message segment carries a sequence number and check information. After receiving each message segment, the C++ middleware checks the data integrity and returns an acknowledgment message to the SAS software. If the SAS software does not receive the acknowledgment message within the preset time, it will automatically retransmit the corresponding segment to ensure no data loss or damage.
[0026] Step S2 of this solution ensures that the C++ middleware can recognize the connection requirements of SAS statements through accurate word segmentation recognition. By dynamically calling the dedicated connection module and constructing a database connection pool, the problems of adaptation and connection efficiency of domestic databases are solved. It not only avoids the compatibility obstacles of direct connection between SAS and general databases but also achieves high-performance access through the database connection pool.
[0027] In some embodiments, the database information includes the connection type and connection parameters. The C++ middleware identifies the database information in the SAS statement through word segmentation to confirm the connection type to be connected and obtain the connection parameters.
[0028] In the step of "identifying the database information in the SAS statement through word segmentation", the C++ middleware builds a mapping library of word segmentation results - connection types and sets the connection parameter extraction rules for the corresponding connection types. The C++ middleware matches the connection type from the mapping library according to the word segmentation results of the SAS statement, calls the connection module based on the connection type, and extracts the connection parameters from the SAS statement according to the connection type to establish a database connection pool.
[0029] In some embodiments, the connection to the database is disconnected when a specific word segmentation is recognized.
[0030] Specifically, if the SAS statement contains "libname" and "dmsql / gbase / tdsql / gaussdb / kingbase", the connection type is direct database connection. Call the direct connection module of the C++ middleware to establish a database connection pool through "server", "port", "user", "password", and "database". At this time, an exemplary SAS statement is: "libname db1 dmsql server=<IP address> port=<port number> user=<username> password=<password> database=<database name>"; If the SAS statement contains libname and jdbc, the connection type is JDBC interface connection, the C++ middleware JDBC module is called, the database connection pool is established through class, url, uid, pwd, schema, and the exemplary SAS statement is "libname DB1 jdbc class=<class name>url=<address>uid=<username>pwd=<password>schema=<library name>"; If the SAS statement contains libname and odbc, the connection type is ODBC interface connection, the C++ middleware ODBC module is called automatically, the database connection pool is established through datasrc, user, and password, and the exemplary SAS statement is "libname db3 odbc datasrc=<data source name>user=<username>password=<password>"; If the SAS statement contains proc sql and connect to dmsql / gbase / tdsql / gaussdb, kingbase, the connection type is database direct connection, the C++ middleware direct connection module is called, the database connection pool is established through host, port, user, password, and schema, and the connection with the database is disconnected when disconnect and quit are recognized. The exemplary SAS statement is "proc sql; connect to dmsql as ohr (host=<ip address>port=<port number>user=<username>password=<password>schema=<library name>)"; If the SAS statement contains proc sql and connect to odbc, the connection type is ODBC interface connection, the C++ middleware ODBC module is called, the database connection pool is established through datasrc, user, password, and schema, and the connection with the database is disconnected when disconnect and quit are recognized. The exemplary SAS statement is "proc sql; connect to odbc as ohr (datasrc=<data source name>user=<username>password=<password>schema=<library name>)"; If the SAS statement contains proc import and dbms=dmsql / gbase / tdsql / gaussdb / kingbase, the connection type is database direct connection, the C++ middleware direct connection module is called, the database connection pool is established through database, host, uid, and pwd, and the connection with the database is disconnected after the SQL statement is executed when run; is recognized. An exemplary SAS statement is "proc import out=<dataset name> dbms=dmsql replace". If the SAS statement contains proc import and dbms=odbc, the connection type is ODBC interface connection, the C++ middleware ODBC module is called, the database connection pool is established through database, host, uid, and pwd, and the connection with the database is disconnected after the SQL statement is executed when run; is recognized. An exemplary SAS statement is "proc import out=<dataset name> dbms=odbc replace".
[0031] As described previously, the C++ middleware has three types of connection modules built-in: domestic database direct connection module, JDBC interface module, and ODBC interface module, which correspond to different types of general databases one by one to solve the compatibility problem of the database. If the "direct connection module" is called, the module has integrated special drivers for various domestic databases (such as the special direct connection driver of Dream DBMS DM and the special direct connection driver of GBase), and can directly establish a bottom-layer connection with the database based on the extracted host / port / user parameters; if the "JDBC interface module" is called, the module loads the JDBC driver file corresponding to the class extracted in the statement, and constructs a JDBC connection based on the url / uid / pwd parameters; if the "ODBC interface module" is called, the module associates the system preset ODBC data source through the datasrc parameter, and completes ODBC connection initialization in combination with the user / password.
[0032] The step S3 of the present scheme converts the SAS statement through the statement recognition-rule mapping logic built-in the C++ middleware, to obtain a database recognizable statement that can be parsed by a general database.
[0033] In some embodiments, the database recognizable statement is an SQL statement.
[0034] In some embodiments, six statement conversion rules are set in the C++ middleware, and when the C++ middleware recognizes the proc sql, proc import or data step of the SAS statement, the statement conversion rule is called to convert the corresponding SAS statement into a database recognizable statement.
[0035] Further, after the C++ middleware recognizes the proc sql, proc import or data step of the SAS statement, the SAS statement is scanned sentence by sentence to extract the relevant parameters and match the statement conversion rule to be converted into a database recognizable statement.
[0036] For example, the original SAS statement: proc sql; select * from db1.a where v1 ^=.; quit, and the converted SQL statement is select * from db1.a where v1 IS NOT NULL; the original SAS statement: Data work.b; set db1.a; where v1 ^=.; run; and the converted SQL statement is select * from db1.a where v1 IS NOT NULL.
[0037] Specifically, when the SAS statement contains proc sql, the SAS statement is the core statement for executing SQL queries and data operations in SAS, and after the C++ middleware recognizes the first and last identification of proc sql and quit, it is determined that the query logic (select clause, where clause) in the SAS statement needs to be converted.
[0038] When the SAS statement contains proc import, the SAS statement is used to import external database data into SAS, and when the C++ middleware recognizes proc import, the SAS statement corresponding to the data import query logic (such as specifying the data table, the filtering condition) needs to be converted.
[0039] When the SAS statement contains data step, the SAS statement is the basic statement for data processing in SAS, and the C++ middleware determines that the data reading logic (set clause, where clause) in the data step needs to be converted.
[0040] Further, the six statement conversion rules are as follows: input() function is converted into CAST() function: when the function input (character value, numerical format) structure is identified in the SAS statement, and the function is to convert character type data into numerical type, input() is converted into SQL function CAST(), that is, the core conversion target is retained. For example: input('123', 8.) is converted into cast('123' as int).
[0041] put() function is converted into CAST() function: when the function put (numerical value, character format) is identified in the SAS statement, and the function is to convert numerical type into character, put() is converted into SQL function CAST(), that is, the character length requirement of put() function is retained. For example: put(123, $8.) is converted into cast(123 as char(8)).
[0042] SAS date format ('day mon year') is converted into TO_DATE: when the date format of 'day mon year' is identified in the SAS statement, it is first judged whether the database is dmsql, GBase, GaussDB, Kingbase, if so, the SAS date format is parsed into the standard date format of "year - month - day" and converted into SQL function TO_DATE('2025-09-15', 'YYYY-MM-DD'). For example: where v1='15sep2025'd is converted into where v1=TO_DATE('2025-09-15', 'YYYY-MM-DD'). It should be noted that if the database is not dmsql, GBase, GaussDB, Kingbase, the SAS statement of the date calculation logic will continue to be executed in the SAS language analysis software.
[0043] SAS date format ('year-month-day hour:minute:second') is converted to TO_DATE: When the date format of 'year-month-day hour:minute:second' is identified in the SAS statement, such as '2025-09-15 14:30:00'dt, it is necessary to determine whether the database is dmsql, GBase, GaussDB, Kingbase, if so, the "year-month-day hour:minute:second" structure of the SAS date and time is retained and the function is converted to the SQL function TO_DATE('2025-09-15 14:30:00', 'yyyy-mm-ddhh24:mi:ss'), such as: where v2='2025-09-15 14:30:00'dt is converted to where v2=TO_DATE('2025-09-15 14:30:00', 'yyyy-mm-dd hh24:mi:ss'). It should be noted that if the database is not dmsql, GBase, GaussDB, Kingbase, the SAS statement of the date calculation logic will continue to be executed in the SAS language analysis software.
[0044] Null identifier=. is converted to IS NULL: When=. is identified in the SAS statement, it is converted to the SQL statement IS NULL. For example: where v1=. is converted to where v1 IS NULL.
[0045] Non-null value identifier ^==. is converted to IS NOT NULL: When ^==. is identified in the SAS statement, it is converted to the SQL statement IS NOT NULL. For example: where v1^=. is converted to where v1 IS NOT NULL.
[0046] Of course, after the C++ middleware completes the conversion of the SAS statement, the C++ middleware integrates the converted fragments to form a complete database recognizable statement.
[0047] Step S4 is to pass the database recognizable statement converted by the C++ middleware to the corresponding database through the database connection pool.
[0048] In some embodiments, when step S4 needs to pass the SAS statement, the connection with the longest idle time can be preferentially called from the database connection pool.
[0049] Embodiment two Embodiment one introduces the content of converting the SAS statement of the SAS language analysis software into a database recognizable statement and then passing it to the general database, and the embodiment two of the present scheme further realizes the data return of the general database based on the embodiment one. That is, after the database engine executes the query, the returned original result set will be converted into the data type of the SAS language analysis software through the C++ middleware, ensuring the integrity and reliability of the data flow.
[0050] As shown in Figure 2 , specifically, the method for the SAS language to access the database interface layer of the present scheme includes the following steps: S1: calling the C++ middleware to obtain the SAS statement of the SAS language analysis software; S2: tokenizing and identifying the database information in the SAS statement, and calling the database connection module of the C++ middleware to establish a database connection pool based on the database information; S3: identifying the SAS statement and converting the SAS statement into a database recognizable statement by using the C++ middleware; S4: passing the database recognizable statement to the corresponding database through the database connection pool by using the C++ middleware; S5: the database executes the database recognizable statement and returns an original result set to the C++ middleware; S6: converting the data type of the original result set into the data type of the SAS statement by using the C++ middleware and obtaining a final result set; S7: passing the final result set to the SAS language analysis software by using the C++ middleware.
[0051] The method for the SAS language to access the database interface layer of the present scheme can convert the original data set of the database into the ROD data set that can be recognized and efficiently operated by the SAS language analysis software, and further realize the bidirectional efficient, data consistent, safe and reliable full-process data interaction between the SAS language analysis software and the general database.
[0052] It should be noted that since the C++ middleware has established a connection with the database connection pool, the converted database recognizable statement can be accurately passed to the general database, and the general database can return the original data set to the C++ middleware after executing the data recognizable statement.
[0053] In step S6, the C++ middleware identifies the data type of the original result set, and converts the original data set into a final result set based on the data type conversion rule.
[0054] Specifically, the C++ middleware reads metadata information of a header of the original result set, extracts a database native data type identifier of each field, and maps the parsed database native data type to a data type of the original result set.
[0055] In some embodiments, the data type of the original result set includes a numeric type, a character type, a date and time type, a Boolean type, a binary type, and other special types, wherein the other special types are data types other than the numeric type, the character type, the date and time type, the Boolean type, and the binary type.
[0056] The data type conversion rule of the C++ middleware is as follows: Conversion of the numeric type: if the data type in the original result set is the numeric type, such as INT, INTEGER, SMALLINT, BIGINT, TINYINT, NUMERIC, NUMBER, DECIMAL, FLOAT, REAL, DOUBLE, DOUBLEPRECISION, etc., the data type is converted to the NUM type in the SAS statement, so as to be uniformly stored in the SAS language analysis software. For example, if the data type in the database is NUMBER(26, 6), the converted data type is the NUM type, and the FORMAT is best32..
[0057] Conversion of the character type: if the data type in the original result set is the character type, such as CHAR(10), VARCHAR(15), TEXT, etc., the data type is converted to the CHAR type in the SAS statement, so as to be uniformly stored in the SAS language analysis software, and the data length is consistent with that in the general database, wherein the default length of the TEXT is 500. For example, if the data type in the database is CHAR(10), the converted data type is the CHAR type, and the length is 10.
[0058] Conversion of the date and time type: if the data type in the original result set is the date and time type, such as DATE, TIME, DATATIME, TIMESTAM, etc., the data type is converted to the NUM type in the SAS statement, and the FORMAT is yymmdd10. or time8. or datetime20., so as to be uniformly stored in the SAS language analysis software. For example, if the data type in the database is DATE, the converted data type is the NUM type, and the FORMAT is yymmdd10..
[0059] Conversion of the Boolean type: if the data type in the original result set is the Boolean type, such as BOOLEAN, BOOL, etc., the data type is converted to the CHAR type in the SAS statement, so as to be uniformly stored in the SAS language analysis software.
[0060] Conversion of binary type: if the data type in the original result set is binary type, such as BLOB, BINARY, VARBINARY, etc., the data type is converted to CHAR type in the SAS statement, so as to be uniformly stored in the SAS language analysis software.
[0061] Conversion of other special types: if the data type in the original result set is other special type, such as ENUM, SET, JSON, GEOMETRY, POINT, etc., the data type is converted to CHAR type in the SAS statement, so as to be uniformly stored in the SAS language analysis software.
[0062] In some embodiments, after the C++ middleware completes the conversion of all data types, the converted data is assembled into the final result set according to the format requirements of the SAS.ROD dataset. Of course, the field order in the final result set needs to be consistent with that of the original result set, so as to ensure that the field mapping is not wrong when the SAS language analysis software reads.
[0063] Embodiment three Based on the same idea, referring to Figure 3 The application also provides a system for executing the method of the SAS language access database interface layer shown in embodiment one or embodiment two, comprising: SAS language analysis software, C++ middleware and a general database, wherein the SAS language analysis software uses the I / O engine to establish communication with the C++ middleware through the TCP / IP protocol, and the C++ middleware establishes communication with the general database.
[0064] The specific execution method and logic are the same as those of embodiment one and embodiment two, and will not be described here.
[0065] It should be noted that, in some embodiments, the SAS language analysis software calls the ACCESS / JDBC driver / ODBC driver of the C++ middleware through the libname / proc sql components, and the C++ middleware mobilizes the general database through the general database special driver.
[0066] Embodiment four The embodiment also provides an electronic device, referring to Figure 4 comprising a memory 404 and a processor 402, the memory 404 storing a computer program, and the processor 402 being configured to run the computer program to execute the steps in any of the method embodiments.
[0067] In particular, the processor 402 can include a central processing unit (CPU) or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present application.
[0068] The memory 404 can include a mass storage for data or instructions. The memory 404 can be used to store or cache various data files needed for processing and / or communication, and possible computer program instructions executed by the processor 402.
[0069] The processor 402 can implement the method of accessing the SAS language database interface layer shown in either embodiment one or embodiment two by reading and executing the computer program instructions stored in the memory 404.
[0070] Optionally, the electronic device can further include a transmission device 406 connected to the processor 402 and an input / output device 408 connected to the processor 402. The transmission device 406 can be used to receive or send data via a network.
[0071] Optionally, in the present embodiment, the processor 402 can be configured to perform the following steps by computer program: S1: calling the C++ middleware to obtain the SAS statement from the SAS language analysis software; S2: identifying the database information in the SAS statement by word segmentation, and calling the database connection module of the C++ middleware to establish a database connection pool based on the database information; S3: identifying the SAS statement by the C++ middleware and converting the SAS statement into a database recognizable statement S4: passing the database recognizable statement to the corresponding database through the database connection pool by the C++ middleware.
[0072] Or: S1: calling the C++ middleware to obtain the SAS statement from the SAS language analysis software; S2: identifying the database information in the SAS statement by word segmentation, and calling the database connection module of the C++ middleware to establish a database connection pool based on the database information; S3: identifying the SAS statement by the C++ middleware and converting the SAS statement into a database recognizable statement S4: passing the database recognizable statement to the corresponding database through the database connection pool by the C++ middleware. S5: The database executes the database recognizable statement and returns the original result set to the C++ middleware; S6: The C++ middleware converts the data type of the original result set to the data type of the SAS statement and obtains a final result set; S7: The C++ middleware transmits the final result set to the SAS language analysis class software.
[0073] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation manners, and this embodiment will not be described here.
[0074] Generally, various embodiments can be implemented in hardware or special-purpose circuitry, software, logic or any combination thereof. Some aspects of the application can be implemented in hardware, while other aspects can be implemented using firmware or software in conjunction with a controller, microprocessor, or other computing device, but the application is not limited thereto. While various aspects of the application can be illustrated and described as block diagrams, flow charts, or using some other pictorial representation, it is well understood that these blocks, apparatus, systems, techniques or methods described herein can be implemented in hardware, software, firmware, special purpose circuits or logic, general purpose hardware or controlers or other computing devices, or some combination thereof.
[0075] Embodiments of the application can be implemented by computer software executable by a data processor of the mobile device such as in the processor entity, or by hardware, or by a combination of software and hardware. Computer software or program, also called program product, including software routines, applets and / or macros, can be stored in any apparatus-readable data storage medium and they include program instructions to implement specific tasks. The program product can include one or more computer-executable components which, when the program is run, are configured to carry out embodiments of the present application. The one or more computer-executable components can be at least one software code or portions thereof. Further, at this regard it should be noted that any block in the logical flow of the figures can represent a module, segment, or portion of code which comprises one or more computer-executable instructions to implement the specified logical function(s). The software can be stored on such physical media as memory chips, or memory blocks implemented in the processor, magnetic media such as hard disk or floppy disks, and optical media such as for example DVD and the data variants thereof, CD. The physical media are non-transitory media.
[0076] Those skilled in the art should understand that the technical features of the above embodiments can be combined in any combination, and in order to make the description concise, not all possible combinations of the technical features in the above embodiments are described, however, as long as the combinations of the technical features do not exist, they should be considered as the scope of the description.
[0077] The above embodiments only express several implementation ways of the present application, and the description is specific and detailed, but it should not be understood as a limitation to the scope of the present application. It should be pointed out that for ordinary skilled in the art, without departing from the concept of the present application, several modifications and improvements can be made, which all belong to the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.
Claims
1. A method for accessing a database interface layer using the SAS language, characterized in that, Includes the following steps: S1: Call the C++ middleware to obtain SAS statements from the SAS language analysis software. S2: Word segmentation identifies database information in SAS statements and establishes a database connection pool by calling the database connection module of C++ middleware based on the database information; S3: Use C++ middleware to recognize SAS statements and convert them into database-recognizable statements; S4: Use C++ middleware to pass database-recognizable statements to the corresponding database through a database connection pool.
2. The method for accessing the database interface layer using the SAS language according to claim 1, characterized in that, The SAS statement in step S1 is a data connection request statement or a data query statement, and the connection type and connection requirements for data access are specified within the SAS statement.
3. The method for accessing the database interface layer using the SAS language according to claim 1, characterized in that, SAS language analysis software uses the built-in libname statement and proc sql procedure step as its built-in I / O engine. The libname statement is used to define the logical database name for the target database, and the proc sql procedure step is a data query and manipulation module in SAS statements that supports SQL syntax.
4. The method for accessing the database interface layer using the SAS language according to claim 1, characterized in that, The C++ middleware has a built-in mapping library for word segmentation results and connection types, and sets the connection parameter extraction rules for the corresponding connection types. The C++ middleware matches the connection type from the mapping library based on the word segmentation results of the SAS statement, calls the connection module based on the connection type, and extracts the connection parameters from the SAS statement to establish a database connection pool.
5. The method for accessing the database interface layer using the SAS language according to claim 1, characterized in that, If the SAS statement contains libname and dmsql / gbase / tdsql / gaussdb / kingbase, the connection type is direct database connection, which calls the C++ middleware direct connection module and establishes a database connection pool through server, port, user, password, and database. If the SAS statement contains libname and jdbc, the connection type is a JDBC interface connection, which calls the C++ middleware JDBC module to establish a database connection pool through class, url, uid, pwd, and schema. If the SAS statement contains `libname` and `odbc`, the connection type is an ODBC interface connection, which automatically calls the ODBC module of the C++ middleware and establishes a database connection pool using `datasrc`, `user`, and `password`. If the SAS statement contains `proc sql` and `connect to dmsql / gbase / tdsql / gaussdb` or `kingbase`, the connection type is a direct database connection, which calls the direct connection module of the C++ middleware and establishes a database connection pool using `host`, `port`, `user`, `password`, and `schema`. The connection to the database is disconnected when `disconnect` and `quit` are detected. If the SAS statement contains proc sql and connect to odbc, the connection type is an ODBC interface connection. It calls the C++ middleware ODBC module to establish a database connection pool through datasrc, user, password, and schema. When disconnect and quit are detected, the connection to the database is disconnected. If the SAS statement contains `proc import` and `dbms=dmsql / gbase / tdsql / gaussdb / kingbase`, then the connection type is a direct database connection. It calls the C++ middleware direct connection module, establishes a database connection pool through `database`, `host`, `uid`, and `pwd`, and disconnects from the database after executing the SQL statement when `run;` is detected. If the SAS statement contains `proc import` and `dbms=odbc`, the connection type is an ODBC interface connection. It calls the C++ middleware ODBC module, establishes a database connection pool using `database`, `host`, `uid`, and `pwd`, and disconnects from the database after executing the SQL statement when `run;` is detected.
6. The method for accessing the database interface layer using the SAS language according to claim 1, characterized in that, The C++ middleware has six statement conversion rules. When the C++ middleware recognizes the proc sql, proc import, or data step of a SAS statement, it calls the statement conversion rules to convert the corresponding SAS statement into a database-recognizable statement.
7. The method for accessing the database interface layer using the SAS language according to claim 6, characterized in that, The input() function is converted to the CAST() function: When the SAS statement recognizes the input(character value, numeric format) structure and its function is to convert character data to numeric data, then input() is converted to the SQL function CAST(). The put() function is converted to the CAST() function: When the SAS statement recognizes the function put(numeric, character format) and its function is to convert numeric types to characters, put() is converted to the SQL function CAST(), that is, the character length requirement of the put() function is preserved. SAS date format ('day-month-day') to TO_DATE: When a SAS statement recognizes a date format of 'day-month-day', it first determines whether the database is dmsql, GBase, GaussDB, or Kingbase. If so, it parses the SAS date format into the standard date format of "year-month-day" and converts it to the SQL function TO_DATE. Converting SAS date format ('year-month-day hour:minute:second') to TO_DATE: When a SAS statement recognizes a date format of 'year-month-day hour:minute:second', it first needs to determine whether the database is dmsql, GBase, GaussDB, or Kingbase. If so, it preserves the SAS date and time structure of "year-month-day hour:minute:second" and converts it to the SQL function TO_DAT. The null value identifier =. is converted to IS NULL: When SAS detects =., it is converted to the SQL statement IS NULL; The non-null value identifier ^=. is converted to IS NOT NULL: When SAS recognizes ^=., it is converted to the SQL statement IS NOT NULL.
8. The method for accessing the database interface layer using the SAS language according to claim 1, characterized in that, Includes the following steps: S5: The database executes database-recognizable statements and returns the raw result set to the C++ middleware; S6: Use C++ middleware to convert the data type of the original result set to the data type of the SAS statement and obtain the final result set; S7: Use C++ middleware to pass the final result set to SAS language analysis software.
9. The method for accessing the database interface layer using the SAS language according to claim 8, characterized in that, The data type conversion rules for C++ middleware are as follows: Numeric type conversion: If the data type in the original result set is numeric, then convert the data type to the NUM type in the SAS statement; Character type conversion: If the data type in the original dataset is character, then convert the data type to CHAR type in SAS statements; Date and time type conversion: If the data type in the original result set is date or time, convert the data type to the NUM type in the SAS statement, FORMAT as yymmdd10, time8, or datetime20. Boolean type conversion: If the data type in the original result set is Boolean, then the data type will be converted to CHAR type in the SAS statement; Binary type conversion: If the data type in the original result set is binary, then convert the data type to CHAR type in the SAS statement; Other special type conversions: If the data type in the original result set is another special type, then the data type will be converted to the CHAR type in the SAS statement.
10. A system for performing the method of accessing a database interface layer using the SAS language as described in any one of claims 1 to 9, characterized in that, include: The system consists of SAS language analysis software, C++ middleware, and a general-purpose database. The SAS language analysis software uses an I / O engine to communicate with the C++ middleware via the TCP / IP protocol, while the C++ middleware communicates with the general-purpose database.
Citation Information
Patent Citations
Software radar signal data processing system and software radar signal data processing method
CN107315168A
Computer-Implemented Method and System for Handling and Transforming Database Queries in a Fourth Generation Language
US20100114932A1
System for implementing data analytics in mainframe environments
US20210389987A1
System and method for directly accessing SAS datasets from a JAVA program
US8943472B1
