View previous topic :: View next topic
|
Author |
Message |
Ezhil Murugan
New User
Joined: 10 Jul 2008 Posts: 14 Location: Chennai
|
|
|
|
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? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
You could use a cursor. . . |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Sorry 'bout that - hit Submit too quickly. . .
In the cursor, define the max you intend to support and use the parm count to further restrict the number of rows processed. |
|
Back to top |
|
|
Ezhil Murugan
New User
Joined: 10 Jul 2008 Posts: 14 Location: Chennai
|
|
|
|
Hi d.sch,
My intension is to not lock the table and just lock the desired number of rows |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Why do you believe that defining a cursor locks the entire table?
If you post your cursor declaration, it may be helpful. |
|
Back to top |
|
|
Bharath Bhat
Active User
Joined: 20 Mar 2008 Posts: 283 Location: chennai
|
|
|
|
Quote: |
when I replace the number 2 with the variable MMAXRECS |
Could you please post the exact query that you wrote. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
in addition to the exact query,
what is the working-storage definition of MMAXRECS? |
|
Back to top |
|
|
|