Page 1 of 1

problem re-executing sql query using rexx

PostPosted: Sat May 29, 2010 7:58 pm
by sricsc
Hi All,

I used REXX to query the DB2 Tables. I used the sql Query by means of Cursor and i give different inputs everytime. Whenver, i'm giving the input one by one from the REXX PROC to the Cursor, Output Host Variable Value has not changing. Is that Host Variable value will not change? Pls tell me whats the issue.

Below is my Rexx code.

GET_PROC:
...........
...........
DO I = 1 TO COUNT
INPUT = A.I
CALL GET_INFO
SAY "VALUE: " VAR1
END
.........

GET_INFO:
QUERY6= "SELECT * ",
"FROM <Table>",
"WHERE <conditions = INPUT>",
"ORDER BY <Col> DESC",
"FETCH FIRST 1 ROWS ONLY WITH UR"

ADDRESS DSNREXX 'EXECSQL PREPARE S7 FROM :QUERY6'
IF (SQLCODE \= 0) THEN CALL SQLC1
ADDRESS DSNREXX 'EXECSQL DECLARE C7 CURSOR FOR S7'
ADDRESS DSNREXX 'EXECSQL OPEN C7'

ADDRESS DSNREXX 'EXECSQL FETCH C7 INTO :'VAR1''
ADDRESS DSNREXX 'EXECSQL CLOSE C7'
RETURN


OUPUT LIKE :

25
25
25
25

Always Host Variable - VAR1 is showing the First output value. Its not showing other o/p Values, when other inputs are giving. I think Once these host variables get assigned to a Value at the first time, its not Changing till the EXIT.

Pls help me in this Issue...

Re: problem re-executing sql query using rexx

PostPosted: Sat May 29, 2010 9:43 pm
by dick scherrer
Hello,

When you have a question, start a new topic for your question rather than posting a reply to an nactive topic.

Change the display after the CALL to show both VAR1 and I . . .