|
|
 |
DeviceSQL Compiler
The DeviceSQL Compiler analyzes statements written in the DeviceSQL language and compiles them into optimized ANSI C source code. This C code is then compiled along with the rest of your application code.
The DeviceSQL Compiler only compiles DeviceSQL code. It analyzes the schema, logic and runtime services described in the DeviceSQL language to generate an optimal implementation in ANSI C source code. The DeviceSQL compiler is used only during development.

The DeviceSQL Compiler can be invoked via command-line options or integrated with various IDEs and tool-chains. To assist with application development and debugging, the compiler indicates errors for code syntax, analysis and usage.
DeviceSQL Language
The DeviceSQL language is a procedural form of SQL that is used to define the data structures for tables and data streams, the logic for manipulating data, and for selecting which DeviceSQL Runtime Services to use, such as storage services, index types, callback events and more. It is also used to describe the sources, destinations and structure for both persistent data and dynamic data streams. Since it is procedural, you naturally create “functions” in DeviceSQL to handle all of the logic for dealing with data. These DeviceSQL functions will be converted into C functions that the application code can call just like any other C function.
With DeviceSQL, you define and manipulate your data using simple SQL statements and invoke the DeviceSQL Compiler to generate an optimal ANSI C implementation for you. Compiling DeviceSQL statements into in-line code results in the fastest, most deterministic performance out of the three DeviceSQL interface methods since it does not require interpretation at runtime. Furthermore, with a Developer-Defined API, this approach typically enables the easiest integration with existing code since you can match the C calling interface with whatever works best for your applications.
Sample DeviceSQL Code
| |
|
|
| |
CREATE TABLE Caller (
CallID INT32,
CallNum PHONECHAR,
CallName VARCHAR,
CallPicture BINARY,
CallStatus BIT8);
..
FOR EACH rec IN (SELECT * FROM Caller)
LOOP
DisplayCaller(rec.Name, rec.CallNum);
END LOOP;
..
START WRITE TRANSACTION;
UPDATE Caller SET CallStatus = 2 ..;
INSERT CallLog VALUES (N_ID, Start, ..);
COMMIT;
..
--Backup
SM_COPY(‘Main_Data’, ‘\bu\’ || TDate);
|
|
| |
|
|
| |
INSERT INTO tabLog
(SELECT CurrDate, Message, Status, Event
FROM Events, Messages
WHERE Events.EventID = Messages.EventID);
..
CREATE FUNCTION ListTrades(pStatus BIT8)
AS
EXPORT NAME “dm_ListTrades”;
BEGIN
FOR EACH Trd IN (SELECT * FROM CTrades
WHERE Status=pStatus)
LOOP
HandleTrade(Trd.ID, Trd.Timestamp, ..
END LOOP;
RETURN GOOD_RESULT;
EXCEPTION
WHEN TradeViolation THEN
HandleTrade(0,0,0,0);
RETURN BAD_RESULT;
WHEN OTHERS THEN
RETURN SQLCODE;
..
|
|
DeviceSQL is based on a small subset of the popular procedural form of SQL known as PL/SQL. It features extensions to the language specifically for embedded development and control, including:
- Control over storage (temporary, persistence, fragmentation, physical table locations, Flash, HD, FIFO, etc.
- Easier interactions with C code (callbacks and externs)
- Backup and restore facilities
- Procedural constructs including IF, THEN, ELSE, END, WHILE, LOOP
- Developer mutex/semaphore control
- Query control (interrupt, cancel, rapid iteration, materialization)
- Developer data types and operators (including BITx, INTx)
- Compact data types (PHONECHAR, Strings, Unicode, etc.)
- Custom memory handling (allocation and freeing)
- Streams (definition, input, output, handling, and control)
- Configurable APIs
- Exception handling and error recovery
If you would like to learn more about the DeviceSQL language, visit the Downloads page to access a copy of the DeviceSQL Language Reference Manual.
|
 |
Key Advantages
Ease of SQL Programming,
Performance of Hand-Coding
With DeviceSQL, you can manipulate your data with simple SQL statements and compile them into optimized ANSI C source code
High-Level Abstraction,
Low-Level Control
DeviceSQL provides the high-level abstraction of SQL together with procedural constructs and special extensions for low-level control
Fastest Path to Reliable Code
Improve code reliability, portability and maintainability by writing 50-90% less data manipulation code and letting the DeviceSQL Compiler generate reliable, consistent, portable C source code
Easier Integration
With three interface methods plus the ability to import existing C functions into DeviceSQL functions, DeviceSQL is the easiest data management technology to integrate with your existing applications
|