(
IN p_RootID INTEGER
)
DYNAMIC RESULT SETS 1
LANGUAGE SQL
 BEGIN

            DECLARE v_RootID INTEGER;
            SET v_RootID = p_RootID;

	            BEGIN
					        DECLARE crs CURSOR WITH RETURN FOR
						    SELECT  spcic.RootID,
						            spcic.ClassNo,
						            spcic.ParentClassNo callingClassNo,
						            spcic.CompositeNo,
						            spcd.ClassName,
						            ParentClassDefinition.ClassName callingClassName,
						            CAST(NULL AS INTEGER) AS Col,
						            spcic.ParentClassNo,
						            ParentClassDefinition.ClassName ParentClassName
						     FROM SPNS_ClassInComposite spcic
						          INNER JOIN SPNS_ClassDefinition spcd ON spcd.ClassNo = spcic.ClassNo
						                                                 AND spcd.RootID = spcic.RootID
						          INNER JOIN SPNS_ClassDefinition AS CallingClassDefinition ON CallingClassDefinition.ClassNo = spcic.ParentClassNo
						                                                                           AND CallingClassDefinition.RootID = spcic.RootID
						          LEFT OUTER JOIN SPNS_ClassDefinition AS ParentClassDefinition ON ParentClassDefinition.ClassNo = spcic.ParentClassNo
						                                                                         AND ParentClassDefinition.RootID = spcic.RootID
						     WHERE spcic.RootID = v_RootID
						          AND spcic.ClassNo IN (SELECT * FROM SESSION.numeric_param_temp) ;
						
				             OPEN crs;
				
                END;
END	
