Command reference / db

RUNSQLSTM

Run SQL Statements

Processes a source file of SQL statements. Statements run in the default activation group. If RUNSQLSTM is included in a compiled CL program or ILE CL procedure, the activation group of that program or procedure is ignored.

Allowed environments: *ALL. Positional parameters: 4.

Parameters

SRCFILE Source file

Source file containing the SQL statements to run. It can be a database file or an inline data file. The second qualifier is the library.

Type
*QUAL
Required
No
Case
Uppercase
*LIBL
All libraries in the thread's library list are searched until the first match.
*CURLIB
The job's current library is searched; QGPL is used if no current library is set.
Qualified parts (object, then library; write LIBRARY/OBJECT)

Source file Source file

Type
*NAME
Required
No
Length
10
Case
Uppercase

Library Library

Type
*NAME
Required
No
Default
*LIBL
Length
10
Case
Uppercase

Suggested / special values: *LIBL, *CURLIB

SRCMBR Source member

Source file member that contains the SQL statements to run.

Type
*NAME
Required
No
Length
10
Case
Uppercase

SRCSTMF Source stream file

Path name of the file that contains the SQL statements. The path may be absolute or relative.

Type
*CHAR
Required
No
Length
50
Case
Uppercase

COMMIT Commitment control

Whether SQL statements run under commitment control.

Type
*CHAR
Required
No
Default
*CHG
Length
5
Case
Uppercase

Allowed values: *CHG, *UR, *CS, *ALL, *RS, *NONE, *NC, *RR

*CHG
Referenced objects and changed rows are locked until end of unit of work; uncommitted changes in other jobs can be seen.
*CS
Locks as for *CHG, and selected-but-not-updated rows are locked until the next row is selected; uncommitted changes in other jobs cannot be seen.
*ALL
Referenced objects and selected, updated, deleted and inserted rows are locked until end of unit of work; uncommitted changes in other jobs cannot be seen.
*NONE
Commitment control is not used; uncommitted changes in other jobs can be seen. Required if the SQL DROP SCHEMA statement is included.
*RR
As *ALL, and tables used by SELECT, UPDATE, DELETE and INSERT are locked exclusively until end of unit of work; uncommitted changes in other jobs cannot be seen.

NAMING Naming

Naming convention used for objects in SQL statements.

Type
*CHAR
Required
No
Default
*SYS
Length
4
Case
Uppercase

Allowed values: *SYS, *SQL

*SYS
The system naming convention (library/file) is used.
*SQL
The SQL naming convention (schema.table) is used.

ERRLVL Severity level

Severity level, 0 through 40 (default 10). If errors above this level occur, no more statements run and they are rolled back under commitment control; syntax checking continues for remaining statements.

Type
*UINT2
Required
No
Default
10
Range
0 to 40
Case
Uppercase

DATFMT Date format

Type
*CHAR
Required
No
Default
*JOB
Length
4
Case
Uppercase

Allowed values: *JOB, *USA, *ISO, *EUR, *JIS, *MDY, *DMY, *YMD, *JUL

DATSEP Date separator character

Type
*CHAR
Required
No
Default
*JOB
Length
6
Case
Uppercase

Allowed values: /, ., ,, -, , *JOB, *BLANK

TIMFMT Time format

Type
*CHAR
Required
No
Default
*HMS
Length
4
Case
Uppercase

Allowed values: *HMS, *USA, *ISO, *EUR, *JIS

TIMSEP Time separator character

Type
*CHAR
Required
No
Default
*JOB
Length
6
Case
Uppercase

Allowed values: :, ., ,, , *JOB, *BLANK

MARGINS Source margins

Type
*ELEM
Required
No
Case
Uppercase
Elements in order

Right margin Right margin

Type
*UINT2
Required
No
Default
80
Range
1 to 32754
Case
Uppercase

DFTRDBCOL Default collection

Type
*NAME
Required
No
Default
*NONE
Length
10
Case
Uppercase

Suggested / special values: *NONE

SAAFLAG IBM SQL flagging

Type
*CHAR
Required
No
Default
*NOFLAG
Length
7
Case
Uppercase

Allowed values: *NOFLAG, *FLAG

FLAGSTD ANS flagging

Type
*CHAR
Required
No
Default
*NONE
Length
5
Case
Uppercase

Allowed values: *NONE, *ANS

DECMPT Decimal point

Type
*CHAR
Required
No
Default
*JOB
Length
7
Case
Uppercase

Allowed values: *JOB, *SYSVAL, *PERIOD, *COMMA

SRTSEQ Sort sequence

Type
*QUAL
Required
No
Case
Uppercase
Qualified parts (object, then library; write LIBRARY/OBJECT)

Sort sequence Sort sequence

Type
*NAME
Required
No
Length
10
Case
Uppercase

Library Library

Type
*NAME
Required
No
Default
*LIBL
Length
10
Case
Uppercase

Suggested / special values: *LIBL, *CURLIB

LANGID Language id

Type
*CHAR
Required
No
Default
*JOB
Length
50
Case
Uppercase

Suggested / special values: *JOB

OPTION Source listing options

Type
*CHAR
Required
No
Default
*LIST
Length
8
Case
Uppercase

Allowed values: *LIST, *NOSRC, *ERRLIST, *NOLIST

PRTFILE Print file

Printer device file that receives the output. It must have a record length of at least 132 bytes.

Type
*QUAL
Required
No
Case
Uppercase
*LIBL
Qualifier 2: all libraries in the library list are searched.
*CURLIB
Qualifier 2: the current library is searched; QGPL if none is set.
Qualified parts (object, then library; write LIBRARY/OBJECT)

Print file Print file

Type
*NAME
Required
No
Default
QSYSPRT
Length
10
Case
Uppercase

Library Library

Type
*NAME
Required
No
Default
*LIBL
Length
10
Case
Uppercase

Suggested / special values: *LIBL, *CURLIB

PROCESS Statement processing

Whether SQL statements are run or only syntax-checked.

Type
*CHAR
Required
No
Default
*RUN
Length
4
Case
Uppercase

Allowed values: *RUN, *SYN

*RUN
Statements are syntax-checked and run.
*SYN
Statements are syntax-checked only.

SECLVLTXT Second level text

Type
*CHAR
Required
No
Default
*NO
Length
4
Case
Uppercase

Allowed values: *NO, *YES

ALWCPYDTA Allow copy of data

Type
*CHAR
Required
No
Default
*OPTIMIZE
Length
9
Case
Uppercase

Allowed values: *OPTIMIZE, *YES, *NO

ALWBLK Allow blocking

Type
*CHAR
Required
No
Default
*ALLREAD
Length
8
Case
Uppercase

Allowed values: *ALLREAD, *NONE, *READ

SQLCURRULE SQL rules

Type
*CHAR
Required
No
Default
*DB2
Length
4
Case
Uppercase

Allowed values: *DB2, *STD

DECRESULT Decimal result options

Type
*ELEM
Required
No
Case
Uppercase
Elements in order

Maximum precision Maximum precision

Type
*CHAR
Required
No
Default
31
Length
2
Case
Uppercase

Allowed values: 31

Maximum scale Maximum scale

Type
*UINT2
Required
No
Default
31
Range
0 to 63
Case
Uppercase

Minimum divide scale Minimum divide scale

Type
*UINT2
Required
No
Default
0
Range
0 to 9
Case
Uppercase

CONACC Concurrent access resolution

Type
*CHAR
Required
No
Default
*DFT
Length
7
Case
Uppercase

Allowed values: *DFT, *CURCMT, *WAIT

SYSTIME System time sensitive

Type
*CHAR
Required
No
Default
*YES
Length
4
Case
Uppercase

Allowed values: *YES, *NO

OUTPUT Listing output

Type
*CHAR
Required
No
Default
*NONE
Length
7
Case
Uppercase

Allowed values: *NONE, *ERROR, *NOLIST, *MSG, *PRINT

TGTRLS Target release

Type
*SNAME
Required
No
Default
*CURRENT
Length
10
Case
Uppercase

Suggested / special values: *CURRENT

DBGVIEW Debugging view

Type
*CHAR
Required
No
Default
*NONE
Length
7
Case
Uppercase

Allowed values: *NONE, *SOURCE, *STMT, *LIST

CLOSQLCSR Close SQL cursor

Type
*CHAR
Required
No
Default
*ENDMOD
Length
10
Case
Uppercase

Allowed values: *ENDMOD, *ENDACTGRP

DLYPRP Delay PREPARE

Type
*CHAR
Required
No
Default
*NO
Length
4
Case
Uppercase

Allowed values: *NO, *YES

USRPRF User profile

Type
*CHAR
Required
No
Default
*NAMING
Length
7
Case
Uppercase

Allowed values: *NAMING, *USER, *OWNER

DYNUSRPRF Dynamic user profile

Type
*CHAR
Required
No
Default
*USER
Length
6
Case
Uppercase

Allowed values: *USER, *OWNER

Examples

RUNSQLSTM SRCFILE(MYLIB/MYFILE) SRCMBR(MYMBR)

Processes the SQL statements in member MYMBR of file MYFILE in library MYLIB.

IBM command documentation

Generated from os/cl/catalog/RUNSQLSTM.json and os/cl/help/RUNSQLSTM.json.