My experience with calling functions/procedures on older versions of the OS, is that the system is more type strict than later versions. On 7.3 I can mix and match different numeric formats so as long as they are easily cast to the final type.
When were on 7.1 I always had to call the functionality passing params in the data type defined on the functionality.
Cast all numeric values to the exact value, Zoned is supposed to be NUMERIC, packed is supposed to be DECIMAL, etc.
You cast a number into a packed value that is then passed to a numeric (zoned) and later you pass a integer into a zoned value.
On later systems I know this is no longer a problem but I did have troubles on older versions unless I pass the same type.
-Matt
-----Original Message-----
From: MIDRANGE-L [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Alan Shore
Sent: Tuesday, January 9, 2018 8:22 AM
To: midrange-l@xxxxxxxxxxxx
Subject: Creating an SQL function from a service program
Hi everyone
We have a procedure in a service program that I need to create an SQL function for I have created SQL functions in the past, but this one is giving me headaches Before I forget - we are on V7 r1 The procedure uses the following parameters
D FnRtEbsCst pi 149a
D ItmNum 5S 0 Value
D Suffix 4A Value
D LblCode 2A Value
D Prefix 2S 0 Value
D NbtyUom 2A Value
D WhsNbr 3S 0 Value
D EnvCode 1A Value
D Type 2A Value
D
This is what I have used to create the SQL function CREATE FUNCTION PRODPA.EBSCST ( NUMERIC (5, 0), CHAR(4), CHAR(2), NUMERIC (2, 0), CHAR(2), NUMERIC (3, 0), CHAR(1),
CHAR(2) )
RETURNS CHAR(146)
LANGUAGE RPGLE
SPECIFIC PRODPA.EBSCST
DETERMINISTIC
NO SQL
RETURNS NULL ON NULL INPUT
NOT FENCED
EXTERNAL NAME 'PRODPA/FNRTEBSCST(FNRTEBSCST)'
When I try and use this function in an SQL query select isuffx, skuno, istat, idescr, prodpa.EBSCST(decimal(substr(skuno, 2, 5),5, 0), isuffx, char(' '), 00, CHAR('EA'), 3, CHAR(' '), CHAR('FG')) from prodfa.itmmstp where isuffx = '0011' and skuno = '052800'
I get a decimal data error
I have a test program that runs the procedure using the same parameters - no problem - so I know its NOT the procedure I have used debug on the procedure and running the SQl function The debug shows that the input parameters are hieroglyphics I have also created the function using DECIMAL instead of NUMERIC with the same decimal data error
Does any one have any ideas as to what I am doing wrong?
As always - all responses gratefully accepted Alan Shore E-mail : ASHORE@xxxxxxxx Phone [O] : (631) 200-5019 Phone [C] : (631) 880-8640 'If you're going through hell, keep going.'
Winston Churchill
--
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:
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.midrange.com_mailman_listinfo_midrange-2Dl&d=DwICAg&c=2S-2xx8Cum_thMfWs-kOOHQTwolPvSZ4PFLhr1wDDGs&r=wgq2KO1Tl8HswJht2RKpmz7qvL2YDU_M-VhnRH6r43I&m=kEMX6LIoLyIZq-7m7ol8uz9vPBNBR8hFll-64UjHxWI&s=SUPcd-DCJPtc8SYSEajuIcr0YcWmPjWQHjCiYlMJ3oc&e=
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at
https://urldefense.proofpoint.com/v2/url?u=https-3A__archive.midrange.com_midrange-2Dl&d=DwICAg&c=2S-2xx8Cum_thMfWs-kOOHQTwolPvSZ4PFLhr1wDDGs&r=wgq2KO1Tl8HswJht2RKpmz7qvL2YDU_M-VhnRH6r43I&m=kEMX6LIoLyIZq-7m7ol8uz9vPBNBR8hFll-64UjHxWI&s=oLaUzAtZUrYNzMUyQsokG6apr3AZ6wImUkolhYB480g&e=.
Please contact support@xxxxxxxxxxxx for any subscription related questions.
Help support midrange.com by shopping at amazon.com with our affiliate link:
https://urldefense.proofpoint.com/v2/url?u=http-3A__amzn.to_2dEadiD&d=DwICAg&c=2S-2xx8Cum_thMfWs-kOOHQTwolPvSZ4PFLhr1wDDGs&r=wgq2KO1Tl8HswJht2RKpmz7qvL2YDU_M-VhnRH6r43I&m=kEMX6LIoLyIZq-7m7ol8uz9vPBNBR8hFll-64UjHxWI&s=S2M41A_RtWxtQ3pGc32yvzSdsDcGYsWE0D5oVh2NjXc&e=
As an Amazon Associate we earn from qualifying purchases.