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



Here is a function I am using in one of our products -

CREATE FUNCTION FOLDERISVALID ( FOLDER1 VARCHAR(100) , FOLDER2 VARCHAR(100) , FOLDER3 VARCHAR(100) , FOLDER4 VARCHAR(100) , FOLDER5 VARCHAR(100) , PGMSCHEMA VARCHAR(10) , DBSCHEMA VARCHAR(10) ) RETURNS SMALLINT LANGUAGE RPGLE -- SPECIFIC RJSIMAGE/FOLDERISVALID SPECIFIC FOLDERISVALID DETERMINISTIC NO SQL RETURNS NULL ON NULL INPUT NO EXTERNAL ACTION EXTERNAL NAME 'RJSIMAGE/DOC453R(DOC453R)'
NOT FENCED PARAMETER STYLE SQL ;
The prototype in the program is as follows - extra fields are because I use SQL parameter style - including NULL indicator parameters -

D DOC453R PR D folder1 100A VARYING
D folder2 100A VARYING
D folder3 100A VARYING
D folder4 100A VARYING
D folder5 100A VARYING
D pPgmSchema 10A VARYING
D pDataSchema 10A VARYING
D retField 5I 0 D folder1I 5I 0 CONST D folder2I 5I 0 CONST D folder3I 5I 0 CONST D folder4I 5I 0 CONST D folder5I 5I 0 CONST D pPgmSchemaI 5I 0 CONST D pDataSchemaI 5I 0 CONST D retFieldI 5I 0 D pSQLState 5A D functionName 517A VARYING
D CONST D pSpecificName 128A VARYING
D CONST D pMessageText 70A VARYING


Alan Shore wrote:
I am also learning about creating sql functions from subprocs
of the few things I have discovered is that varying does NOT work
CONST is the way to go
This message was sent from my BlackBerry
My BlackBerry number is 631 880 8640


----- Original Message -----
From: Vern Hamberg [vhamberg@xxxxxxxxxxx]
Sent: 10/25/2008 06:59 PM EST
To: RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>
Subject: Re: SQL User Defined Function Not Found



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

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.