|
|
BSQL Commands
Command
Function
CLOSE Closes active log files, see CLOSE. DESCRIBE Describes a specified object, see DESCRIBE. EXIT Leaves BSQL, see EXIT. GET DIAGNOSTICS Presents status and diagnostics information, see LIST Lists information on a specified object, see LIST. LOG Logs input, output or both on a sequential file, see LOG. READ INPUT Reads commands from a sequential file, see READ INPUT. READLOG Obtains information about logged operations, see READLOG. SET ECHO Specifies whether lines are echoed to the terminal during READ INPUT, see SET ECHO. SET EXECUTE Activate or deactivate the execution of queries, see SET EXECUTE. SET EXPLAIN Activate or deactivate the explain facility, see SET EXPLAIN. SET LINECOUNT Sets the terminal page size, see SET LINECOUNT. SET LINESPACE Sets the number of blank lines between each output record, see SET LINESPACE. SET LINEWIDTH Sets the terminal page width, see SET LINEWIDTH. SET LOG Stops or resumes logging input, output or both, see SET LOG. SET MAX_BINARY_LENGTH Specifies the maximum display length for binary columns, see SET MAX_BINARY_LENGTH. SET MAX_CHARACTER_LENGTH Specifies the maximum display length for character columns, see SET MAX_CHARACTER_LENGTH. SET MESSAGE Specifies whether messages are displayed on the terminal, see SET MESSAGE. SET OUTPUT Specifies whether output should be written to the terminal, see SET OUTPUT. SET PAGELENGTH Defines the page length of output file, see SET PAGELENGTH. SET PAGEWIDTH Defines the page width of output file, see SET PAGEWIDTH. SHOW SETTINGS Displays current values of all set options, SHOW SETTINGS. TRANSACTIONS Displays the menu for administrating distributed transactions, see TRANSACTIONS. WHENEVER Sets action to be taken in response to an error or warning, see WHENEVER.BSQL commands are not case sensitive.
About BSQL Syntax Descriptions
For information on how to read the syntax diagrams that follow, please refer to Mimer SQL Reference Manual, Reading SQL Syntax Diagrams.
CLOSE
Syntax
Description
The command closes the specified log file. If no log type is specified, all active log files are closed.
DESCRIBE
Syntax
Description
The DESCRIBE command presents the following menu, when no object is specified:
Menu for describe 1. Databank 6. Table 11. Trigger 2. Domain 7. View 12. Sequence 3. Ident 8. Module 13. Schema 4. Index 9. Procedure 14. Shadow 5. Synonym 10. Function 15. Collation 0. ExitChoosing an item presents a submenu for choosing between different DESCRIBE functions - see the table that follows for details.
Entering an exclamation mark (!) in the Select field returns to the previous menu level. Entering a double exclamation mark (!!) terminates the DESCRIBE session.
Specifying an object type and name in the command executes the first menu choice for that object. If no object name is given, the user is prompted for a name.
Selection numbers should not be used in batch files, since they may change in future versions.
DESCRIBE DATABANK Options
DESCRIBE IDENT Options
DESCRIBE INDEX Options
DESCRIBE INDEXResult
BRIEF Lists the following information on the specified index:table name and columns on which the index is defined
sort order
uniqueness
comment
creation date.DESCRIBE SYNONYM Options
DESCRIBE SYNONYMResult
BRIEF Lists the following information on the specified synonym:schema and name of referenced table/view
comment
creation dateDESCRIBE TABLE Options
DESCRIBE VIEW Options
DESCRIBE VIEWResult
BRIEF Lists the following information on the specified view:view definition
comment
creation date.DESCRIBE MODULE Options
DESCRIBE MODULEResult
BRIEF List the following information on the specified module:module definition
comment
creation date.DESCRIBE PROCEDURE Options
DESCRIBE FUNCTION Options
DESCRIBE TRIGGER Options
DESCRIBE SEQUENCE Options
DESCRIBE SCHEMA Options
DESCRIBE SCHEMAResult
BRIEF List the following information about the specified schema:schema owner
contained objects
comment
creation date.DESCRIBE SHADOW
DESCRIBE SHADOWResult
BRIEF List the following information on the specified shadow:shadow creator
databank name
file name
comment
creation dateDESCRIBE COLLATION
EXIT
Syntax
Description
GET DIAGNOSTICS
Get diagnostics for statement.
Syntax
Description
Presents all status and diagnostics information for the preceding statement.
LIST
Lists information on a specified object.
Syntax
Description
The LIST command presents the following menu, if no object-type is specified:
Menu for List 1. Databanks 6. Synonyms 11. Functions 2. Domains 7. Tables 12. Triggers 3. Idents 8. Views 13. Sequences 4. Indexes 9. Modules 14. Schemata 5. Objects 10. Procedures 15. Shadows 16. Collations 0. ExitChoosing an item presents a submenu for choosing between different LIST functions - see the table that follows for details.
Entering an exclamation mark (!) in the Select field returns to the previous menu level. Entering a double exclamation mark (!!) returns two levels.
Giving an object type in the command executes the first menu choice for that type.
Selection numbers should not be used in batch files, because the may change in future versions.
LIST COLLATIONS Options
LIST COLLATIONSResult
ALL Lists all collations in the database. IN SCHEMA Lists collations in the specified schema.LIST DATABANKS Options
LIST DATABANKResult
ALL Lists all databanks in the database. CREATED BY Lists databanks created by a specified ident.LIST DOMAINS Options
LIST DOMAINSResult
ALL Lists all domains in the database. IN SCHEMA Lists domains in the specified schema.LIST FUNCTIONS Options
LIST FUNCTIONSResult
ALL Lists all the functions the current ident has execute privilege on. IN SCHEMA Lists functions in the specified schema.LIST IDENTS Options
LIST IDENTSResult
ALL Lists all idents in the database. CREATED BY Lists idents created by a specified ident.LIST INDEXES Options
LIST INDEXESResult
ALL Lists the secondary indexes in the database. IN SCHEMA Lists secondary indexes in the specified schema.LIST MODULES Options
LIST MODULESResult
ALL Lists all the modules in the database that are visible to (i.e. created by) the current ident.LIST OBJECTS Options
LIST OBJECTSResult
ALL Lists objects in the database. CREATED BY Lists objects created by a specified ident. WITH TYPE Lists objects of a specified type.LIST PROCEDURES Options
LIST PROCEDURESResult
ALL Lists all the procedures the current ident has execute privilege on. IN SCHEMA Lists procedures in the specified schema.LIST SCHEMATA Options
LIST SEQUENCES Options
LIST SEQUENCESResult
ALL Lists all the sequences the current ident has usage privilege on. IN SCHEMA Lists sequences in the specified schema.LIST SHADOWS Options
LIST SHADOWSResult
ALL List shadows created on databanks created by the current ident or all shadows if the current ident has shadow privilege.LIST SYNONYMS Options
LIST SYNONYMSResult
ALL Lists synonyms in the database. IN SCHEMA Lists synonyms in the specified schema.LIST TABLES Options
LIST TABLESResult
ALL Lists tables in the database. IN SCHEMA Lists tables in the specified schema.LIST TRIGGERS Options
LIST TRIGGERSResult
ALL List triggers defined on tables accessible to current user. IN SCHEMA Lists triggers in the specified schema.LIST VIEWS Options
LOG
Logs input, output or both to a specified sequential file.
Syntax
Description
All input, output or both will be logged in the specified sequential file.
If ON is specified a new file will always be created, otherwise the log data is appended to the file.
Logging is stopped with the SET LOG OFF command and is resumed with the SET LOG ON command.
Using the AS option, you can set the file format to UTF8, UTF16, UTF16BE, UTF16LE, UTF32, UTF32BE or UTF32LE.
READ INPUT
Reads commands from a sequential file.
Syntax
Description
Commands and SQL statements are read from the specified file.
When READ COMMAND INPUT is specified, commands are read from the file while prompt answers are taken from the terminal (batch job, command procedure).
When READ ALL INPUT or READ INPUT is specified, both commands and prompt answers are read from the sequential file.
Using the AS option, you can set the file format to UTF8, UTF16, UTF16BE, UTF16LE, UTF32, UTF32BE or UTF32LE.
READLOG
Obtains information about logged operations.
Syntax
Description
READLOG is a Mimer SQL function which enables you to read the contents of LOGDB so that you can check logged operations performed on the database since the last backup copy or incremental backup was taken.
You can use READLOG as an audit trail or, in the event of a system failure, to determine which databanks need to be restored (i.e. which databanks have been altered since the last backup).
Functions
READLOG enables you to select information from LOGDB on the basis of time interval, ident performing the operation, and specified databanks or tables.
This is particularly useful in production systems where LOGDB can contain a large number of entries.
Authorization
To list the log for selected tables or all tables in a databank, you must have SELECT access on the tables in question.
To list the log for the entire database, you must have BACKUP privilege.
Using the READLOG Functionality
You control the READLOG functionality using a menu from which different listing options may be set before finally performing the read operation.
The different listing options are set by using menu selections 1-5. The menu is re-displayed after selecting any of these so that further options may be set for the listing.
When all the desired listing options have been set in this way, a listing is produced from the log by choosing menu selection 6, 7 or 8 from under List operations.
-- Read log -- List definitions List restrictions List operations ---------------- ----------------- --------------- 1. Log file 3. Time interval 6. Specified tables 2. File properties 4. Ident 7. Tables in databank 5. Databank 8. All (no data) 0. EXITList Definitions - Output Control
- Log File
Choosing Log file allows you to specify the name of a sequential file into which the listing is to be placed. In systems where the terminal may be addressed by a logical file name, this may be given to display the listing on the terminal.
If this option is not selected, a sequential file with the default name RDLOGL will be used.
The following examples sets the log file explicitly:
Select: 1 Log list file: READLOG.DAT
- List Properties
The file properties choice is used to set either the width of a report or the format for the log file. The file format can be one of the following encodings:
1. Default 2. Latin 1 3. UTF 8 4. UTF 16 5. UTF 16 big endian 6. UTF 16 little endian 7. UTF 32 8. UTF 32 big endian 9. UTF 32 litte endianDefault means the encoding specified by the locale settings for the client.
List Restrictions
- Time interval
This option allows the listing to be restricted to a given time interval, specified as a starting time and a finishing time.
Times are given as a single parameter representing year, month, day, hour, minute and second in the format YYYYMMDDHHMMSS.
If an incomplete time specification is given (truncated from the right), the remaining parameters are taken as low for the starting time and high for the finishing time. Thus giving 200211 as both the starting and finishing time, lists the log from the beginning to the end of November 2002.
A default time value is assumed if no time interval is specified, or may be chosen for starting or finishing time by specifying a `blank' time.
If no start time is specified, the time at the beginning of the log is assumed. If no end time is specified, the time at the end of the log is assumed.
If neither a start time nor an end time is specified, the following message is displayed:
** No time restrictionA selected time interval applies for all subsequent list operations in the current session until the time interval is reset.
A time interval of two months has been selected in the following example:
Select: 3 Format : YYYYMMDDHHMMSS Starttime: 200311 Endtime : 200312
- Ident
Selecting an ident restricts the listing to operations performed by that ident. Only one ident may be selected for a given listing.
The default setting lists operations performed by all idents.
The default applies if no ident restriction is selected, or may be chosen by specifying a blank ident. If the default is chosen, the following message is displayed:
** No ident restrictionA selected ident applies for all subsequent list operations in the current session until a new ident is specified.
Select: 4 Identname: mimer_store
- Databank
Selecting a databank restricts the listing to operations performed on that databank. This option must be specified if the list operation 7 (Tables in databank) is to be used. Only one databank may be selected for a given listing.
If no databank is specified, the list operation is done for all databanks. If this is the case, the following message is displayed:
** No databank restrictionA selected databank applies for all subsequent list operations in the current session until the databank is reset.
Select: 5 Databank: mimer_ordersList Operations
- Specified Tables
This option activates listing of the log for selected tables in the database.
As many tables may be specified as are required, with the table name qualified, if necessary, by the name of the schema to which it belongs.
If no schema is specified, the schema with the same name as the current ident is assumed.
Databank restrictions selected with option 5 are ignored if specified tables are selected. However, any ident and time restrictions selected with options 3 and 4 are applied.
The ident running READLOG must have SELECT access on the requested tables, otherwise the following message is displayed for the table in question:
** No select access on tableIf a non-existent table is requested, the following message is displayed:
** No such tableErrors of this type do not abort the listing if valid and invalid requests are mixed in the same operation.
The list operation is activated by giving a blank response to the prompt for a table name when all the required tables have been specified, as in the following example:
Select: 6 Table: HOTELADM.EMPLOYEE Table: HOTELADM.STAFF Table: HOTELADM.SALARY Table:Note: The list operation can be interrupted by entering an exclamation mark !.
- Tables in Databank
Operations on all tables in the databank specified under option 5 are listed. If no databank has been selected, the following message is displayed and the user must select a new option:
**Databank not enteredTime or ident restrictions selected with options 3 or 4 are applied.
Data is listed only for those tables to which the ident running READLOG has SELECT access.
Tables to which access is denied are indicated by the following message in the log list file:
Table <schema-name.table-name> - No select access
- All (No Data)
This option lists logged operations without details of data records (see below). The ident running READLOG must have BACKUP privilege.
If the privilege is not held by the current ident the following error message is displayed:
** AUTHORIZATION FAILUREOutput Format
The output from READLOG is divided into transactions, showing the date and time, the ident performing the transaction (with entered program idents where appropriate) and the number of database records read during the transaction.
Note: The output does not contain statements for reconstructing the logged operations - it is simply a documentary record of the transactions performed on the database
If list operations 6 or 7 (select by Specified tables or Tables in databank) are selected, the contents of the affected rows in the table are displayed. Insert and delete operations are listed as a single row. Update operations are recorded as the state of the row before and after the update.
If the list operation 8, All (no data), is selected the operations are listed without the data records.
SET ECHO
Controls whether or not lines read during READ INPUT are echoed.
Syntax
Description
When echo is set to ON, lines read during READ INPUT are echoed to the terminal or batch log file. When echo is set to OFF, these lines are not echoed. The default value is ON.
The setting has no effect on the output of responses to BSQL commands and statements.
SET EXECUTE
Activate or deactivate the execution of queries.
Syntax
Description
When execute is set to off no queries will be executed, only the syntax is checked. This can be useful when testing a script for correctness or when using the explain facility.
SET EXPLAIN
Activate or deactivate the explain facility.
Syntax
Description
When the explain facility is activated the execution plan for the query is shown. By default the query will be executed, to avoid this behavior the SET EXECUTE command can be used.
The execution plan will show different operations and the sequence in which these operations are performed. The following operations can be shown when the explain facility is active:
For more details, see the following article http://developer.mimer.com/howto/howto_46.htm
SET LINECOUNT
Sets the length of the terminal page.
Syntax
Description
The LINECOUNT value defines the length of the terminal page.
If LINECOUNT has a value greater than zero, terminal output will temporarily be stopped after the number of lines defined for the value.
After the Continue-prompt, the user will have the choice of either continuing with the display or terminating the output.
Answering `Y' (default) implies that the output will continue until the number of lines is reached again.
Answering `N' terminates the output. Answering `G' will ignore the line count and the output will continue until all data are displayed.
If LINECOUNT is zero, the output will continue until all data is displayed.
The value of LINECOUNT must either be zero or >= 10.
Default
If BSQL is run from a batch job, LINECOUNT is zero by default. For interactive operation, the default value is machine- and terminal-dependent.
SET LINESPACE
Sets the number of blank lines between each output record.
Syntax
Description
The LINESPACE value defines the number of blank lines to be written between each output record. This value is only used when printing the result of a SELECT statement.
The maximum value for LINESPACE is 9. The default value is 0.
SET LINEWIDTH
Specifies the width of the output.
Syntax
Description
The LINEWIDTH value defines the maximum line width for output to the terminal or batch log file.
The value for LINEWIDTH cannot be set to a value less than 20.
SET LOG
Stops or resumes logging input, output or both.
Syntax
Description
When SET LOG is set to OFF, logging of input, output or both in a sequential file is temporarily stopped.
Resume logging with the SET LOG ON command.
If no input/output log is specified, all active logs are stopped or resumed.
SET MAX_BINARY_LENGTH
Specifies the maximum display length for binary columns.
Syntax
Description
The MAX_BINARY_LENGTH value defines the number of elements that are displayed when selecting data that is defined as binary, binary varying or binary large object.
The default value is 15 000 and the value must be between 1 and 15 000.
As a binary string is shown as a hexadecimal string with two characters for each element the display length will be twice the value of MAX_BINARY_LENGTH.
SET MAX_CHARACTER_LENGTH
Specifies the maximum display length for character columns.
Syntax
Description:
The MAX_CHARACTER_LENGTH value defines the number of characters that are displayed when selecting data that is defined as any character data type.
The default value is 15 000 and the value must be between 1 and 15 000.
SET MESSAGE
Specifies whether or not messages should be displayed.
Syntax
Description
Specifies whether or not result messages such as One row found etc. are written to the terminal screen or batch log file.
SET OUTPUT
Specifies whether or not output should be displayed.
Syntax
Description
When OUTPUT is set to ON, the output from BSQL is written to the terminal or batch log file. When it is set to OFF, the output does not appear.
SET PAGELENGTH
Specifies the page size of the output log file.
Syntax
Description
The PAGELENGTH value defines the page size of the file on which output is logged, i.e. at what interval a page break will be performed. A value of zero will result in no page breaks.
The PAGELENGTH value can either be set to zero or >= 10. The default value is machine-dependent.
SET PAGEWIDTH
Specifies the page width of the output log file.
Syntax
Description
The PAGEWIDTH value defines the page width of the output file. The value should be greater than 20. The default value is 132.
SHOW SETTINGS
Displays the current values of all set options.
Syntax
Description
Displays the current values for all set options, i.e.
ECHO LINESPACE OUTPUT TRANSACTION START EXECUTE LINEWIDTH PAGELENGTH TRANSACTION ISOLATION LEVEL EXPLAIN LOG PAGEWIDTH TRANSACTION MODE (read only or read write) LINECOUNT MESSAGECurrent server and connection names are also displayed.
TRANSACTIONS
Displays the menu for administrating distributed transactions.
Syntax
Description
You can use the TRANSACTIONS command to monitor distributed transactions that are in a prepared or heuristically completed state. Note that all transactions are uniquely identified by the XID string. Because those strings are somewhat long, BSQL assigns a small sequence number to each line to be used as a shorthand. This shorthand is only valid until the List transactions option is used again. Note that since transactions are normally short-lived, the same transaction may be assigned different sequence numbers each time the List transactions option is used.
Note: The TRANSACTIONS command should only be used in exceptional circumstances, such as when a transaction monitor has crashed or a network failure has occurred making it is impossible to establish contact with a transaction monitor.
The command will present the following menu:
Menu for handling distributed transactions 1. List transactions 2. Heuristic commit 3. Heuristic rollback 0. ExitThe List transactions option displays a list of all distributed transactions that are either in a prepared ore heuristically completed state. For example:
NUMBER STATUS XID ====== ========== =============================================================== 1 Prepared 34C6F6E675849446E616D6520 === 2 Prepared C6F6E675849446E616D6520 === 2 transactions foundTo heuristically commit or rollback a distributed transaction, you can choose option 2 or 3 in the menu. This will prompt for a transaction number which should correspond to a number in the listing. It is not possible to heuristically commit or rollback a distributed transaction without a prior listing.
When a distributed transaction is heuristically committed or rolled back it will remain in the list until it has been forgotten by the transaction monitor.
If the transaction with sequence number 1 (XID 34C6F6E675849446E616D6520) was heuristically committed a subsequent listing would look like this:
NUMBER STATUS XID ====== ========== =============================================================== 1 Prepared C6F6E675849446E616D6520 === 2 Committed 34C6F6E675849446E616D6520 === 2 transactions foundMore information on distributed transactions in general, can be found in the Mimer SQL Programmer's Manual, Distributed Transactions.
WHENEVER
Determines which actions should be taken in the event of an error or warning.
Syntax
Description
If an error or warning should occur in a file being run in batch, there are several action options that may be chosen to determine what should happen.
The actions can be broken down into two groups:
Execution Flow
|
Mimer Information Technology AB Voice: +46 18 780 92 00 Fax: +46 18 780 92 40 info@mimer.se |
|
|