Did you try it? And it doesn't work?

Question (comp.lang.rexx, 28.5.2000) Using features explained in Zabrodsky's site, I built and ran a Rexx program on the AS/400 to make use of the EXECSQL with no luck!

Please find below the program and the result I got on the screen.  Any input and/or insight would be very much appreciated.  I only noticed that the system did not have problem in handling the first EXECSQL statement for the SET command.  

 

program

...
address EXECSQL
EXECSQL 'SET OPTION COMMIT = *NONE'
SQL = 'SELECT ID, NAME FROM SHUS1/INPRCPF'
EXECSQL 'PREPARE S1 FROM :SQL'
EXECSQL 'DECLARE C1 CURSOR FOR S1'
EXECSQL 'OPEN C1'
EXECSQL 'FETCH C1 INTO :HVID, :HVNAME'
do while SQLCODE = 0
  say 'ID:' Hvid'  - Name:' Hvname
  EXECSQL 'FETCH C1 INTO :HVID, :HVNAME'
end
EXECSQL 'CLOSE C1'



sequence of error messages

EXECSQL
    12 *-*  EXECSQL 'PREPARE S1 FROM :SQL';
        +++    RC(-10)
    14 *-*  EXECSQL 'OPEN C1';
        +++    RC(-10)
    15 *-*  EXECSQL 'FETCH C1 INTO :HVID, :HVNAME';
        +++    RC(-10)
    20 *-*  EXECSQL 'CLOSE C1';
        +++    RC(-10)
Press ENTER to end terminal session.


Answer     It may be a surprise but the program is all right. Of course, in the system there has to be the library SHUS1 and the table INPRCPF in the library SHUS1 and this table has to include the columns named ID and NAME, see the statement

SQL = 'SELECT ID, NAME FROM SHUS1/INPRCPF'

And vice versa, when the library or the table or the column doesn't exist we get the sequence of error messages as described above.

Thanks Simon Husin for the inspiration


tour from Rexx to AS/400

  [How write and run Rexx program]

  [Standard Input and Output]

  [External Data Queue]

  [SQL statements]


main page rexx page apple 
snails identification and authentication optical illusions mail ceska verze

last modified 1st January 2001
Copyright © 1998-2001 Vladimir Zabrodsky
Czech Republic
 

1