SATMYSQL Reference |
Usage |
Syntax: | satmysql ?suffix? |
---|---|
?suffix?: | Suffix for SATMYSQL error messages. |
Example: | satmysql Customer |
SATMYSQL reads mysql output data from standard input. SATMYSQL output will be in a format suitable for either SATGUI or SATFORM depending on the SATMYSQL commands (if any) embedded in the SQL. The default action is to produce SATGUI formatted output.
SATMYSQL returns "0" if the command/SQL statements succeed, otherwise it returns "1". The no-fail command prevents SATMYSQL failing if the associated SQL statement fails.
SATMYSQL Commands |
SATMYSQL commands are embedded in SQL as select statements.
Syntax: |
select 'satmysql ?commands? ?list?'; |
---|---|
?commands?: | continue force no-fail print silent silent-fail silent-ok |
?list?: | If not a recognised command, name of Multi Column List (SATGUI) or list prefix (SATFORM). |
Example: | select 'satmysql silent no-fail'; |
All SQL output begining "satmysql" is seen as a SATMYSQL command. The command effects the following SQL statement only.
By default SATMYSQL will generate output suitable for SATGUI, SATGUI messages will be generated for success/failure of all SQL satements, and an SQL failure/error will cause SATMYSQL to stop processing.
NOTE: The last command which is not a recognised command is assumed to be the name of a list. A list, therefore, cannot have the same name as a SATMYSQL command.
The continue command causes SATMYSQL to not output a form-feed after formatting the result of the next select statement when in print mode. This allows the results of more than one select statement to be formatted as data for a single SATFORM form.
NOTE: If the last select statement "continues" the data will not be processed by SATFORM.
The force command causes SATMYSQL to produce an empty list if the next select statement returns no data when in display/list mode.
The no-fail command prevents SATMYSQL from failing if the next SQL statement fails.
The print command causes SATMYSQL to create output in a format suitable for printing using SATFORM. No success/failure messages are generated, in effect print is implicitly "silent".
NOTE: Print and display output types must not be mixed.
The silent command prevents SATMYSQL from generating success/failure messages.
NOTE: SATMYSQL is always "silent" when in print mode.
The silent-fail command prevents SATMYSQL from generating failure messages.
NOTE: SATMYSQL is always "silent" when in print mode.
The silent-ok command prevents SATMYSQL from generating success messages.
NOTE: SATMYSQL is always "silent" when in print mode.
SATMYSQL Output Formats |
SATMYSQL can output data in four formats:
Examples:
For example purposes the following database called "custom" is assumed.
customer_ref customer address address2 address3 ------------ --------------- -------- --------------- ----------- A001001 Fred Smith 12 Long Avenue Townsville A001003 Mary Jones 154 Green Street Townsville A001007 Harry Dodd 98 Tall Buildings Metropolis
The default action is for SATMYSQL to generate a SAT/DL setItems command. The SQL result column names are used as the SAT/DL item names.
The default mode can only be used where the SQL will produce a single row.
select customer,address,address2,address3 from custom where customer_ref='A001003';...will generate...
setItems {{customer {Mary Jones}} {address {154}} {address2 {Green Street}} {address3 {Townsville}}}
If a list is specified SATMYSQL generates a SAT/DL setItem command. The name of the list must match the name of a Multi Column List item. Each row of the SQL result will be a row in the Multi Column List.
select 'satmysql customers'; select customer_ref,customer from custom;...will gernerate...
setItem {customers {A001001\tFred Smith} {A001003\tMary Jones} {A001007\tHarry Dodd}}...where \t represents a TAB character.
If the print command is specified SATMYSQL generates data formatted for SATFORM.
Print mode can be used where the SQL result is more than one row. A FORM-FEED is inserted
between the data for each row, therefore each row will be a new SATFORM form. This
could be used for tasks such as batch production of letters for a mail-shot.
select 'satmysql print';
select customer,address,address2,address3 from custom where customer_ref='A001003';
...will generate...
customer\034Mary Jones
address\034154
address2\034Green Street
address3\034Townsville
\f
...where \034 represents OCTAL character 034 (delimiter used by
SATFORM), and \f represents FORM-FEED.
SATMYSQL Messages |
By default SATMYSQL will generate SATGUI compatible (setMessage) commands to indicate the success/failure of an SQL statement. Success messages are black, error messages red.
Message formats:
Success: | action Ok |
---|---|
Failure: | Unable to action ?suffix? |
action: | First word of SQL statement. |
?suffix?: | Message suffix passed as parameter to SATMYSQL. |
Examples:
SQL statement | Suffix | Result | Message |
insert | NONE | SUCCESS | Insert Ok |
insert | NONE | FAILURE | Unable to Insert |
insert | Customer | SUCCESS | Insert Ok |
insert | Customer | FAILURE | Unable to Insert Customer |
update | Product | FAILURE | Unable to Update Product |