ANSI Standard PL/B Language and Visual PL/B
NOTE TO OUR READERS
This web resource is written for our own use. But we feel strongly that the PL/B language should be shared with the software community. So feel free to use this at will!
BUT PLEASE...
if you find errors or omissions or have a better way to do something. TELL US! Dialog helps us all. Send e-mail to:
support@mmcctech.com
SQLIO
SQL Lite support in PL/B
This is a SUNBELT ONLY language feature.
Sunbelt added SQL Lite to the Version 9 PL/B language suite around 2009.
These two links are to white papers on the sunbelt site:
Sunbelt's History of Data Access
Getting Started with SQLIO
The following discussions from the Sunbelt web board might be useful
when figuring out SQLite.
From Paul in New York:
In my programs, I frequently keep temporary data in temporary files. File names depend on the user, session, and program. Therefore, the file name varies greatly. I'm trying to use SQL to keep all my data including temporary files with SQLIO for total file system isolation. In order for data to be written to the SQL database, a schema entry is required. Without a schema entry, PLB just falls back to the file system. Is SQLIO intended to be used this way with all I/O go to the SQL database? What are your experiences? Is there a setting or different semantics for creating a SQL table without a schema entry? Thanks.
From Ed Boedecker at Sunbelt:
- In the PL/B Language Reference manual, check out the section named 'PLB Language Changes' related to the SQLIO support.
- Look at the Sql Tag Attributes like the 'template={filename}' and 'file_name=filename' that can be used to override program settings.
- The Sql Tag Attributes were implemented to provide the flexibility to address your temporary file requirements.
- You still must have a schema file definition. This can be a generic schema definition for your temporary file usage.
- The SQLIO Getting Started section has an example that shows the 'Template=' usage.
11/15/2011:
Alan Saliwanchik asked if there was a way to dymanically evaluate a CALC formula at runtime.
Ed Boedecker of Sunbelt replied as follows.
This gives an interesting use of the SQLite DBFILE
Alan,
1. There is no math expression parser built directly into the PLB runtime. Therefore, it is not possible to directly evaluate the string expression as you have presented.
2. Now, let me give you a jump start about another way to evaluate this expression. The PLB runtimes do have a SQLite database engine available. How about using the SQLite engine expression processing to evaluate your expression.
3. I set down and put together some sample code for everyone/you to think about.
Conn DBFILE
Result FORM 10.10
................................................................
MOVE "( 2 * 3 ) + 2", S$CMDLIN
CALL Calculate GIVING Result USING S$CMDLIN
DISPLAY *ll,S$CMDLIN,"...Result-->", Result
.
MOVE "( 5 / 2 )", S$CMDLIN
CALL Calculate GIVING Result USING S$CMDLIN
DISPLAY *ll,S$CMDLIN,"...Result-->", Result
.
MOVE "( 5.0 / 2.0 )", S$CMDLIN
CALL Calculate GIVING Result USING S$CMDLIN
DISPLAY *ll,S$CMDLIN,"...Result-->", Result
.
MOVE "( 5 % 2 )", S$CMDLIN
CALL Calculate GIVING Result USING S$CMDLIN
DISPLAY *ll,S$CMDLIN,"...Result-->", Result
.
KEYIN "Hit enter to exit...:",S$CMDLIN
SHUTDOWN
...............................................................
Calculate FUNCTION
Exp DIM 100
ENTRY
.
Data DIM 40
F1 FORM "10"Sel
Cmd DIM 200
xRes FORM 10.10
.
TYPE Exp
IF EOS
RETURN using xRes
ENDIF
.
GETFILE Conn
IF NOT ZERO
DbConnect Conn, "SQLITE;;:memory:","",""
ENDIF
.
PACK SelCmd, "SELECT ( ", Exp, " )"
.
DbSend Conn;SelCmd
DbExecute Conn
DbFetch Conn,F1;Data
.
TYPE Data
IF EQUAL
MOVE Data, xRes
ENDIF
.
RETURN USING xRes
.
FUNCTIONEND
Plb-0520.cfm v1.0