Author |
Message
|
m.schneider |
Posted: Mon Jun 11, 2007 3:47 am Post subject: Datatype List as parameter in a function |
|
|
Centurion
Joined: 10 Apr 2007 Posts: 132 Location: Germany
|
Hello,
how can I get the following code to work?
DECLARE rInData REFERENCE TO InputRoot."MRM"."FIN"."TEXT_BLOCK"."MT541";
Set count = getCardinality(rInData.C_Test_Financial_Instrument_Account.SW97A.ACCOUNT_NUMBER[]);
CREATE FUNCTION getCardinality(IN fieldReference CHARACTER)
RETURNS INTEGER
BEGIN
return CARDINALITY(fieldReference);
END;
With this code I get the this error:
BIP2493E: (.receive_MT541_SWIFT2XML.getCardinality, 4.10) : Illegal type for parameter '1' of the function 'CARDINALITY'. A list is required.
I also tried LIST as datatype, but it did not work either.
Thanks for your hel |
|
Back to top |
|
 |
marcin.kasinski |
Posted: Mon Jun 11, 2007 4:19 am Post subject: Re: Datatype List as parameter in a function |
|
|
Sentinel
Joined: 21 Dec 2004 Posts: 850 Location: Poland / Warsaw
|
Try to set REFERENCE as a input parameter data type. _________________ Marcin |
|
Back to top |
|
 |
m.schneider |
Posted: Tue Jun 12, 2007 2:08 am Post subject: |
|
|
Centurion
Joined: 10 Apr 2007 Posts: 132 Location: Germany
|
Thanks for the reply, but REFERENCE also does not work |
|
Back to top |
|
 |
marcin.kasinski |
Posted: Tue Jun 12, 2007 2:12 am Post subject: |
|
|
Sentinel
Joined: 21 Dec 2004 Posts: 850 Location: Poland / Warsaw
|
m.schneider wrote: |
Thanks for the reply, but REFERENCE also does not work |
Without testing ...
Code: |
Set count = getCardinality(rInData.C_Test_Financial_Instrument_Account.SW97A.*[]);
|
_________________ Marcin |
|
Back to top |
|
 |
elvis_gn |
Posted: Tue Jun 12, 2007 2:26 am Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi,
Code: |
Set count = getCardinality(rInData.C_Test_Financial_Instrument_Account.SW97A.ACCOUNT_NUMBER[]); |
Code: |
Set count = getCardinality(rInData.C_Test_Financial_Instrument_Account.SW97A.*[]);
|
The only difference in the above two lines would be that the first should have found the count of fields named 'ACCOUNT_NUMBER', whereas the second would fetch all fields under SW97A, irrespective of name.
I think the problem is while sending the reference to the function(you are sending a list as reference)....either use cardinality directly where you use getCardinality, OR
Code: |
Set count = getCardinality(rInData.C_Test_Financial_Instrument_Account.SW97A.ACCOUNT_NUMBER[1]);
CREATE FUNCTION getCardinality(IN fieldReference REFERENCE)
RETURNS INTEGER
BEGIN
return CARDINALITY(fieldReference);
END; |
P.S: Code not tested.
Regards. |
|
Back to top |
|
 |
m.schneider |
Posted: Wed Jun 13, 2007 6:10 am Post subject: |
|
|
Centurion
Joined: 10 Apr 2007 Posts: 132 Location: Germany
|
Thanks for your replies, I will use CARDINALITY direct, ... |
|
Back to top |
|
 |
|