Rexx/SQL

A Rexx interface to SQL databases

Version 2.5

10 October 2006


SQLGETDATA(statement name,column name,[start byte],[number bytes][,file name])

Extracts part (or all) of a data column from the current, fetched row. The column name specifed corresponds to a column name within the current query. The column contents are returned either into a Rexx compound variable or directly written to a file (if the optional file name argument is passed). The format of the compound variable, consists of the stem being statement name and the tail corresponding to the column name.

Arguments:

statement name
A name to identify the sql statement.

column name
The name of the column within the current query for which a portion of data is to be retrieved. Some implementations do not support this function. To determine if an implementation supports this, call SQLVARIABLE with the SUPPORTSSQLGETDATA argument. Still other implementations restrict which columns can be retrieved in parts, based on the datatype of the column.

start byte
The starting byte from which to retrive column contents. The first byte of a column is 1. This argument is optional. A value of 0 can be passed; see file name argument for further details.

number bytes
The number of bytes to retrieve. An error occurs if this value exceeds 65536. This argument is optional. A value of 0 can be passed; see file name argument for further details.

file name
This is the name of an operating system file, into which the complete contents of the column is written. The start byte and number bytes arguments must either be specified as zero, or not specified at all, to allow this option.

Returns:
success: a number >= zero which corresponds to the number of bytes retrieved.
a value of zero indicates no more data are available to be retrieved.
failure: a negative number
Example:
rc = sqlprepare(s1,"select ename, empno, empaddr  from emp")
rc = sqlopen(s1)
Do Forever
   rc = sqlfetch(s1)
   If rc < 0 Then Abort()
   If rc = 0 Then Leave
   Do i = 0
      rc = sqlgetdata(s1,'ename',(i*100)+1,100)
      If rc < 0 Then Abort()
      If rc = 0 Then Leave
      Say 'Column: ename:' s1.ename
   End
   rc = sqlgetdata(s1,'empaddr',,,'/tmp/empaddr.txt')
End


Copyright © Mark Hessling 1997-2006 <mark@rexx.org>


Return to Table of Contents
Last updated 10 October 2006