Wednesday, 1 October 2014

Setting Variables to Null in PeopleCode

 String

Always use space to assign a null value to a string.

 Local String &Test_Str = " ";

 Number

 Use 0 (zero) to assign a null value to a number.

 
Local Number &Test_Num = 0;

 Date


If you try to assign a date variable a null value you will get an error saying that the left and right sides of the assignment are not compatible.

For instance, the following PeopleCode would error out: 



Local Date &Test_DT =NULL;

To perform this kind of assignment, you may use the Date function in the following way:


Local Date &Test_DT;
&Test_DT = DATE(0);

The Date function takes a number in the form YYYYMMDD and returns a corresponding Date value. If the date is invalid, Date displays an error message.

&Test_DT = Date(19970713);

 

No comments:

Post a Comment