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

Fetch next cursor/ invalid database interruption

Former Member
0 Likes
2,573

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

1 ACCEPTED SOLUTION
Read only

ThomasZloch
Active Contributor
1,372

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

6 REPLIES 6
Read only

Former Member
0 Likes
1,372

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.

Read only

0 Likes
1,372

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

Read only

ThomasZloch
Active Contributor
1,373

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

Read only

0 Likes
1,372

Hi Thomas,

that was the problem. Thank you very much

Cheers

marmsg

Read only

0 Likes
1,372

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.

Read only

0 Likes
1,372

Hi Vijay, let's continue in [this thread of yours|;.