‎2008 Aug 04 2:29 PM
Hi Experts,
I would appreciate your help for the following problem:
I am trying to develope something like that:
OPEN CURSOR ... WITH HOLD
loop at ...
FETCH ... PACKAGE SIZE ... into lt_names
insert table ZZ_XXXX ... from lt_names
commit work
endloop.
in the second loop, the FETCH dumps raising the runtime error "Invalid interruption of a database selection"
Runtime Error DBIF_RSQL_INVALID_CURSOR
Exception CX_SY_OPEN_SQL_DB
The cursor is opened "with hold".
Does anybody know, why does it dump?
Cheers
marmsg
‎2008 Aug 04 2:43 PM
COMMIT WORK resets the database cursor, so the next fetch does not "know" any more where the last one has left off.
Replace the COMMIT WORK with a call to function DB_COMMIT.
Thomas
‎2008 Aug 04 2:36 PM
Problem is causing by insert table ZZ_XXXX statement please make sure insert is not suppose to insert duplicate key entries which already exist in ZZ_XXXX.
Amit.
‎2008 Aug 04 2:39 PM
Hello Amit,
thanks for your answer, but the dump is when the FETCH is executed, not in the insert.
I have realized, that sometimes, it dumps even in the FIRST FETCH.
Cheers
marmsg
‎2008 Aug 04 2:43 PM
COMMIT WORK resets the database cursor, so the next fetch does not "know" any more where the last one has left off.
Replace the COMMIT WORK with a call to function DB_COMMIT.
Thomas
‎2008 Aug 04 3:47 PM
Hi Thomas,
that was the problem. Thank you very much
Cheers
marmsg
‎2008 Aug 06 3:21 PM
Hi Thomas,
I have four entires in a custom z-table. During FETCH Statements, I use, PACKET SIZE, of 2.
Rough code is as follows:
OPEN CURSOR WITH HOLD w_dbcur1 FOR
SELECT * FROM ztable.
WHILE sy-subrc = 0.
FETCH NEXT CURSOR w_dbcur1 INTO TABLE i_notes PACKAGE SIZE p_pack. "Here packet size is of 2
IF sy-subrc = 0.
Calling some X BAPI Function module.
Calling BAPI_TRANSACTION_COMMIT Function module.
ENDIF.
ENDWHILE.
CLOSE CURSOR w_dbcur1.
Here the problem is, if I give packet size as 30,000, then program is working fine. If I am giving packet size as 2, which less than 4 entries in the table, The program dumps either at first execution of FETCH NEXT CURSOR statement or at the second time of FETCH NEXT CURSOR. Can you provide exact solution for this, and not the links please. Rewards will be provided.
Thanks,
Vijayanand.
‎2008 Aug 06 3:24 PM