A Rexx interface to SQL databases
Version 2.5
10 October 2006
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.
Arguments:
- 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.
- bind1...bindN
- Values supplied to bind to the placemarkers.
The format of bind values is implementation dependant.
Returns:
- 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.
Example:
rc = sqlcommand(s1,"select ename, empno from emp")
|
If the SELECT statement returns 3 rows then:
- S1.ENAME.0 = 3
- S1.ENAME.1 = "SCOTT"
- S1.ENAME.2 = "SMITH"
- S1.ENAME.3 = "BROWN"
- S1.EMPNO.0 = 3
- S1.EMPNO.1 = "1234"
- S1.EMPNO.2 = "1437"
- S1.EMPNO.3 = "1555"
Copyright ©
Mark Hessling 1997-2006
<mark@rexx.org>
Return to Table of Contents
Last updated 10 October 2006