MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help Reg SQL -508
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
edkir98
Beginner


Joined: 27 Aug 2007
Posts: 102
Topics: 42
Location: Chennai

PostPosted: Tue Aug 28, 2007 6:53 am    Post subject: Help Reg SQL -508 Reply with quote

I am trying to update a particular set of rows in a table using a cursor. It is throwing up SQL -508. Can anyone help?
below is my update statement
Code:
EXEC SQL                                       
     UPDATE SJRT_SL_ADJ_RQST                   
     SET SL_RQST_STAT_CD = :SJR-SL-RQST-STAT-CD,
         SL_SUB_STAT_CD  = :SJR-SL-SUB-STAT-CD 
     WHERE CURRENT OF SJRT-SL-CUR               
END-EXEC                                       
                                               

_________________
Thanks
Back to top
View user's profile Send private message Yahoo Messenger
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Tue Aug 28, 2007 7:11 am    Post subject: Reply with quote

-508 CURSOR not positioned on a row.

The update sql is not your problem. What your program did between the FETCH and the UPDATE is your problem.

Last FETCH SQLCODE = 0?
what did your program do between the FETCH of SJRT-SL-CUR and the UPDATE? and I mean everything.
online or batch?
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Aug 28, 2007 7:15 am    Post subject: Reply with quote

edkir98,


The error is self explanatory.

1. Did you define the cursor with "for Update" clause?
2. Were all the updated columns defined in the "for update" clause?
3. Is the cursor open when you are updating ?

Check the explanation of the error -508

Code:

-508   THE CURSOR IDENTIFIED IN THE UPDATE OR DELETE STATEMENT IS NOT     
       POSITIONED ON A ROW OR ROWSET THAT CAN BE UPDATED OR DELETED       
                                                                           
Explanation:   The application program attempted to execute an UPDATE or   
DELETE WHERE CURRENT OF cursor statement at a time when the specified     
cursor was not positioned on a row of the object table. The cursor must be
positioned on the row that is to be updated or deleted.                   
                                                                           
This can occur if the cursor is no longer positioned on the row because   
another cursor in the same application program delete the row or updates   
an index column. This includes deletes and index column updates that are   
performed as a result of rolling back to a savepoint.                     
                                                                           
This can also occur with a sensitive dynamic cursor when the FOR ROW n OF 
ROWSET clause is specified and the specified row of the current rowset has
been updated or deleted.                                                   
                                                                           
System Action:  The statement cannot be executed. No data was updated or   
deleted.                                                                   
                                                                           
Programmer Response:   Correct the logic of the application program to     
ensure that the cursor is correctly positioned on the intended row of the 
object table before the UPDATE or DELETE statement is executed. Note that 
the cursor is not positioned on a row if FETCH returned an SQLCODE = 100. 


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
edkir98
Beginner


Joined: 27 Aug 2007
Posts: 102
Topics: 42
Location: Chennai

PostPosted: Tue Aug 28, 2007 7:27 am    Post subject: re Reply with quote

To dbzTHEdinosauer
I am trying to read from the cursor and process the records and write to output files. Once this is done I check for a particular date field and if the date is same as today then I update the status in a particular column in the table

This is my declare cursor
Code:
 EXEC SQL                                                 
      DECLARE SJRT-SL-CUR CURSOR WITH HOLD FOR           
       SELECT SL_ADJ_ENT_ID                               
             ,FIRM_ID                                     
             ,IBD_ID                                     
             ,OFF_ID                                     
             ,IP_ID                                       
             ,ACCT_ID                                     
             ,ENT_ID                                     
             ,SL_RQST_STAT_CD                             
             ,SL_SUB_STAT_CD                             
             ,SL_ADJ_RQST_AM                             
             ,SL_ADJ_TRANS_CT                             
             ,ACCT_EVNT_CD                               
             ,SL_ADJ_CR_ACCT_ID                           
             ,SL_ADJ_DB_ACCT_ID                           
             ,SL_ADJ_SUS_ACCT_ID                         
             ,PER_SL_ADJ_END_DT                           
             ,PRIM_BILL_FREQ_CD                           
             ,SCND_BILL_FREQ_CD                           
             ,LPRC_ORIG_SLDTL_ID                         
         FROM SJRT_SL_ADJ_RQST                           
        WHERE SL_RQST_STAT_CD    = :SJR-SL-RQST-STAT-CD   
          AND SL_SUB_STAT_CD     = :SJR-SL-SUB-STAT-CD   
          AND LPRC_ORIG_SLDTL_ID = :SJR-LPRC-ORIG-SLDTL-ID
          AND PER_SL_ADJ_END_DT >= :SJR-PER-SL-ADJ-END-DT
          AND PER_SL_ADJ_IN      = :SJR-PER-SL-ADJ-IN     
          AND SL_ADJ_ENT_ID     >= :SJR-SL-ADJ-ENT-ID     
     ORDER BY SL_ADJ_ENT_ID                               
FOR UPDATE OF SL_RQST_STAT_CD, SL_SUB_STAT_CD             
 END-EXEC.                                               


Kolusu,

I checked all the 3 scenarios u told. everythin seems ok. but still am gettin the error.

Also this was working fine till yesterday and suddenly today I am getting this error.
_________________
Thanks
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Aug 28, 2007 7:41 am    Post subject: Reply with quote

Quote:

cursor is not positioned on a row if FETCH returned an SQLCODE = 100.


Did you see if that is true?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jsharon1248
Intermediate


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Tue Aug 28, 2007 8:16 am    Post subject: Reply with quote

Are any rows updated? One other remote possibility. I can't tell from the code you displayed, but is the UPDATE in it's own paragraph? I've seen some COBOL programs get lost and 'fall through' paragraphs.
Back to top
View user's profile Send private message
vivek1983
Intermediate


Joined: 20 Apr 2006
Posts: 222
Topics: 24

PostPosted: Tue Aug 28, 2007 8:54 am    Post subject: Reply with quote

edkir98,

Try this:

1. AFter fetching from the cursor, handle the sqlcode -508. (If sqlcode = -508).

2. Display the host variables. These variables will be displayed in the sysout once you run the job.

3. Check the variables against the table.

Let us know your analysis.

Regards,
Vivek G
_________________
Vivek G
--------------------------------------
A dream is just a dream. A goal is a dream with a plan and a deadline. (Harvey Mackay)
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Tue Aug 28, 2007 9:21 am    Post subject: Reply with quote

vivek1983,

you don't receive a -508 from a FETCH.

edkir98 probably does not have an SQLCODE check after his FETCH; he probably received a +100 from his FETCH and attempted to execute the UPDATE WHERE CURRENT CURSOR which gave him the -508.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
edkir98
Beginner


Joined: 27 Aug 2007
Posts: 102
Topics: 42
Location: Chennai

PostPosted: Tue Aug 28, 2007 10:59 am    Post subject: Reply with quote

I am getting all the values loaded into the ws variables before the update is executed... Also the fetch from cursor gives sqlcode +100. I'm still helpless..
_________________
Thanks
Back to top
View user's profile Send private message Yahoo Messenger
edkir98
Beginner


Joined: 27 Aug 2007
Posts: 102
Topics: 42
Location: Chennai

PostPosted: Tue Aug 28, 2007 11:00 am    Post subject: Reply with quote

I'm sorry..The fetch from the cursor is giveing sqlcode 0
_________________
Thanks
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Aug 28, 2007 11:04 am    Post subject: Reply with quote

edkir98,

I am sure your code has a fall thru the paragraphs. comment all the code invoking the Update table paragraph and change the code to perform update paragraph like
shown below.
Code:

FETCH CURSOR
IF SQLCODE = 0
   PERFORM UPDATE-TABLE PARAGRAPH
END-IF


and see if you get the same error

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jsharon1248
Intermediate


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Tue Aug 28, 2007 11:31 am    Post subject: Reply with quote

edkri98

You haven't told us if any UPDATEs are successful. If you can reproduce this in a test environment, display the FETCH and UPDATE counts, and the host variables prior to UPDATE. This will help determine if you're falling through paragraphs.
Back to top
View user's profile Send private message
edkir98
Beginner


Joined: 27 Aug 2007
Posts: 102
Topics: 42
Location: Chennai

PostPosted: Tue Aug 28, 2007 11:34 am    Post subject: Reply with quote

hi Kolusu,
As you said... its workin fine when I do like this..what could be the problem?

Also I tried another thing.
While update, I put when sqlcode=-508 display 'error ent id ' ent-id.
It displayed only the first ent-id. All others were ok.
There were a total of 318 rows updated except this one. This one alone throws and error
_________________
Thanks
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Aug 28, 2007 11:37 am    Post subject: Reply with quote

Quote:

hi Kolusu,
As you said... its workin fine when I do like this..what could be the problem?

Also I tried another thing.
While update, I put when sqlcode=-508 display 'error ent id ' ent-id.


edkir98,

As expected there is a fall thru in the code. You can either display statements to see where the fall thru is or run the pgm thru xpeditor and see the error. If the program is not too big post the code here.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jsharon1248
Intermediate


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Tue Aug 28, 2007 12:10 pm    Post subject: Reply with quote

How do you know that the ENT_ID you displayed is the first one returned by the cursor? I was thinking that you were having a problem trying to UPDATE after a CLOSE, but if what you said about the error occurring on the very first UPDATE is accurate, I'm thinking you might be trying to UPDATE after the OPEN, but before the first FETCH. For 318 rows, I'd do like Kolusu suggested and load it up with DISPLAYs (paragraph names, FETCH and UPDATE counts, host variables), or post it so we can have a look at it.

One more question, are there any DELETEs issued against that cursor?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group