× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Scott's website is always a good place to start...
https://www.scottklement.com/presentations/#RPGUDF

And the IBM Redbooks
SQL Procedures, Triggers, and Functions on IBM DB2 for i
https://www.redbooks.ibm.com/abstracts/sg248326.html?Open
External Procedures, Triggers, and User-Defined Functions on IBM DB2 for i
https://www.redbooks.ibm.com/abstracts/sg246503.html?Open

I wouldn't call option #2 a bad idea...
You'd still have the SP returning all parms, you'd just have a specific UDF
that returns the one value you need in this statement.

Option #2 would be your quickest option...and usable from embedded SQL or
Run SQL Scripts


Charles


On Tue, Apr 19, 2022 at 8:33 AM K Crawford <kscx3ksc@xxxxxxxxx> wrote:

Charles, thanks for the reply. I have spent a lot of time looking at this
and trying several things that have not worked. I have only done a few
stored procedures and don't think I have done any UDF or UDTF.
I do want to return all values so I don't think option 2 is a good idea.
Can you point me in the right direction to some good documentation? Or
give me some pointers?
Thanks Kerwin

On Mon, Apr 18, 2022 at 3:39 PM Charles Wilt <charles.wilt@xxxxxxxxx>
wrote:

Option #1
- Rewrite the Stored Proc as a User Defined Table Function. While a
regular UDF can only return a single value, a UDTF can return one or more
rows containing 1 or more columns...

Option #2
- wrap the stored proc call in a UDF that only returns the value you are
interested in.

Option #3
- build a new SQL or RPG proc that makes the stored proc call and uses
the
output in the subsequent SQL.


Charles

On Mon, Apr 18, 2022 at 2:27 PM K Crawford <kscx3ksc@xxxxxxxxx> wrote:

I have a stored procedure that I want to use in a SQL where clause.
Something like this. I know this doesn't work.

Select * from myLib.TableRRR R
where R.PlnYr = (CPLnyer of call myLib.SPGETCPLNY ('AS',5,0,0,0,0,' '))

I want R.PlnYr to equal the output parameter #4 of the procedure call.
-------
The stored procedure is fairly straightforward.
CREATE or REPLACE PROCEDURE myLib.SPGETCPLNY
(
INOUT client char(2)
,INOUT rnum numeric(7,0)
,INOUT LPlnYer numeric(4,0)
,INOUT CPlnYer numeric(4,0)
,INOUT NPlnYer numeric(4,0)
,INOUT SrchDate numeric(8,0)
,INOUT found char(1)
)
EXTERNAL NAME MyLib.RPLANSQL
LANGUAGE RPGLE
PARAMETER STYLE GENERAL
-------
When I call this via ACS-RSS this is my results in the message tab:
call myLib.spgetcplny ('AS', 5, 0,0,0,0,' ')
Return Code = 0
Output Parameter #1 (CLIENT) = AS
Output Parameter #2 (RNUM) = 5
Output Parameter #3 (LPLNYER) = 2021
Output Parameter #4 (CPLNYER) = 2022
Output Parameter #5 (NPLNYER) = 2023
Output Parameter #6 (SRCHDATE) = 20220418
Output Parameter #7 (FOUND) = Y
-------
--
KCrawford
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription
related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com



--
KCrawford
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2023 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.