IBM Support

User Defined Function not receiving provided variable

Technote (troubleshooting)


Problem(Abstract)

A variable provided in a User Defined Function call is not received within the function action.

Symptom

The User Defined Function call is of the style:


    MyFunction(MyResultSet[0].MyField);

and MyResultSet was acquired in a previous GetBy - for example:

    MyResultSet=GetByFilter(MyDataType, MyFilter, False);

and this was proven to have received a result:

    NumMyResultSet=Length(MyResultSet);
    If(NumMyResultSet > 0)
    {
    MyFunction(MyResultSet[0].MyField);
    }

Any attempt to use that value in the User Defined Function will report a NULL style error if it is not able to handle a null value or just simply fail to produce the expected results.

Resolving the problem

Assigning the variable prior to the function call will ensure that the value is passed to the User Defined Function. Using the above example we can rewrite this as:


    MyResultSet=GetByFilter(MyDataType, MyFilter, False);
    NumMyResultSet=Length(MyResultSet);
    If(NumMyResultSet > 0)
    {
    MyFieldValue=MyResultSet[0].MyField;
    MyFunction(MyFieldValue);
    }

This is similar to the behaviour and work-around recorded in the TechNote "Unsolicited SQL updates from User Defined Function" [ link below], which was recorded as IZ67227: "UNSOLICITED SQL UPDATE STATEMENT PRODUCED BY FUNCTION CALL WHEN LOOPING THROUGH GETBY* RESULT SET" [ link below].

Related information

Unsolicited SQL updates from User Defined Function
IZ67227

Document information

More support for: Tivoli Netcool/Impact
Netcool/Impact

Software version: 6.1, 6.1.1, 7.1.0

Operating system(s): AIX, HP-UX, Linux, Solaris, Windows

Reference #: 1500040

Modified date: 13 June 2011