SQL host variable with data structure array

10 pts.
Tags:
AS/400
SQL statements
SQLRPGLE
I am trying to write Printer file format using Data structure. Below is the code:
Dcl-Ds abc extname('prtf':'data':*output) qualified template;
End-Ds;

dcl-ds test likeds(abc) dim(100);
I am fetching records using fetch first for n rows statement into test DS array and every time it is giving me error message host variable not defined or usable.
Other hand when I'm defining a DS with same field names as in prtf 'DATA' record format, the SQL statement runs fine but when I'm writing to DATA using:
write data test(i) ;
Compiler error saying DS is not allowed for this operation. Please suggest, I would like to perform write operation using DS.
Any help is appreciated.

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 1  Reply

 
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.
  • TheRealRaven
    Should work. Only problem seems to be that the TEST DS doesn't have EXTNAME() nor LIKEREC(). In your first example, the EXTNAME() keyword is on the ABC DS rather than on TEST.

    Since the definition is from an externally described file, there doesn't seem to be much point in having a TEMPLATE definition. The external description is already a "template" in itself.

    I suspect that the SQL pre-compiler doesn't understand the redirection resulting from LIKEDS() and simply can't tell that EXTNAME() might be related.

    There might be some other cause, but there's not enough program code to tell. Also, there are no error message IDs given to us, so we can't be sure what errors were reported.
    26,640 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: