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



I did say I tried changing the UDF parameter varchar as well and it still didn't work.
However using the syntax you gave did work, so that's good to know, but I'd rather not have to do that (since I'd know - but our users aren't likely to think of that even if I tell them).

Thanks,
Kurt

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Peter Dow
Sent: Friday, April 13, 2012 4:47 PM
To: midrange-l@xxxxxxxxxxxx
Subject: Re: SQL UDF - hardcoded parameters

Hi Kurt,

When you pass a constant, SQL defaults it to type VARCHAR. Your function is expecting a parameter of type CHAR(20). To pass a constant as a CHAR field, try

SELECT isTollFree(char('800')) FROM ...

--
*Peter Dow* /
Dow Software Services, Inc.
909 793-9050
petercdow@xxxxxxxxx <mailto:petercdow@xxxxxxxxx> /

On 4/13/2012 1:44 PM, Kurt Anderson wrote:
I created a UDF to check to see if an alphanumeric phone number is toll-free. When I hardcode a parameter such as '800' it doesn't work (returns false, '0'). When I pass in a variable that contains '800', it does work (returns true, '1').

Here is my Function:
Create or Replace Function ccdlib/isTollFree ( ANI Char(20) )
returns Char(1)
language rpgle
no sql
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 tried changing the function parameter to VarChar, but that didn't resolve the issue.

Thanks,
Kurt Anderson
Sr. Programmer/Analyst
CustomCall Data Systems
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/midrange-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.