SQL fetch returns no data

Tags:
RPGLE
SQL
SQL statements
My SQL select statement returns data, but an almost identical fetch does not, although the SQL code is 0, sqlstt is '0000', and sqlwarn is all blanks. What am I doing wrong?
dcl-ds prtsplds;
outnam char(10);
libnam char(10);
nofils char( 5);
writer char(10);
status char( 3);
end-ds;

exec sql
declare gen cursor for
select p3outq, p3libn, p3nfil, p3wtr, p3stat
from prtsplq3
where p3outq like :compoutq;
exec sql
fetch gen into :prtsplds;
This doesn't work, but this does:
exec sql
select p3outq, p3libn, p3nfil, p3wtr, p3stat
into :prtsplds
from prtsplq3
where p3outq like :compoutq;
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

I don’t find Open cursor in your code. Not sure whether you have a one in your code. If you don’t have add it and try again. If this is already there, try pasting your full logic. That would be helpful to answer.

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • danieljones
    I don't understand what you are trying to say, but if you are trying to use SQL Fetch Function then execute: SQLRETURN SQLFetch(SQLHSTMT StatementHandle)
    2,840 pointsBadges:
    report
  • Yorkshireman
    when you say 'almost identical'  you are saying 'it's different'

    could you provide both sets of code? - can your different version be looking for data which is not there?

    or is it just the cursor open code missing as mentioned earlier  
    6,085 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: