× 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.



Charles,

Wanted to let you know that the passing the argument by reference worked.
Thanks to everyone for helping out. I just needed that bit of info to get
it working.

Thank you,
Steve Stevens


-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Charles
Wilt
Sent: Tuesday, July 01, 2014 4:29 PM
To: RPG programming on the IBM i (AS/400 and iSeries)
Subject: Re: Problem calling ILE Stored Procedure from SQL Function

You must pass by reference, with or without the CONST keyword.

So it should have worked both ways.

Are you getting a different error than you did before?

Charles


On Tue, Jul 1, 2014 at 4:11 PM, Steve Stevens <s_stevens@xxxxxxxxxx>
wrote:

Charles,

Could you elaborate a bit? I tried passing by Const and without any
keyword, both methods failed. Do you know the correct method?
Steve


-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of
Charles Wilt
Sent: Tuesday, July 01, 2014 4:03 PM
To: RPG programming on the IBM i (AS/400 and iSeries)
Subject: Re: Problem calling ILE Stored Procedure from SQL Function

You can't pass a parm in from SQL by value

PrmCustNo 9s 0 value

Charles


On Tue, Jul 1, 2014 at 3:10 PM, Steve Stevens <s_stevens@xxxxxxxxxx>
wrote:

I am having trouble calling an ILE stored procedure that is part of
a service program from an SQL Function.



Short story is that the results are inconsistent. Sometimes it will
correctly determine whether the customer is a store, sometimes not,
and sometimes it gives a decimal data error. The decimal data error
always occurs where the parameter is moved to the key field for the
chain. The ILE stored procedure works every time when called from
RPG. It act as if the parameter placed in a memory location that
the store procedure does not access correctly so that sometimes it
pick up the correct number and is ok and other times it either gets
part of a number or none of it. The following error message shows
that the external procedure was found and executed and failed inside
the RPG code. So this does not appear to be a signature mismatch.



Message . . . . : Application error. MCH1202 unmonitored by VALID
at


statement 0000008800, instruction X'0000'.


Cause . . . . . : The application ended abnormally because an
exception


occurred and was not handled. The name of the program to which
the


unhandled exception is sent is VALID VALIDE AMIASTORE. The program
was


stopped at the high-level language statement number(s) 0000008800
at the


time the message was sent. If more than one statement number is
shown, the

program is an optimized ILE program. Optimization does not allow
a single

statement number to be determined. If *N is shown as a value, it
means the

real value was not available.




The store procedure code follows. I have removed the file spec for
lmllst01 and comments:

/title AmIAStore = Am I classified as a store?


p*******************************************************************
**
****


p** AmIAStore Am I classified as a store?


p AmIAStore b export


d*


d AmIAStore pi 1a

d PrmCustNo 9s 0 value

d* Field definitions . . .


d SaAnswer s 1a

d SaCat s 3a


c*******************************************************************
**
****


c**


c* Open table(s)


c if not %open(lmllst01)


c open(e) lmllst01


c endif


c* Build the key fields

c eval mlcst# = PrmCustNo

c eval SaCat = 'STR'


c* Check to see if in the file

c mlcst# chain (e) pmllstf1


c* What is the answer?

c select


c* Error on the chain?

c when %error

c eval SaAnswer = 'N'


c* Not found?

c when not %found(lmllst01)

c eval SaAnswer = 'N'

c* Classified as Store

c when mlclas = 'STR'

c eval SaAnswer = 'Y'

c other

c eval SaAnswer = 'N'

c endsl

p AmIAStore e



Copy member for prototypes:

d/if defined(AmIAStore)

d AmIAStore pr 1a

d CustNo 9s 0 value

d/endif



SQL Create Function:

CREATE FUNCTION spslib/AMIASTOR_F

(Customer Numeric(9,0))

RETURNS char(1)

language rpgle

deterministic

no sql

no external action

external name 'PMBASO/VALID(AMIASTORE)'

parameter style general

program type sub



Invocation:

select mlcst#,

amiastor_f(cast(mlcst# as Numeric(9,0)))


from lmllst01

This should return the customer number and a flag indicating whether
it is a store (Y or N).






--
This is the RPG programming on the IBM i (AS/400 and iSeries)
(RPG400-L) mailing list To post a message email:
RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list
options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take
a moment to review the archives at
http://archive.midrange.com/rpg400-l.


--
This is the RPG programming on the IBM i (AS/400 and iSeries)
(RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at http://archive.midrange.com/rpg400-l.

--
This is the RPG programming on the IBM i (AS/400 and iSeries)
(RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at http://archive.midrange.com/rpg400-l.


--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.


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-2024 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.