I have a pretty simple Cobol program which accepts an integer as an input parameter. This parameter tells me how many rows to fetch. In my select statement, I can say 'FETCH FIRST 2 ROWS ONLY' but DB2 doesnt work when I replace the number 2 with the variable MMAXRECS. It says "Unexpected text "MMAXRECS" encountered.
Is there any other way i can fetch a variable number of rows?