|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
eSQL Function with a parameter that is another function |
« View previous topic :: View next topic » |
Author |
Message
|
bradhack |
Posted: Wed Sep 01, 2004 10:17 am Post subject: eSQL Function with a parameter that is another function |
|
|
Newbie
Joined: 28 May 2002 Posts: 7
|
I don't even know if this is possible (I just assumed that it was), but I'm having trouble calling a reusable eSQL function when one of my parameters is created by another function. Here's the deal:
CREATE FUNCTION fEntAtt(cCode CHAR, cValue CHAR) RETURNS CHAR
--Uses 2 arguements, Code and Value, to generate a sequence of 3 fields: Length, EntAttCode, & Value
BEGIN
DECLARE cEntAttString CHAR;
SET Environment.LastSuccessfulEntAttCode = cCode;
IF LENGTH(cValue) > 0 THEN
SET cEntAttString = RIGHT('0000' || CAST(LENGTH(cValue) + 10 AS CHAR),4) || cCode || cValue;
ELSE
SET cEntAttString = '';
END IF;
RETURN cEntAttString;
END;
This works fine when my input parameters are obtained from my XML input however, when I need to perform other formatting on the parameter field first, the function deosn't return anything.
Here's are two sample calls, the first works the second doesn't:
1. Set Environment.EntAtt = fEntAtt('010654',iAnnuity.SurrenderValue);
2. Set Environment.EntAtt = fEntAtt('020003',fParticipantRole(Environment.Annuitant.RoleCode));
The second function is as follows:
CREATE FUNCTION fParticipantRole(cRole CHAR) RETURNS CHAR
--Converts Participant Role to user-friendly text
BEGIN
DECLARE cRoleOut CHAR;
SET cRoleOut =
CASE cRole
WHEN '7' THEN 'Primary Beneficiary'
WHEN '18' THEN 'Owner'
WHEN '27' THEN 'Annuitant'
END;
RETURN cRoleOut;
END;
It works on its own, but when it's called as a parameter, the 1st function will not work.
As a workaround, I've set a variable to the results of the second function, and used that as input to the first. However, I'd like to be able to combine the two steps, if anyone knows how.
Thanks for your help. |
|
Back to top |
|
 |
contactop |
Posted: Wed Sep 01, 2004 12:49 pm Post subject: |
|
|
Acolyte
Joined: 26 Jun 2003 Posts: 50
|
Why dont u write a procedure, and get the variable as parameter of the function. |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Sep 01, 2004 2:36 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I would expect this would work, looking at it.
But, what version are you running? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
mgk |
Posted: Wed Sep 01, 2004 11:56 pm Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Hi,
This is a known defect. It should indeed work exactly as you say. However the fix is is not yet available in a CSD. If you raise a PMR you should be able to get one...
To respond to contactop, the same problem would occur if you used a procedure with a function return value as a parameter as well, due to the nature of the problem. The same fix will cover both scenarios.
Your workaround (assign function return to a local variable - two steps rather than one step) is the correct one.
Cheers, _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|