Hi Stoggers,
You don't say which DB2 environment you're using.
On i-series you need to explicitly specify a read only cursor or have journalling applied to the table you're after
Also check that your have *READ rights to Collection/Table
This code works with REXX/400 DB2/400
/* LIST EMPLOYEES */
SAY ' '
SAY ' LIST OF EMPLOYEES'
SAY ' '
ADDRESS EXECSQL
SIGNAL ON ERROR
select_stmt = 'SELECT EFEMNO, EFSURN, EFFORN FROM CSEMPSPF FOR READ ONLY'
EXECSQL 'PREPARE S1 FROM :select_stmt'
EXECSQL 'DECLARE C1 CURSOR FOR S1'
EXECSQL 'OPEN C1 '
/* Fetch all of the rows */
DO UNTIL (SQLCODE <> 0)
EXECSQL 'FETCH C1 INTO :EMNO, :SURN, :FORN'
IF SQLCODE = 100 THEN
LEAVE
/* Print out the fetched row */
SAY EMNO ' ' SURN ' ' FORN
END;
EXECSQL 'CLOSE C1'
ERROR:
say 'Error SQLCODE: ' SQLCODE 'SQLSTATE: ' SQLSTATE