Solved

How To Return Data Structure in SQLRPGLE Stored Procedure

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Check Group Membership 2 104
Compile Issue with Cusor Loction Solution 3 138
ED710 -->  UADDMBX 10 216
Create AS400 Logical File 5 59
Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
In this article, I will show you HOW TO: Perform a Physical to Virtual (P2V) Conversion the easy way from a computer backup (image).
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 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

10 Experts available now in Live!

Get 1:1 Help Now