So creating a separate function expecting VarChar that pointed to a
separate procedure that expected a Varying field did the trick.
Admittedly, I never pass Varying fields into non-Varying parameters
in RPG, but I thought that the Const keyword would convert the value
as it does with zoned to packed and so on. I guess that is not the
Thankfully SQL supports overloading, so the user can use the same
function name regardless of the file's field type.
CRPence on Sunday, April 15, 2012 12:35 AM
On 13-Apr-2012 13:44 , Kurt Anderson wrote:
Here is my Function:
Create or Replace Function ccdlib/isTollFree ( ANI Char(20) )
external name 'CCDLIB/ANIPROCS($ISTOLLFREE)'
parameter style general
The service program procedure's prototype:
// Is the Number Toll-Free?
D $isTollFree PR n
D NPA 20a Const
Am I doing something wrong?
I see nothing wrong with that.
I tried changing the function parameter to VarChar, but that
didn't resolve the issue.
<<SNIP>> Changing to define the function to have VARCHAR input
would typically be done to avoid a sql0440. However changing only
the UDF to have ANI as input to VARCHAR, leaving the storage
required by [as defined by] the called procedure as char(20),
would cause the procedure to see the two-byte varchar length as the
first two bytes of the char(20) data... which is not very helpful.
In that case, expectations would be that the procedure would have
been originally designed or redesigned to have NPA declared as
"varying", or else probably all invocations would return false
[per the two-byte variable length mis-compare problem].