DYNAMIC RESULT SETS 1
LANGUAGE SQL
ss: BEGIN

	            BEGIN
					    DECLARE crs CURSOR WITH RETURN FOR
						SELECT DISTINCT
					            Variables_1.VarID,
					            st.Description AS StatementType,
					            Programs_1.ProgramID,
					            pa1.AliasName,
					            pth.PathStr,
					            os.StartRow,
					            Programs_2.ProgramID,
					            Programs_2.AliasName,
					            Variables_1.VarName
					     FROM Programs AS Programs_1
					             INNER JOIN ProgramAliases pa1 ON pa1.ProgramID = Programs_1.ProgramID AND pa1.AliasType = 0
								 INNER JOIN StatementReference AS StatementReference_2 ON Programs_1.ProgramID = StatementReference_2.ResourceID
					             INNER JOIN OccurrencesStmt os ON StatementReference_2.OccurID = os.OccurID
							     INNER JOIN Statements st ON st.StatementType = os.StatementType
					             INNER JOIN ProgramAliases AS Programs_2 ON os.ProgID = Programs_2.ProgramID
					             INNER JOIN StatementReference AS StatementReference_1 ON os.OccurID = StatementReference_1.OccurID
					             INNER JOIN Variables AS Variables_1 ON StatementReference_1.ResourceID = Variables_1.VarID
					             INNER JOIN StatementReference AS StatementReference_3 ON os.OccurID = StatementReference_3.OccurID
					             INNER JOIN CallParameters cp ON Variables_1.VarID = cp.VariableId
					                                             AND StatementReference_3.ResourceID = cp.ID
					             INNER JOIN Paths pth ON os.PathID = pth.PathID
					     WHERE Variables_1.VarID IN (SELECT * FROM SESSION.numeric_param_temp)
					           AND StatementReference_2.ResourceType = 5
					           AND StatementReference_1.ResourceType = 4
					           AND StatementReference_3.ResourceType = 96
					           AND Programs_1.ProgramTypeID >= 0
					     ORDER BY Variables_1.VarID;
						           
						           
						 
						      
				        OPEN crs;
				
                END;
END ss	


