A method and system for accessing the database interface layer of SAS language based on C++ middleware.

By using C++ middleware to achieve data interface between SAS language and general databases, the compatibility and performance issues between SAS language analysis software and general databases are resolved, enabling efficient and stable data access and transmission, and supporting multi-platform deployment.

CN121166802BActive Publication Date: 2026-03-06杭州启维人工智能编译技术有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-11-21
Publication Date
2026-03-06

AI Technical Summary

Technical Problem

SAS language analysis software cannot efficiently connect to general databases, and suffers from problems such as syntax incompatibility, limited functionality, and poor performance, especially in scenarios with large data volumes and high-frequency access.

Method used

A C++ middleware is used to implement the database access interface layer for the SAS language. The database information in the SAS statement is identified by word segmentation, a connection pool is established, and the SAS statement is converted into a database-recognizable statement. The C++ middleware is used for data transfer and type conversion to ensure efficient and stable data transmission and processing.

Benefits of technology

It enables high-performance, secure, and reliable data access between SAS language analysis software and general-purpose databases, supports multi-platform deployment, optimizes memory management and concurrency models, and ensures stable system operation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121166802B_ABST
    Figure CN121166802B_ABST
Patent Text Reader

Abstract

This invention provides a method and system for accessing a database interface layer using SAS language based on C++ middleware. The method includes the following steps: calling C++ middleware to obtain SAS statements from SAS language analysis software; identifying database information in the SAS statements through word segmentation, and establishing a database connection pool based on the database information by calling the database connection module of the C++ middleware; using the C++ middleware to identify the SAS statements and convert them into database-recognizable statements; and using the C++ middleware to pass the database-recognizable statements to the corresponding database through the database connection pool. This solves the problem in the prior art that SAS language analysis software cannot directly and efficiently connect to general databases, and enables high-performance, high-reliability, and secure data access.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data transfer, and in particular to a method and system for accessing a database interface layer using SAS language based on C++ middleware. Background Technology

[0002] SAS language analysis software, with its superior data processing, statistical modeling, data analysis, and visualization capabilities, is a key tool for many entities to conduct data-driven decision-making. SAS software can perform operations such as reading and writing data from foreign databases, SQL queries, and dataset imports through its built-in libname statement, procsql procedure steps, and proc import procedure steps, without requiring additional complex adaptations.

[0003] However, SAS's native support is only for specific databases, such as Oracle and DB2, and its native support for most general-purpose databases is very limited. This leads to multi-dimensional incompatibility issues when SAS software connects to general-purpose databases: First, data type mapping mismatches occur. Some numeric and character types in general-purpose databases lack default adaptation rules with SAS's built-in data types such as NUM and CHAR, easily resulting in data truncation and formatting errors. Second, proprietary SQL syntax or functions are not recognized. SAS functions such as input() / put() for converting numbers to characters and date formats like '15sep2025'd cannot be directly parsed by general-purpose databases, causing SQL statement execution to fail. Third, the stored procedures and transaction processing mechanisms unique to general-purpose databases are difficult to call through SAS, resulting in significant functional adaptation defects.

[0004] In order to solve the connection compatibility problem of general databases, some users have tried to indirectly connect SAS and general databases through general interfaces such as ODBC and JDBC. However, such methods have serious performance bottlenecks in scenarios with large data volume and high frequency of access. They have fatal problems of complexity, inefficiency and poor stability, which greatly increases the technical difficulty, time cost and potential risks of SAS system migration.

[0005] In conclusion, there is an urgent need in the market to develop a solution that enables efficient, stable, and fully functional interconnection between SAS language analysis software and general-purpose databases. Summary of the Invention

[0006] The purpose of this invention is to provide a method and system for accessing a database interface layer based on C++ middleware for SAS language, which solves the problem that SAS language analysis software cannot directly and efficiently connect to general databases in the prior art, and can achieve high-performance, high-reliability and secure data access.

[0007] To achieve the above objectives, this technical solution provides a method for accessing a database interface layer using the SAS language, comprising the following steps:

[0008] S1: Call the C++ middleware to obtain SAS statements from the SAS language analysis software.

[0009] 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;

[0010] S3: Use C++ middleware to recognize SAS statements and convert them into database-recognizable statements;

[0011] S4: Use C++ middleware to pass database-recognizable statements to the corresponding database through a database connection pool.

[0012] Furthermore, the SAS language method for accessing the database interface layer in this technical solution includes additional steps:

[0013] S5: The database executes database-recognizable statements and returns the raw result set to the C++ middleware;

[0014] 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;

[0015] S7: Use C++ middleware to pass the final result set to SAS language analysis software.

[0016] In addition, this technical solution provides a system for executing the above-mentioned method of accessing the database interface layer using the SAS language, including: SAS language analysis software, C++ middleware, and a general-purpose database, wherein the SAS language analysis software uses an I / O engine to establish communication with the C++ middleware via the TCP / IP protocol, and the C++ middleware establishes communication with the general-purpose database.

[0017] Compared with existing technologies, this technical solution has the following characteristics and beneficial effects:

[0018] This solution provides a method and system for accessing a database interface layer using SAS language based on C++ middleware. This solution achieves data interoperability between SAS language analysis software and general-purpose databases through C++ middleware, addressing the shortcomings of existing technologies where SAS language analysis software interacts with general-purpose databases, such as syntax incompatibility, limited functionality, and poor performance. Furthermore, this solution, based on C++ middleware for data transformation, offers advantages such as high performance, cross-platform compatibility, high scalability, security, reliability, and ease of deployment. Specifically, this solution supports mainstream operating systems such as Windows and Linux, and optimized memory management and concurrency models ensure high performance under large data volumes. Additionally, the C++ middleware is simple to deploy and has robust security mechanisms and error handling to ensure stable operation during the transformation process. Attached Figure Description

[0019] Figure 1 This is a flowchart illustrating the method for accessing the database interface layer using the SAS language in Example 1.

[0020] Figure 2 This is a flowchart illustrating the method for accessing the database interface layer using the SAS language in Example 2.

[0021] Figure 3 This is a schematic diagram of the system framework for executing the SAS language database access interface layer.

[0022] Figure 4 This is a schematic diagram of the electronic device that executes the SAS language's database access interface layer method. Detailed Implementation

[0023] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with one or more embodiments of this specification. Rather, they are merely examples of apparatuses and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.

[0024] It should be noted that the steps of the corresponding methods are not necessarily performed in the order shown and described in this specification in other embodiments. In some other embodiments, the methods may include more or fewer steps than described in this specification. Furthermore, a single step described in this specification may be broken down into multiple steps in other embodiments; and multiple steps described in this specification may be combined into a single step in other embodiments.

[0025] Example 1

[0026] This solution provides a method for accessing a database interface layer using SAS language based on C++ middleware. It can parse SAS language and convert it into statements that can be recognized by general databases, thereby enabling the data exchange between SAS language analysis software and general databases.

[0027] like Figure 1 As shown, this solution provides a method for accessing the database interface layer using the SAS language, including the following steps:

[0028] S1: Calls SAS statements from the SAS language analysis software sourced in C++;

[0029] 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;

[0030] S3: Use C++ middleware to recognize SAS statements and convert them into database-recognizable statements;

[0031] S4: Use C++ middleware to pass database-recognizable statements to the corresponding database through a database connection pool.

[0032] This solution leverages C++ middleware to achieve data integration between SAS language analysis software and general-purpose databases. By employing a modern C++ technology stack, efficient network communication protocols, and a flexible data adaptation layer, it constructs a highly efficient end-to-end data transfer solution, improving data integration compatibility while optimizing data transmission and processing efficiency.

[0033] In step S1, the SAS language analysis software uses its built-in I / O engine to communicate with the C++ middleware via the TCP / IP protocol and transmits SAS statements to the C++ middleware, thereby achieving complete data transmission and accurate conversion.

[0034] In some embodiments, the SAS statement in step S1 is a data connection request statement or a data query statement, and the SAS statement specifies the connection type and connection requirements for data access.

[0035] Specifically, when SAS language analysis software performs data access operations (such as reading database data or executing SQL queries), it triggers a call to the built-in I / O engine. That is, by writing libname statements, proc sql procedure steps, and other instructions, users can explicitly specify the target database type and operation requirements for data access. 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 middleware" to avoid confusion with other non-database access instructions within the SAS software.

[0036] Furthermore, in some embodiments, SAS language analysis software uses the built-in libname statement and procsql procedure step as its built-in I / O engine. The libname statement is used to define the logical database name for the target database, which essentially declares to the SAS language analysis software the location, type, and access parameters of the database to be connected to. The procsql procedure step is a data query and operation module in SAS that supports SQL syntax. It can initiate database connections through the connect to clause and perform data read and write operations through SQL statements such as select / insert.

[0037] Furthermore, when the built-in I / O engine of the SAS language analysis software is triggered, the SAS language analysis software establishes a connection-oriented communication link with the C++ middleware based on the TCP / IP protocol to transmit the SAS language to the C++ middleware.

[0038] Specifically, the SAS language analysis software first initiates a TCP connection request to the designated port of the C++ middleware. After verifying the legitimacy of the connection source, the C++ middleware establishes a bidirectional communication channel. During the transmission of SAS statements, the SAS statements are first segmented according to the message length specified by the TCP protocol. Each message carries a sequence number and checksum information. After receiving each message, the C++ middleware verifies the data integrity and returns an acknowledgment message to the SAS software. If the SAS software does not receive the acknowledgment message within a preset time, it will automatically retransmit the corresponding segment to ensure that no data is lost or corrupted.

[0039] Step S2 of this solution ensures that the C++ middleware can recognize the connection requirements of SAS statements through accurate word segmentation and recognition. By dynamically calling a dedicated connection module and building a database connection pool, it solves the compatibility and connection efficiency problems of domestic databases. This avoids the compatibility barrier of SAS directly connecting to general databases and achieves high-performance access through the database connection pool.

[0040] In some embodiments, the database information includes connection type and connection parameters. The C++ middleware identifies the database information in the SAS statement through word segmentation to determine the connection type to be connected and obtain the connection parameters.

[0041] In the step of "recognizing database information in SAS statements through word segmentation", the C++ middleware has a built-in mapping library of 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 according to the connection type to establish a database connection pool.

[0042] In some embodiments, the connection to the database is disconnected when a specific word segmentation is recognized.

[0043] Specifically, if the SAS statement contains "libname" and "dmsql / gbase / tdsql / gaussdb / kingbase", the connection type is direct database connection. The C++ middleware direct connection module is called to establish a database connection pool through server, port, user, password, and database. An exemplary SAS statement at this time is: "libname db1 dmsql server=<IP address> port=<port number> user=<username> password=<password> database=<database name>";

[0044] If the SAS statement contains "libname" and "jdbc", the connection type is JDBC interface connection. The C++ middleware JDBC module is called to establish a database connection pool through class, url, uid, pwd, and schema. An exemplary SAS statement at this time is "libname DB1 jdbc class=<class name> url=<address> uid=<username> pwd=<password> schema=<database name>";

[0045] If the SAS statement contains "libname" and "odbc", the connection type is ODBC interface connection. The ODBC module of the C++ middleware is automatically called to establish a database connection pool through datasrc, user, and password. An exemplary SAS statement at this time is "libname db3 odbc datasrc=<data source name> user=<username> password=<password>";

[0046] If the SAS statement contains "proc sql" and "connect to dmsql / gbase / tdsql / gaussdb, kingbase", the connection type is direct database connection. The direct connection module of the C++ middleware is called to establish a database connection pool through host, port, user, password, and schema. And when "disconnect" and "quit" are recognized, the connection to the database is disconnected. An exemplary SAS statement is "proc sql ; connect to dmsql as ohr(host=<IP address> port=<port number> user=<username> password=<password> schema=<database name>)";

[0047] If a SAS statement contains `proc sql;connect to odbc`, the connection type is an ODBC interface connection. It calls the C++ middleware ODBC module to establish a database connection pool using `datasrc`, `user`, `password`, and `schema`. The connection to the database is terminated when `disconnect` or `quit` is detected. An example SAS statement is: `proc sql;connect to odbc as ohr(datasrc=<data source name>user=<username>password=<password>schema=<database name>)`.

[0048] If a SAS statement contains `proc import = <dataset name>dbms=dmsql / gbase / tdsql / gaussdb / kingbase`, the connection type is a direct database connection. It calls the C++ middleware direct connection 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. An example SAS statement is `proc import out=<dataset name>dbms=dmsql replace`.

[0049] If a 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 an SQL statement when `run;` is detected. An example SAS statement is `proc import out=<dataset name>dbms=odbc replace`.

[0050] As mentioned earlier, the C++ middleware has three main categories of built-in connection modules: direct connection modules for domestic databases, JDBC interface modules, and ODBC interface modules. Each module corresponds to a common database type to address database compatibility issues. If the "direct connection module" is called, it integrates dedicated drivers for various domestic databases (such as dedicated direct connection drivers for DM and GBase), allowing direct establishment of a low-level connection based on extracted host / port / user parameters. If the "JDBC interface module" is called, it loads the JDBC driver file corresponding to the class extracted in the loading statement and constructs a JDBC connection based on url / uid / pwd parameters. If the "ODBC interface module" is called, it associates the system's preset ODBC data source with the datasrc parameter and initializes the ODBC connection using user / password.

[0051] Step S3 of this solution uses the statement recognition-rule mapping logic built into the C++ middleware to transform the SAS statement into a database-recognizable statement that can be parsed by a general database.

[0052] In some embodiments, the database can recognize statements as SQL statements.

[0053] In some embodiments, the C++ middleware sets 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.

[0054] Furthermore, when the C++ middleware recognizes the proc sql, proc import, or data step of a SAS statement, it scans the SAS statement line by line to extract relevant parameters and matches them with statement conversion rules to convert them into statements that the database can recognize.

[0055] For example, the original SAS statement: `proc sql; select * from db1.a where v1^=.; quit`, is transformed into the SQL statement: `select * from db1.a where v1 IS NOT NULL`; the original SAS statement: `Datawork.b; setdb1.a; where v1^=.; run;`, is transformed into the SQL statement: `select * from db1.a where v1 IS NOT NULL`.

[0056] Specifically, when a SAS statement contains proc sql, it is the core statement in SAS for executing SQL queries and data operations. After the middleware recognizes the beginning and end identifiers of proc sql and quit, it determines that the query logic (select clause, where clause) in the SAS statement needs to be converted.

[0057] When a SAS statement contains `proc import`, it is used to import data from an external database into SAS. When the C++ middleware recognizes `proc import`, it needs to convert the SAS statement containing the corresponding query logic (such as specifying the data table and filtering conditions) for the data import.

[0058] When a SAS statement contains a data step, it is the basic statement for data processing in SAS. The C++ middleware needs to convert the data reading logic (set clause, where clause) in the data step.

[0059] Furthermore, the six statement conversion rules are as follows:

[0060] The input() function is converted to the CAST() function: When a 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(), thus preserving the core conversion target. For example, input('123', 8.) is converted to cast('123' as int).

[0061] The `put()` function is converted to the `CAST()` function: When a SAS statement recognizes the function `put(numeric, character format)`, and its function is to transpose a numeric type to a character, then `put()` is converted to the SQL function `CAST()`, which preserves the character length requirement of the `put()` function. For example, `put(123, $8.)` is converted to `cast(123 as char(8))`.

[0062] SAS date format ('day-month-day') to TO_DATE conversion: When a SAS statement recognizes a date format of 'day-month-day', it first checks if the database is dmsql, GBase, GaussDB, or Kingbase. If so, it parses the SAS date format into the standard "year-month-day" date format and converts it to the SQL function TO_DATE('2025-09-15', 'YYYY-MM-DD'). For example, WHERE v1='15sep2025'd is converted to WHERE v1=TO_DATE('2025-09-15', 'YYYY-MM-DD'). It should be noted that if the database is not dmsql, GBase, GaussDB, or Kingbase, the SAS statement containing the date calculation logic will continue to be executed within the SAS language analysis software.

[0063] 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', such as '2025-09-15 14:30:00'dt, it first needs to determine if 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 the function to the SQL function TO_DATE('2025-09-15 14:30:00', 'yyyy-mm-ddhh24:mi:ss'). For example, 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, or Kingbase, the SAS statement for calculating this date will continue to be executed in SAS language analysis software.

[0064] The null value identifier =. is converted to IS NULL: When SAS detects =. in a statement, it is converted to the SQL statement IS NULL. For example, WHERE v1=. is converted to WHERE v1 IS NULL.

[0065] The non-null value identifier ^=. is converted to IS NOT NULL: When SAS recognizes ^=. in a statement, it is converted to the SQL statement ISNOT NULL. For example, WHERE v1^=. is converted to WHERE v1 IS NOT NULL.

[0066] Of course, after the C++ middleware completes the conversion of the SAS statement, it integrates the converted fragments to form a complete database-recognizable statement.

[0067] Step S4 involves passing the database-recognizable statements, which have been converted by the C++ middleware, to the corresponding database through the database connection pool.

[0068] In some embodiments, when step S4 requires passing SAS statements, the connection with the longest idle time can be retrieved from the database connection pool first.

[0069] Example 2

[0070] Example 1 describes how SAS statements from SAS language analysis software are converted into database-recognizable statements and then passed to a general-purpose database. Example 2 of this solution further implements data return to the general-purpose database based on Example 1. That is, after the database engine executes the query, the returned raw result set is converted into the data types of SAS language analysis software through C++ middleware, ensuring the integrity and reliability of the data flow.

[0071] like Figure 2 As shown, specifically, the method for accessing the database interface layer using the SAS language in this solution includes the following steps:

[0072] S1: Call the C++ middleware to obtain SAS statements from the SAS language analysis software.

[0073] 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;

[0074] S3: Use C++ middleware to recognize SAS statements and convert them into database-recognizable statements;

[0075] S4: Use C++ middleware to pass database-recognizable statements to the corresponding database through a database connection pool;

[0076] S5: The database executes database-recognizable statements and returns the raw result set to the C++ middleware;

[0077] 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;

[0078] S7: Use C++ middleware to pass the final result set to SAS language analysis software.

[0079] The SAS language access database interface layer method in this solution can convert the raw dataset of the database into a .ROD dataset that can be recognized and efficiently processed by SAS language analysis software, thereby realizing bidirectional, efficient, consistent, secure and reliable end-to-end data interaction between SAS language analysis software and general databases.

[0080] It should be noted that since the C++ middleware has already established a database connection pool, it can accurately pass the converted database-recognizable statements to the general database, and the general database can return the original dataset to the C++ middleware after executing the data-recognizable statements.

[0081] In step S6, the C++ middleware identifies the data type of the original result set and converts the original dataset into the final result set based on data type conversion rules.

[0082] Specifically, the C++ middleware reads the metadata information from the header of the original result set, extracts the database native data type identifier for each field, and maps the parsed database native data type to the data type of the original result set.

[0083] In some embodiments, the data types of the original result set include numeric types, character types, date and time types, boolean types, binary types, and other special types, wherein the other special types are non-numeric types, character types, date and time types, boolean types, and binary types.

[0084] The data type conversion rules for C++ middleware are as follows:

[0085] Numeric type conversion: If the data type in the original result set is numeric, such as INT, INTEGER, SMALLINT, BIGINT, TINYINT, NUMERIC, NUMBER, DECIMAL, FLOAT, REAL, DOUBLE, DOUBLEPRECISION, etc., then the data type will be converted to the NUM type in the SAS statement for unified storage in SAS language analysis software. For example, if the data type in the database is NUMBER(26,6), it will be converted to the NUM type, and the FORMAT will be best32.

[0086] Character type conversion: If the data type in the original dataset is a character type, such as CHAR(10), VARCHAR(15), TEXT, etc., then the data type will be converted to the CHAR type in SAS statements for unified storage in SAS language analysis software, while retaining the same data length as in general databases. TEXT retains a default length of 500. For example, if the data type in the database is CHAR(10), it will be converted to CHAR type with a length of 10.

[0087] Date and Time Type Conversion: If the data types in the original result set are date and time types, such as DATE, TIME, DATATIME, TIMESTAMP, etc., then the data types will be converted to the NUM type in the SAS statement, with FORMAT set to yymmdd10, time8, or datetime20, for unified storage in SAS language analysis software. For example, if the data type in the database is DATE, it will be converted to NUM type, with FORMAT set to yymmdd10.

[0088] Boolean type conversion: If the data type in the original result set is Boolean, such as BOOLEAN or BOOL, then the data type will be converted to CHAR in the SAS statement for unified storage in SAS language analysis software.

[0089] Binary type conversion: If the data type in the original result set is binary, such as BLOB, BINARY, VARBINARY, etc., then the data type will be converted to CHAR type in SAS statements for unified storage in SAS language analysis software.

[0090] Other special type conversions: If the data type in the original result set is another special type, such as ENUM, SET, JSON, GEOMETRY, POINT, etc., then the data type will be converted to the CHAR type in the SAS statement for unified storage in SAS language analysis software.

[0091] In some embodiments, after the C++ middleware completes all data type conversions, it assembles the converted data into a 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 the original result set to ensure that field mapping is not misaligned when read by SAS language analysis software.

[0092] Example 3

[0093] Based on the same concept, referencing Figure 3This application also proposes a system for implementing the SAS language database interface layer method shown in Embodiment 1 or Embodiment 2, comprising:

[0094] 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.

[0095] The specific execution methods and logic are the same as in Examples 1 and 2, and will not be elaborated upon here.

[0096] It should be noted that in some embodiments, SAS language analysis software calls the ACCESS / JDBC / ODBC driver in the C++ middleware through components such as libname / proc sql, and the C++ middleware calls the general database through a dedicated driver for the general database.

[0097] Example 4

[0098] This embodiment also provides an electronic device, see reference. Figure 4 It includes a memory 404 and a processor 402, wherein the memory 404 stores a computer program and the processor 402 is configured to run the computer program to perform the steps in any of the above method embodiments.

[0099] Specifically, the processor 402 may include a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.

[0100] The memory 404 may include a large-capacity memory 404 for data or instructions. The memory 404 can be used to store or cache various data files that need to be processed and / or communicated, as well as possible computer program instructions executed by the processor 402.

[0101] The processor 402 reads and executes computer program instructions stored in the memory 404 to implement the SAS language database interface layer method shown in any of the embodiments 1 or 2 above.

[0102] Optionally, the electronic device may further include a transmission device 406 and an input / output device 408, wherein the transmission device 406 is connected to the processor 402, and the input / output device 408 is connected to the processor 402. The transmission device 406 can be used to receive or send data via a network.

[0103] Optionally, in this embodiment, the processor 402 can be configured to perform the following steps via a computer program:

[0104] S1: Call the C++ middleware to obtain SAS statements from the SAS language analysis software.

[0105] 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;

[0106] S3: Use C++ middleware to recognize SAS statements and convert them into database-recognizable statements.

[0107] S4: Use C++ middleware to pass database-recognizable statements to the corresponding database through a database connection pool.

[0108] or:

[0109] S1: Call the C++ middleware to obtain SAS statements from the SAS language analysis software.

[0110] 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;

[0111] S3: Use C++ middleware to recognize SAS statements and convert them into database-recognizable statements.

[0112] S4: Use C++ middleware to pass database-recognizable statements to the corresponding database through a database connection pool;

[0113] S5: The database executes database-recognizable statements and returns the raw result set to the C++ middleware;

[0114] 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;

[0115] S7: Use C++ middleware to pass the final result set to SAS language analysis software.

[0116] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated here.

[0117] Generally, various embodiments can be implemented in hardware or dedicated circuitry, software, logic, or any combination thereof. Some aspects of the invention can be implemented in hardware, while others can be implemented by firmware or software executed by a controller, microprocessor, or other computing device, but the invention is not limited thereto. Although various aspects of the invention may be shown and described as block diagrams, flowcharts, or using some other graphical representation, it should be understood that, by way of non-limiting example, these blocks, apparatuses, systems, techniques, or methods described herein can be implemented in hardware, software, firmware, dedicated circuitry or logic, general-purpose hardware or controllers or other computing devices, or some combination thereof.

[0118] Embodiments of the present invention can be implemented by computer software, which may be executable by a data processor of a mobile device, such as a processor entity, or by hardware, or by a combination of software and hardware. Computer software or programs (also referred to as program products), including software routines, applets, and / or macros, can be stored in any device-readable data storage medium, and they include program instructions for performing specific tasks. A computer program product may include one or more computer-executable components configured to perform embodiments when the program is run. One or more computer-executable components may be at least one piece of software code or a portion thereof. Additionally, it should be noted that any block in the logical flow of the figures may represent a program step, or interconnected logical circuitry, blocks and functions, or a combination of program steps and logical circuitry, blocks and functions. The software may be stored on physical media such as memory chips or blocks of storage implemented within a processor, magnetic media such as hard disks or floppy disks, and optical media such as, for example, DVDs and their data variants, CDs, etc. The physical medium is a non-transient medium.

[0119] Those skilled in the art should understand that the technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments have been described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0120] The above embodiments are merely illustrative of several implementation methods of this application, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A method of accessing a database interface layer in SAS language, characterized by, The method comprises the following steps: S1: calling a C++ middleware to obtain an SAS statement from an SAS language analysis class software; S2: identifying database information in the SAS statement through 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 statement through the C++ middleware and converting the SAS statement into a database recognizable statement; S4: transmitting the database recognizable statement to a corresponding database through the database connection pool by using the C++ middleware; Six statement conversion rules are set in the C++ middleware, when the C++ middleware identifies a proc sql, a proc import or a data step in the SAS statement, the corresponding SAS statement is converted into a database recognizable statement by calling the statement conversion rules; The six statement conversion rules are as follows: An input() function is converted into a CAST() function: when an input( character value, numerical value format) structure is identified in the SAS statement, and the function is to convert character type data into numerical type, the input() is converted into a SQL function CAST(); A put() function is converted into a CAST() function: when a put( numerical value, character format) is identified in the SAS statement, and the function is to convert numerical type into character, the put() is converted into a SQL function CAST(), that is, the character length requirement of the put() function is retained; An SAS date format ('day mon year') is converted into TO_DATE: when a 'day mon year' date format is identified in the SAS statement, it is judged whether the database is dmsql, GBase, GaussDB or Kingbase, if yes, the SAS date format is parsed into a standard date format of "year-month-day" and converted into a SQL function TO_DATE; An SAS date format ('year-month-day time:minute:second') is converted into TO_DATE: when a 'year-month-day time:minute:second' date format is identified in the SAS statement, it is judged whether the database is dmsql, GBase, GaussDB or Kingbase, if yes, the "year-month-day time:minute:second" structure of the SAS date and time is retained and the function is converted into a SQL function TO_DATE; A null value identifier =. is converted into IS NULL: when =. is identified in the SAS statement, it is converted into a SQL statement IS NULL; A non-null value identifier ^=. is converted into IS NOT NULL: when ^=. is identified in the SAS statement, it is converted into a SQL statement IS NOT NULL.

2. The method of Claim 1, wherein the SAS language accesses the database interface layer. The SAS statement in step S1 is a data connection request statement or a data query statement, and a connection type and connection requirement of data access are specified in the SAS statement.

3. The method of Claim 1, wherein the SAS language accesses the database interface layer. The SAS language analysis software uses a built-in libname statement and a proc sql process step as a built-in I / O engine, wherein the libname statement is used to define a logical library name for a target database, and the proc sql process step is a data query and operation module in the SAS statement that supports SQL syntax.

4. The method of Claim 1, wherein the SAS language accesses a database interface layer. The C++ middleware has a built-in mapping library of segmentation results-connection types, and sets extraction rules of connection parameters corresponding to the connection types. The C++ middleware matches the connection types from the mapping library according to the segmentation results of the SAS statement, calls a connection module based on the connection types, and extracts connection parameters from the SAS statement according to the connection types to establish a database connection pool.

5. The method of claim 1, wherein, if the SAS statement contains libname and dmsql / gbase / tdsql / gaussdb / kingbase, the connection type is database direct connection, a C++ middleware direct connection module is called, and a database connection pool is established through server, port, user, password, and database; if the SAS statement contains libname and jdbc, the connection type is JDBC interface connection, a C++ middleware JDBC module is called, and a database connection pool is established through class, url, uid, pwd, and schema; if the SAS statement contains libname and odbc, the connection type is ODBC interface connection, a C++ middleware ODBC module is automatically called, and a database connection pool is established through datasrc, user, and password; if the SAS statement contains proc sql and connect to dmsql / gbase / tdsql / gaussdb or kingbase, the connection type is database direct connection, a C++ middleware direct connection module is called, and a 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; if the SAS statement contains proc sql and connect to odbc, the connection type is ODBC interface connection, a C++ middleware ODBC module is called, and a 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. 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. 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.

6. The method of Claim 1, wherein the SAS language accesses a database interface layer. The method comprises the following steps: 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 into 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.

7. The method of Claim 6, wherein the SAS language accesses the database interface layer. The data type conversion rule of the C++ middleware is as follows: Conversion of numerical type: if the data type in the original result set is a numerical type, the data type is converted into the NUM type in the SAS statement; Conversion of character type: if the data type in the original result set is a character type, the data type is converted into the CHAR type in the SAS statement; Conversion of date and time type: if the data type in the original result set is a date and time type, the data type is converted into the NUM type in the SAS statement, and the FORMAT is yymmdd10. or time8. or datetime20.; Conversion of Boolean type: if the data type in the original result set is a Boolean type, the data type is converted into the CHAR type in the SAS statement; Conversion of binary type: if the data type in the original result set is a binary type, the data type is converted into the CHAR type in the SAS statement; Conversion of other special types: if the data type in the original result set is other special types, the data type is converted into the CHAR type in the SAS statement.

8. A system for performing the method of the SAS language access database interface layer of any one of claims 1 to 5, characterized by The method comprises the following steps: The SAS language analysis class software, the C++ middleware, and the general database, wherein the SAS language analysis class software uses an I / O engine to establish communication with the C++ middleware through a TCP / IP protocol, and the C++ middleware establishes communication with the general 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