I.1 Integrated Database Access
One of the major features of Sheerpower is its ability to perform database
operations integrated into the language.
To access the payroll table in a database, you enter the following:
open table payroll: name '@..\data\payroll'
This opens the payroll table with a reference name of PAYROLL.
The table is found in the data folder.
To print the salary field in a payroll table, you would give the name of the
table and the name of the field:
Unlike SQL and many other query languages, Sheerpower is careful to separate
data from functions. This makes it impossible for hackers to launch
SQL INJECTION ATTACKS
against a website that uses Sheerpower on the back end.
In order to access a specific record in a table, it must be current
successful key lookup causes a record to be current. Within an extract/end
block, each record becomes current. Within a for each/next
block, each record also becomes current.
In general, table records are first collected using extract/end
and then iterated through using for each/next
. This is
done as two steps in order for collected records to be optionally sorted.
After any operation that could make a record current
, the internal
will be zero if no record was found or will
reflect the number of records found.
An extract/end extract
block can contain:
- exclude nn -- where nn is a logical expression
- include nn -- where nn is a logical expression
- exit extract -- get out of the block with collected records
- cancel extract -- get out of the block without any collected records
- sort by xxx -- where xxx is any arbitrary expression, usually containing a database table reference
- sort descending by xxx -- where xxx is any arbitrary expression as well