Using the SQL statement processor
The SQL statement processor allows SQL statements to be run from a source member. The statements in the source member can be run repeatedly, or changed, without compiling the source. This makes the setup of a database environment easier.
The SQL statement processor is available through the Run SQL Statements (RUNSQLSTM) command.
The statements that can be used with the SQL statement processor are:
- ALTER SEQUENCE
- ALTER TABLE
- CALL
- COMMENT ON
- COMMIT
- CREATE ALIAS
- CREATE DISTINCT TYPE
- CREATE FUNCTION
- CREATE INDEX
- CREATE PROCEDURE
- CREATE SCHEMA
- CREATE SEQUENCE
- CREATE TABLE
- CREATE TRIGGER
- CREATE VIEW
- DECLARE GLOBAL TEMPORARY TABLE
- DELETE
- DROP
- GRANT
- INSERT
- LABEL ON
- LOCK TABLE
- REFRESH TABLE
- RELEASE SAVEPOINT
- RENAME
- REVOKE
- ROLLBACK
- SAVEPOINT
- SET CURRENT DEGREE
- SET ENCRYPTION PASSWORD
- SET PATH
- SET SCHEMA
- SET TRANSACTION
- UPDATE
In the source member, statements end with a semicolon and do not begin with EXEC SQL. If the record length of the source member is longer than 80, only the first 80 characters will be read. Comments in the source member can be either line comments or block comments. Line comments begin with a double hyphen (--) and end at the end of the line. Block comments start with /* and can continue across many lines until the next */ is reached. Block comments can be nested. Only SQL statements and comments are allowed in the source file. The output listing and the resulting messages for the SQL statements are sent to a print file. The default print file is QSYSPRT.
To perform syntax checking only on all statements in the source member, specify the PROCESS(*SYN) parameter on the RUNSQLSTM command.
- Execution of statements after errors occur
If a statement returns an error with a severity higher than the value specified for the error level (ERRLVL) parameter of the Run SQL Statements (RUNSQLSTM) command, the statement fails.
- Commitment control in the SQL statement processor
A commitment-control level is specified on the Run SQL Statements (RUNSQLSTM) command.
- Source member listing for the SQL statement processor
This example shows a source member listing for the SQL statement processor.
Parent topic:
Using SQL in different environments
Related reference
Run SQL Statement (RUNSQLSTM) command