dbTalk Databases Forums  

when does a commit occurs within an SQL file ?

comp.databases.ibm-db2 comp.databases.ibm-db2


Discuss when does a commit occurs within an SQL file ? in the comp.databases.ibm-db2 forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Toralf Förster
 
Posts: n/a

Default when does a commit occurs within an SQL file ? - 07-19-2010 , 03:51 AM






I'm wondering, whether the "nobody ...." comment in the following sql file
(which is called via "$>db2 -t -f sql") :

$>cat sql
-- BEGIN
delete from NEW
;
-- nobody should to read from NEW at this point
insert into NEW (select * from OLD)
;
--END

could be removed or if it is possible that somebody could read from table
NEW between the delete and insert statement.

Reply With Quote
  #2  
Old   
Mark A
 
Posts: n/a

Default Re: when does a commit occurs within an SQL file ? - 07-19-2010 , 09:27 AM






"Toralf Förster" <toralf.foerster (AT) gmx (DOT) de> wrote

Quote:
I'm wondering, whether the "nobody ...." comment in the following sql file
(which is called via "$>db2 -t -f sql") :

$>cat sql
-- BEGIN
delete from NEW
;
-- nobody should to read from NEW at this point
insert into NEW (select * from OLD)
;
--END

could be removed or if it is possible that somebody could read from table
NEW between the delete and insert statement.
Auto-commit is on by default, so commit happens after every statement.

Reply With Quote
  #3  
Old   
Serge Rielau
 
Posts: n/a

Default Re: when does a commit occurs within an SQL file ? - 07-19-2010 , 06:19 PM



On 7/19/2010 7:57 PM, Mark A wrote:
Quote:
"Toralf Förster"<toralf.foerster (AT) gmx (DOT) de> wrote in message
news:i213mg$jf4$1 (AT) news (DOT) eternal-september.org...
I'm wondering, whether the "nobody ...." comment in the following sql file
(which is called via "$>db2 -t -f sql") :

$>cat sql
-- BEGIN
delete from NEW
;
-- nobody should to read from NEW at this point
insert into NEW (select * from OLD)
;
--END

could be removed or if it is possible that somebody could read from table
NEW between the delete and insert statement.

Auto-commit is on by default, so commit happens after every statement.


Aside from that in DB2 9.7 CURRENTLY COMMITTED for CS ISOLATION is on by
default for all new databases. So there can be concurrent queries.
These concurrent queries will see the "deleted" rows until the delete is
committed.
They will not see any INSERTed rows until that is committed.

Cheers
Serge

--
Serge Rielau
SQL Architect DB2 for LUW
IBM Toronto Lab

Reply With Quote
  #4  
Old   
Toralf Förster
 
Posts: n/a

Default Re: when does a commit occurs within an SQL file ? - 07-20-2010 , 03:44 AM



Serge Rielau wrote:

Quote:
Aside from that in DB2 9.7 CURRENTLY COMMITTED for CS ISOLATION is on by
default for all new databases. So there can be concurrent queries.
These concurrent queries will see the "deleted" rows until the delete is
committed.
They will not see any INSERTed rows until that is committed.
Thx,

so an sql file like this :
$> cat sql
delete ...
;
insert ....
;
commit
;

called with this command:
$>db2 +c -vt -f sql

guarantees that nobody will see an empty table, isn't it ?

--
MfG/Sincerely

Toralf Förster
pgp finger print: 7B1A 07F4 EC82 0F90 D4C2 8936 872A E508 7DB6 9DA3

Reply With Quote
  #5  
Old   
Joachim Müller
 
Posts: n/a

Default Re: when does a commit occurs within an SQL file ? - 07-20-2010 , 06:00 AM



On Jul 20, 1:19*am, Serge Rielau <srie... (AT) ca (DOT) ibm.com> wrote:
Quote:
On 7/19/2010 7:57 PM, Mark A wrote:



"Toralf Förster"<toralf.foers... (AT) gmx (DOT) de> *wrote in message
news:i213mg$jf4$1 (AT) news (DOT) eternal-september.org...
I'm wondering, whether the "nobody ...." comment in the following sql file
(which is called via "$>db2 -t -f sql") :

$>cat sql
-- BEGIN
* * * * * * * * delete from NEW
* * * * * * * * ;
-- nobody should to read from NEW at this point
* * * * * * * * insert into NEW (select * from OLD)
* * * * * * * * ;
--END

could be removed or if it is possible that somebody could read from table
NEW between the delete and insert statement.

Auto-commit is on by default, so commit happens after every statement.

Aside from that in DB2 9.7 CURRENTLY COMMITTED for CS ISOLATION is on by
default for all new databases. So there can be concurrent queries.
These concurrent queries will see the "deleted" rows until the delete is
committed.
They will not see any INSERTed rows until that is committed.

Cheers
Serge

--
Serge Rielau
SQL Architect DB2 for LUW
IBM Toronto Lab- Hide quoted text -

- Show quoted text -
Hello Serge,

indeed this was a feature. Our developer told me that he has to
rewrite all procedure after upgrading to 9.7 and activate
CURRENTLY COMMITTED , to do a commit after each sql. Is this true?

But, it works as expected, we are very happy. Onother application has
no more lockwaits after we upgrade to 9.7

Best regards,
Joachim

Reply With Quote
  #6  
Old   
Serge Rielau
 
Posts: n/a

Default Re: when does a commit occurs within an SQL file ? - 07-20-2010 , 10:38 PM



On 7/20/2010 4:30 PM, Joachim Müller wrote:
Quote:
indeed this was a feature. Our developer told me that he has to
rewrite all procedure after upgrading to 9.7 and activate
CURRENTLY COMMITTED , to do a commit after each sql. Is this true?
I'm not sure I follow.

Generically I can say that relying on locks to synchronize sessions on
queries does not work with CURRENTLY COMMITTED.
That is the reason why we don't force the new semantics.
We ever so gently nudge people instead. :-)


--
Serge Rielau
SQL Architect DB2 for LUW
IBM Toronto Lab

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.