Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

DBIF_RSQL_INVALID_CURSOR exception during select endselect with modify

michael_habermueller
Product and Topic Expert
Product and Topic Expert
0 Likes
1,887

Hello,

I do have a problem in a report that updates two tables.

The program throws a DBIF_RSQL_INVALID_CURSOR Exception in an select statement with package size.

I assume it is because I perform a SQL modify statement to the selected table within the select endselect loop. Rows are only updated but not inserted.

Unfortunately I do not know a better approach that may not need the select endselect statement or do perform an update which is allowed there.

The tables do have a lot of entries.

Therefore I do have the following approach for updating.

1. Select a package of rows from table A.

2. Select matching rows to the package in table B.

3. Do the update of B by performing a modify statement.

4. Do the update of table A in second modfiy statement.

5. goto 1 and perform the next package

Here is the code for it. Do you have a better idea ? Best regards Michael

SELECT * FROM /rb04/yl7_aiidl  INTO TABLE gt_aiidl
     PACKAGE SIZE p_bsize
*  WHERE xupdatedone ne 'X'
     .

     SELECT * FROM /ain/kbndet INTO TABLE gt_kbndet
     FOR ALL ENTRIES IN gt_aiidl
     WHERE det_intid = gt_aiidl-det_intid.

     LOOP AT gt_kbndet ASSIGNING <fs_kbndet>.
       READ TABLE  gt_aiidl ASSIGNING <fs_aiidl> WITH KEY det_intid = <fs_kbndet>-det_intid.
       IF sy-subrc = 0.
         <fs_kbndet>-/rb04/conf_log = <fs_aiidl>-conf_log_new.
         <fs_kbndet>-/rb04/det_log = <fs_aiidl>-det_log_new.
         <fs_aiidl>-xupdatedone = 'X'.
       ENDIF.
     ENDLOOP.

     DESCRIBE TABLE gt_kbndet LINES gv_anz.

     gv_anz_total = gv_anz_total + gv_anz.
     CLEAR gv_anz.
     MODIFY /ain/kbndet FROM TABLE gt_kbndet.
     MODIFY /rb04/yl7_aiidl FROM TABLE gt_aiidl.

     IF  p_test IS  INITIAL.
       COMMIT WORK.
     ENDIF.


   ENDSELECT.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,201

The issue is bcoz of the commit work inside the select/endselect statement. Please check the error analysis in ST22.

Hello,

I do have a problem in a report that updates two tables.

The program throws a DBIF_RSQL_INVALID_CURSOR Exception in an select statement with package size.

I assume it is because I perform a SQL modify statement to the selected table within the select endselect loop. Rows are only updated but not inserted.

Unfortunately I do not know a better approach that may not need the select endselect statement or do perform an update which is allowed there.

The tables do have a lot of entries.

Therefore I do have the following approach for updating.

1. Select a package of rows from table A.

2. Select matching rows to the package in table B.

3. Do the update of B by performing a modify statement.

4. Do the update of table A in second modfiy statement.

5. goto 1 and perform the next package

Here is the code for it. Do you have a better idea ? Best regards Michael

SELECT * FROM /rb04/yl7_aiidl  INTO TABLE gt_aiidl
     PACKAGE SIZE p_bsize
*  WHERE xupdatedone ne 'X'
     .

     SELECT * FROM /ain/kbndet INTO TABLE gt_kbndet
     FOR ALL ENTRIES IN gt_aiidl
     WHERE det_intid = gt_aiidl-det_intid.

     LOOP AT gt_kbndet ASSIGNING <fs_kbndet>.
       READ TABLE  gt_aiidl ASSIGNING <fs_aiidl> WITH KEY det_intid = <fs_kbndet>-det_intid.
       IF sy-subrc = 0.
         <fs_kbndet>-/rb04/conf_log = <fs_aiidl>-conf_log_new.
         <fs_kbndet>-/rb04/det_log = <fs_aiidl>-det_log_new.
         <fs_aiidl>-xupdatedone = 'X'.
       ENDIF.
     ENDLOOP.

     DESCRIBE TABLE gt_kbndet LINES gv_anz.

     gv_anz_total = gv_anz_total + gv_anz.
     CLEAR gv_anz.
     MODIFY /ain/kbndet FROM TABLE gt_kbndet.
     MODIFY /rb04/yl7_aiidl FROM TABLE gt_aiidl.

     IF  p_test IS  INITIAL.
       COMMIT WORK.
     ENDIF.


   ENDSELECT.

3 REPLIES 3
Read only

Former Member
0 Likes
1,202

The issue is bcoz of the commit work inside the select/endselect statement. Please check the error analysis in ST22.

Read only

0 Likes
1,201

Thank you very much for your helpflul answer. This solves the problem of the dump.

Do you have an idea how to program this, when I want to do some commits during processing,

Best regards

Michael

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,201

Yes,  no database commit or rollback, is allowed in a SELECT/ENDSELECT block, triggered by COMMIT-WORK, call of function module DB_COMMIT or any other implicit event.

(Read SELECT online documentation)

Regards,

Raymond