//HI Every one, i am beginner in DB2 i getting problem to convert MS SQL code to DB2, i have mention below that code, please help as soon as possible.


Create Function CastInt(Array Varchar(2000))
Returns IntTable Table(IntValue Integer)
LANGUAGE SQL
CONTAINS SQL
DETERMINISTIC
NO EXTERNAL ACTION
BEGIN
If Array <> ''
DECLARE separator Char(1)
SET separator=','
DECLARE separator_position Integer
DECLARE separator array_value Varchar(2000)
SET array= array+ ','
While patindex('%,%', array)<> 0
BEGIN
SELECT separator_position= patindex('%,%', array)
SELECT array_value= LEFT(Array, separator_position -1)
INSERT IntTable Values(CAST(array_value Integer))
SELECT Array= stuff(Array, 1, separator_position, '')
END
END IF
Return
END
;