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



This is the classic issue with functions & stored procedures - you defined the parameters as character but are passing literals. Literals are cast to varying char type by SQL, so the prototype does not match.

You can do something like char('L') or cast('L' as char(1)) - check the syntax there, I don't use cast very much - usually use the char function itself.

I also don't know if there is any benefit to the CONST - or even if those will work - i seem to remember something to the contrary.

You could define all the parameters as varying, too.

HTH
Vern

Alex Wade wrote:
I have been experimenting with user defined functions in SQL. I have an RPG Service Program with the following subprocedure.

P pr_GetPlhNamW B EXPORT D pr_GetPlhNamW PI 100a D p_RefTyp 1a const D p_RefNo 9a const D p_AmdNo 3s 0 const D p_Mode 1a const D lw_Return s 100a /free return lw_Return; /end-free P pr_GetPlhNamW E
I have run the create function command with the following:

CREATE FUNCTION DEVAW/A ( CHAR(1), CHAR(9), DECIMAL(3,0), CHAR(1) ) RETURNS CHAR(100) LANGUAGE RPGLE SPECIFIC DEVAW/A NOT DETERMINISTIC NO SQL RETURNS NULL ON NULL INPUT DISALLOW PARALLEL NOT FENCED EXTERNAL NAME 'DEVAW/CDV0110(PR_GETPLHNAMW)' PARAMETER STYLE GENERAL WITH NULLS

According to the messages that have been returned, the statement ran succesfully, and according to the iSeries Navigator the function exists with all of the correct information. However, when running the following SQL Query:

select A('L', '222001064', 123, ' ')from paddr where lapolno = '222001064'

I get the following error.

Message . . . . : A in *LIBL type *N not found. Cause . . . . . : A in *LIBL type *N was not found. If the member name is *ALL, the table is not partitioned. If this is an ALTER TABLE statement and the type is *N, a constraint or partition was not found. If this is not an ALTER TABLE statement and the type is *N, a function, procedure, trigger or sequence object was not found. If a function was not found, A is the service program that contains the function. The function will not be found unless the external name and usage
name match exactly. Examine the job log for a message that gives more details on which function name is being searched for and the name that did not match.
I have checked that my library list has been setup correctly, and have tried variations on the parameters in both the SQL Create Function and in the sub-procedure itself. (such as adding/removing the const and using CHAR instead of Decimal)

Thanks for the help,

Alex

_________________________________________________________________


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.