Solved

How To Return Data Structure in SQLRPGLE Stored Procedure

Posted on 2010-08-12
3
1,890 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In the hope of saving someone else's sanity... About a year ago we bought a Cisco 1921 router with two ADSL/VDSL EHWIC cards to load balance local network traffic over the two broadband lines we have, but we couldn't get the routing to work consi…
Cloud-based technologies and services will continue to grow in popularity in 2017 thanks to the simple, scalable and cost-effective solutions they deliver. Here are three areas where cloud adoption is poised to really take off.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now