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

Commit work after select statement

Former Member
0 Likes
2,887

HI

In one of the cases I came across this syntax

select * from ....

commit work.

I know commit work closes the current LUW and opens new one, what is the correct benefit of writing commit work after select statement is fired on any table?
Thanks

8 REPLIES 8
Read only

arthur_alvesteixeira
Active Participant
0 Likes
1,775

Commit work is used when you update/modify the database.

Read only

0 Likes
1,775

Select statement only read data and doesn't make change in database to use commit work.

Read only

Former Member
0 Likes
1,775

Hello Sam

If there is no logic between these two statements (SELECT and COMMIT WORK) then I see no benefit from this logic.

regards

Read only

Former Member
0 Likes
1,775

Hi Sam,

Are there more statements written in the program above Select statement?

If yes, then it might be that some database update is happening in program and commit is used for them.

However, there is no effect if commit is put right after select statement.

You can move on top of select (if more code is present before select statement)or remove the commit statement.

Thanks

Amit

Read only

0 Likes
1,775

Thanks all really speaking there are no other statements between just select and commit, strange , that is why I put this query.


Read only

0 Likes
1,775

How developed this code? Can you contact the person who did this? Otherwise you can remove it I think.

Thanks

Amit

Read only

0 Likes
1,775

Hi

Sometimes COMMIT is required for example to save data to SPOOL.

I would not remove the line if you do not know why it is there. However, in your own coding, do not use that kind of sequence. COMMIT is not needed after SELECT.

regards

Read only

0 Likes
1,775


Commit work is used to reset the time limit counter, e.g after a long time run select statement.