Solved

How To Return Data Structure in SQLRPGLE Stored Procedure

Posted on 2010-08-12
3
2,048 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
The recent Petya-like ransomware attack served a big blow to hundreds of banks, corporations and government offices The Acronis blog takes a closer look at this damaging worm to see what’s behind it – and offers up tips on how you can safeguard your…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

624 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