Solved

How To Return Data Structure in SQLRPGLE Stored Procedure

Posted on 2010-08-12
3
1,981 Views
Last Modified: 2012-08-13
I would like to  use an SQLRPGLE stored procedure to return all the fields in a particular record, plus some other fields that I will add, to a web-based application.  What I had hoped to do was a) define an externally-described data structure, based on the file that I'm using, and then b) define a field in the data structure that will be my returned record set using the LIKEDS keyword and referencing the externally-defined data structure.

My code looks like this:

D MSIADS        E DS                  ExtName(@MSIA) Qualified                                
                                                                                               
D  OUTPUT         DS                  DIM(1) QUALIFIED                                        
D   MSIA                              LIKEDS(MSIADS)

But when I tried to compile it, I got the message "Host structure array OUTPUT not defined or
 not usable." from the SQL compiler.

Is it possible to do what I want to do, or should I try to work this out some other way?

Thanks very much for your help!
0
Comment
Question by:MikeN49
  • 2
3 Comments
 
LVL 27

Expert Comment

by:tliotta
ID: 33426070
It seems that message ID SQL5011 would be the one you describe. (It would be more certain if you supplied the message ID instead of or in addition to the text.) Did you verify that all of the conditions in the message are satisfied? There are nine listed conditions, and a few of them are possible from what you show.

We can't tell by looking at the code that you supplied here. We'd need to see at least the full expanded set of elements with their definitions.

Tom
0
 

Author Comment

by:MikeN49
ID: 33434867
Hi Tom,

Yes, it was SQL5011. I've looked over the listed conditions, and most of them don't seem to apply -- the data structure is a dimensioned array, it does only have one dimension, I'm not using a structure for indicators, etc. There's one that I don't quite  understand: "the host structure array is limited to 2 levels" -- maybe that's it? But I'm not quite sure what that means ...

In the meantime, I've actually found a way around this -- rather than using LIKEDS, I'm just defining the data structure that SQL returns as an externally-defined data structure, and that seems to work fine:

D  OUTPUT      E DS                  Occurs(1) ExtName(@MSIA)

So maybe it just doesn't like LIKEDS?

                         
0
 
LVL 27

Accepted Solution

by:
tliotta earned 500 total points
ID: 33448732
The SQL Pre-compiler is different from the RPG compiler itself. The RPG compiler runs after the pre-compiler insert the SQL-specific code into the source code.

But the LIKEDS keyword isn't SQL -- it's pure RPG.

So, when the pre-compiler runs, the full array definition doesn't exist yet. It won't exist until after the RPG compiler processes LIKEDS.

OTOH, SQL is well suited for the fundamental resolving of external database names. A simple EXTNAME() is relatively easy for the pre-compiler to handle.

I think you got the right combination.

Tom
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question