Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How To Return Data Structure in SQLRPGLE Stored Procedure

Posted on 2010-08-12
3
Medium Priority
?
2,094 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 2000 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

While opting for any web-to-print solution, you need to discuss with your team and some of your end users and know their opinions about your decisions. In this article we list down some questions you need to ask yourself.
Files go missing when using DFS (Distributed File System) Replication and how to recover them and fix it.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

664 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