Page 1 of 2

getting abend s322 executing a cursor program

PostPosted: Fri Oct 29, 2010 7:33 am
by kirangentlebreeze
identification division.
program-id last.
data division.
working-storage section.
  exec sql
      include sqlca
  end-exec.     
  exec sql
     include empta
  end-exec.
  exec sql
     declare c1 cursor for select empno,empname,activity from empta for fetch only
  end-exec.
  procedure division.
  exec sql
     open c1
  end-exec.
  perform fp-pa until sqlcode=100.
  perform rd-pa.
  exec sql
   close c1
   end-exec.
   stop run.
   fp-pa.
        fetch c1 into:empno,empname,activity.
   rd-pa.
          fetch last c1 into:empno,empname,activity.
          display empno.
          display empname.
          display activity.

hello freinds i am just a beginner in mf
i want to fetch the last record from the cursor memory,but i am getting abend s322 executing this piece of code.can any one help me to resolve my problem.

Re: getting abend s322 executing a cursor program

PostPosted: Fri Oct 29, 2010 8:12 am
by dick scherrer
Hello,

Your process has "timed out".

Why are you fetching all of the rows when you only want the last row (not record)?

Re: getting abend s322 executing a cursor program

PostPosted: Fri Oct 29, 2010 8:20 am
by kirangentlebreeze
yes i want the last record from the cursor memory

Re: getting abend s322 executing a cursor program

PostPosted: Fri Oct 29, 2010 8:33 am
by dick scherrer
Hello,

yes i want the last record from the cursor memory
Ok, then fetch the last row. . .

To repeat:
Why are you fetching all of the rows when you only want the last row?

Suggest you read about FETCH LAST in the db2 documentaton and if you find something that is not clear, post what you found and your doubt. Someone will be able to clarify.

Re: getting abend s322 executing a cursor program

PostPosted: Fri Oct 29, 2010 8:41 am
by kirangentlebreeze
i tried using "fetch last c1 into:empno,empname,activity." alone
but i got abend s322

Re: getting abend s322 executing a cursor program

PostPosted: Fri Oct 29, 2010 8:56 am
by dick scherrer
Hello,

How many rows are in the table?

Is this being run in the correct CLASS?

What do you mean by "cursor memory"? This is not a database term and terminology is critical. . .

It may help if you post the first 3 spooled outputs from the run.

Re: getting abend s322 executing a cursor program

PostPosted: Fri Oct 29, 2010 9:17 am
by kirangentlebreeze
there are 3 rows in my table

Re: getting abend s322 executing a cursor program

PostPosted: Fri Oct 29, 2010 9:40 am
by dick scherrer
Hello,

When multiple things are asked, they should all be answered. . .

As you are reluctant to post enough info here for someone to help, your best bet is probably to ask a senior or a dba on your system.

d

Re: getting abend s322 executing a cursor program

PostPosted: Fri Oct 29, 2010 1:33 pm
by GuyC
1) without "order by" fetch last is a meaningless statement because you have no idea which record will be last.
2) s322 is a jcl problem : exceeding CPU limit. ask your collegues about class and/or time parameters.

Re: getting abend s322 executing a cursor program

PostPosted: Fri Oct 29, 2010 4:55 pm
by kirangentlebreeze
any ways i could able to solve my problem
thank you guys