A Rexx interface to SQL databases

Version 2.5

10 October 2006

SQLCOMMAND(statement name,sql statement[,bind1[,bind2[,...[,bindN]]]])

Executes an SQL statement as a single step. The statement is executed in the default work area for the default database connection. No bind values may be passed for DDL statements. Bind values may optionally be passed for DML statements.


statement name
A name to identify the sql statement and used to name the compound variable created when sql statement is a SELECT statement. The results of the SELECT statement are returned in compound variables with this name as the stem.

sql statement
Any valid DDL or DML statement. For DML statements, the statement may contain placemarkers to which values may be bound.
The format of these placemarkers is implementation dependant.

Values supplied to bind to the placemarkers.
The format of bind values is implementation dependant.

success: zero
failure: a negative number
When the sql statement is a SELECT, all column values are returned as Rexx arrays. The compound variable name is composed of the statement name followed by a period, followed by the column name specified in the SELECT statement, followed by a number corresponding to the row number. As with all Rexx arrays, the number of elements in the array is stored in the zeroth element. If no statement name is specified, a default string is used; usually SQL. See 5. Implementation Notes for information when this is not the case.

If the column selected consists of a constant, or includes a function, a valid Rexx variable may not be able to be generated. See the implementation specific Appendixes for details on how each implementation handles this.

After a successful DML statement, the variable SQLCA.ROWCOUNT is set to the number of rows affected by the statement.

Because the contents of all columns for all rows are returned from a SELECT statement, the statement may return many rows and exhaust available memory. Therefore, the use of the SQLCOMMAND function should be restricted to queries that return a small number of rows. For larger queries, use a combination of SQLPREPARE, SQLOPEN, SQLFETCH, and SQLCLOSE.

rc = sqlcommand(s1,"select ename, empno from emp")

If the SELECT statement returns 3 rows then:

Copyright © Mark Hessling 1997-2006 <>

Return to Table of Contents
Last updated 10 October 2006