Mid-Michigan Computer Consultants - Bay City, Michigan

CONTENTS       (old style)
Mid-Michigan Computer Consultants
509 Center
Bay City, Michigan

Sales (989) 892-9242
Support (989) 686-8860

Plb-0520.cfm v1.0


ANSI Standard PL/B Language and Visual PL/B

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:

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:

  1. In the PL/B Language Reference manual, check out the section named 'PLB Language Changes' related to the SQLIO support.

  2. Look at the Sql Tag Attributes like the 'template={filename}' and 'file_name=filename' that can be used to override program settings.

  3. The Sql Tag Attributes were implemented to provide the flexibility to address your temporary file requirements.

  4. You still must have a schema file definition. This can be a generic schema definition for your temporary file usage.

  5. The SQLIO Getting Started section has an example that shows the 'Template=' usage.

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

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

Calculate    FUNCTION

Exp    DIM 100

Data   DIM     40
F1     FORM  "10"Sel
Cmd    DIM     200
xRes   FORM  10.10
       TYPE Exp
       IF EOS
            RETURN using xRes
       GETFILE Conn
       IF NOT ZERO
            DbConnect Conn, "SQLITE;;:memory:","",""
       PACK SelCmd, "SELECT ( ", Exp, " )"
       DbSend Conn;SelCmd
       DbExecute Conn
       DbFetch Conn,F1;Data
       TYPE Data
       IF EQUAL
          MOVE Data, xRes
       RETURN USING xRes


Plb-0520.cfm v1.0

Write to MMCC Technical Support at:               Send e-mail to MMCC.
MMCC - Technical Support
600 W. Midland
Bay City, MI 48708
(989) 686-8860
© 1997 - 2017 MMCC - All Rights Reserved