Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Transaction related

3 posts in ,  General DiscussionWindows NT General Discussion Last posting was on 2000-03-29 21:26:16.0Z
test Posted on 2000-03-28 18:31:44.0Z
Message-ID: <38E0FA90.102EE897@yack.com>
Date: Tue, 28 Mar 2000 10:31:44 -0800
From: test <test@yack.com>
X-Mailer: Mozilla 4.61 [en] (WinNT; I)
X-Accept-Language: en
MIME-Version: 1.0
Subject: Transaction related
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.jconnect40,sybase.public.sqlserver.nt,sybase.public.sqlserver.general,sybase.public.jconnect
Lines: 20
NNTP-Posting-Host: dhcp4.yack.com 216.200.134.197
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.jconnect40:199 sybase.public.sqlserver.nt:200 sybase.public.sqlserver.general:213 sybase.public.jconnect:1187
Article PK: 253867

I am firing a transaction with two statements using JDBC driver
com.sybase.jdbc2.jdbc.SybDriver :
Begin tran
Insert a record into a table.
Deletion of records from a table which is not in the database
commit tran

The entire transaction rolled back as the second statement aborts.

consider this example
Begin tran
Insert a duplicate key record into a table.
Deletion of records from a table (in the database)
commit tran

The first statement fails due to the primary key constraint. But the
second statement still goes through and deletes the records. But it is
not supposed to as it is in a transaction and the entire transaction
should have been rolled back.

Can some one throw some light on this discrepancy ?


Jay Anderson Posted on 2000-03-29 21:26:16.0Z
From: janders@sybase.com (Jay Anderson)
Subject: Re: Transaction related
Date: Wed, 29 Mar 2000 21:26:16 GMT
Message-ID: <38e27380.529919531@forums.sybase.com>
References: <38E0FA90.102EE897@yack.com>
X-Newsreader: Forte Free Agent 1.11/32.235
Newsgroups: sybase.public.jconnect40,sybase.public.sqlserver.nt,sybase.public.sqlserver.general,sybase.public.jconnect
Lines: 38
NNTP-Posting-Host: powerjay.sybase.com 157.133.10.202
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.jconnect40:197 sybase.public.sqlserver.nt:198 sybase.public.sqlserver.general:211 sybase.public.jconnect:1185
Article PK: 253864

On Tue, 28 Mar 2000 10:31:44 -0800, test <test@yack.com> wrote:

>I am firing a transaction with two statements using JDBC driver
>com.sybase.jdbc2.jdbc.SybDriver :
>Begin tran
> Insert a record into a table.
> Deletion of records from a table which is not in the database
>commit tran
>
>The entire transaction rolled back as the second statement aborts.
>
>consider this example
>Begin tran
> Insert a duplicate key record into a table.
> Deletion of records from a table (in the database)
>commit tran
>
>The first statement fails due to the primary key constraint. But the
>second statement still goes through and deletes the records. But it is
>not supposed to as it is in a transaction and the entire transaction
>should have been rolled back.

You are controlling whether you commit or rollback the work. You are controlling what is atomic by
virtue of when and whether you issue commits and rollback. Simplest case I can think of is "sqlcode
= 100 -> no rows found', this could be considered as an error in some cases and as a condition for
success in others. It is not possible for the database to know your intention and what you consider
to be an error in the case that the insert failed, the assumption is the you received indication
that the insert failed so you decided to delete some rows.

You could use try {} catch{} blocks around sql code to provide more logic.
>
>Can some one throw some light on this discrepancy ?
>


Kevin J. Grittner Posted on 2000-03-28 20:21:32.0Z
Message-ID: <38E1144C.6495F97D@chorus.net>
Date: Tue, 28 Mar 2000 14:21:32 -0600
From: "Kevin J. Grittner" <kjgrittn@chorus.net>
X-Mailer: Mozilla 4.51 [en] (WinNT; I)
X-Accept-Language: en-US,en,en-GB
MIME-Version: 1.0
Subject: Re: Transaction related
References: <38E0FA90.102EE897@yack.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.jconnect40,sybase.public.sqlserver.nt,sybase.public.sqlserver.general,sybase.public.jconnect
Lines: 27
NNTP-Posting-Host: 165.219.95.135
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.jconnect40:198 sybase.public.sqlserver.nt:199 sybase.public.sqlserver.general:212 sybase.public.jconnect:1186
Article PK: 253865

A statement that throws an exception doesn't roll back the transaction
-- that's up to the code that catches the exception. Look for problems
with your exception handling. Why is it even GETTING TO the second
statement???

test wrote:
>
> I am firing a transaction with two statements using JDBC driver
> com.sybase.jdbc2.jdbc.SybDriver :
> Begin tran
> Insert a record into a table.
> Deletion of records from a table which is not in the database
> commit tran
>
> The entire transaction rolled back as the second statement aborts.
>
> consider this example
> Begin tran
> Insert a duplicate key record into a table.
> Deletion of records from a table (in the database)
> commit tran
>
> The first statement fails due to the primary key constraint. But the
> second statement still goes through and deletes the records. But it is
> not supposed to as it is in a transaction and the entire transaction
> should have been rolled back.
>
> Can some one throw some light on this discrepancy ?