commit or rollback?

2004-10-18 Thread Colm G. Connolly
Hi all,

I'm working with tables stored by the InnoDB engine and would like to
be able to commit only if there are no errors generated by a group of
statements like this.

/* -*- sql -*- */
SET AUTOCOMMIT=0;
use db1;
begin work;
sql statement 1;
sql statement 2;
.
.
.
sql statement n;

At this point I'd like to say, in sql, 
if no errors then
   commit;
else 
   rollback
end

From what I read in the manual I can do one or the other (commit or
rollback) but there didn't seem to be a way of conditionally doing one
or the other of them.

Thanks in advance,

-- 
 _\\|//_ 
 ( O-O )
---o00--(_)--00o--
Colm G. Connolly| Tel  : +353-1-716-2851
Department of Computer Science  | Fax  : +353-1-269-7262
University College Dublin (UCD) | Web  : http://darwin.ucd.ie/
Belfield, Dublin 4  | MSN  : [EMAIL PROTECTED]
Éire / Republic of Ireland  | 

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: commit or rollback?

2004-10-18 Thread Stuart Felenstein
I'm relatively new to all of this but just about
finished setting up a transaction myself.

I'm doing something like this:

this is in php:( i also have functions set up for
begin, rollback and committ.  
You should also set autocommitt to 0 .

Hope this helps!
Stuart

function run_query($sql)
{
  $result = mysql_query($query);
  if(!$result)
  {
return false;
  }else{
return true;
  }
}

then:

begin();
$query = INSERT INTO firsttable.//first query
$res1 = run_query($query);
$query = INSERT INTO secondtable...//second query
$res2 = run_query($query);
$query = INSERT INTO thirdtable//third query
$res3 = run_query($query);

if($res1  $res2  $res3) // If all results are true
{
  commit();
  echo your insertions were successful;
}else{
  echo mysql_errno($link). :
.mysql_error($link).\n;
  rollback();
  exit;
}


 Hi all,
 
 I'm working with tables stored by the InnoDB engine
 and would like to
 be able to commit only if there are no errors
 generated by a group of
 statements like this.
 
 /* -*- sql -*- */
 SET AUTOCOMMIT=0;
 use db1;
 begin work;
 sql statement 1;
 sql statement 2;
 .
 .
 .
 sql statement n;
 
 At this point I'd like to say, in sql, 
 if no errors then
commit;
 else 
rollback
 end
 
 From what I read in the manual I can do one or the
 other (commit or
 rollback) but there didn't seem to be a way of
 conditionally doing one
 or the other of them.
 
 Thanks in advance,
 
 -- 
  _\\|//_ 
  ( O-O )

---o00--(_)--00o--
 Colm G. Connolly| Tel  :
 +353-1-716-2851
 Department of Computer Science  | Fax  :
 +353-1-269-7262
 University College Dublin (UCD) | Web  :
 http://darwin.ucd.ie/
 Belfield, Dublin 4  | MSN  :
 [EMAIL PROTECTED]
 Éire / Republic of Ireland  | 
 
 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:   

http://lists.mysql.com/[EMAIL PROTECTED]
 
 


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: commit or rollback?

2004-10-18 Thread Philippe Poelvoorde
Colm G. Connolly wrote:
Hi all,
I'm working with tables stored by the InnoDB engine and would like to
be able to commit only if there are no errors generated by a group of
statements like this.
/* -*- sql -*- */
SET AUTOCOMMIT=0;
use db1;
begin work;
If you specify Begin or Start Transaction, set autommit=0; is optionnal.
--
Philippe Poelvoorde
COS Trading Ltd.
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Re: commit or rollback?

2004-10-18 Thread Paul DuBois
At 11:42 +0100 10/18/04, Colm G. Connolly wrote:
Hi all,
I'm working with tables stored by the InnoDB engine and would like to
be able to commit only if there are no errors generated by a group of
statements like this.
/* -*- sql -*- */
SET AUTOCOMMIT=0;
use db1;
begin work;
sql statement 1;
sql statement 2;
.
.
.
sql statement n;
At this point I'd like to say, in sql,
if no errors then
   commit;
else
   rollback
end
From what I read in the manual I can do one or the other (commit or
rollback) but there didn't seem to be a way of conditionally doing one
or the other of them.
That's correct.  You handle the logic of checking for errors and committing
or rolling back using your programming language (or rather, in the MySQL
API for your programming language).
--
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Commit and rollback problem

2002-08-19 Thread forum mail

Hi List!

Hope you can help me with my problem...
I am trying to incorporate commit and rollback in my sql 
statements... I have tried it in my web application which runs 
on weblogic and it work fine. However, when I migrated my web 
app to Tomcat, it failed to rollback when it encountered an 
error.  Ive been using the same mysql driver for both.
Is there a special configuration I need that is dependent on 
the server Im running? Other sql statements without the commit 
and rollback functionality.. works perfectly fine in TOmcat. 

I wonder what's wrong.  I dunno where to address the problem... 
its it a mysql problem or server config.

Thanks in advance.

 




Get your own 800 number
Voicemail, fax, email, and a lot more
http://www.ureach.com/reg/tag

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Re: Commit and rollback problem and mm.mysql

2002-08-19 Thread forum mail

Hi.
Thanks for the reply...

I curious with what you mean by mysql not supporting commit and 
rollback coz I found this in the site :

http://www.mysql.com/documentation/mysql/bychapter/manual_Refere
nce.html#COMMIT

Actually, Ive already tested it in my app under weblogic(and 
worked). I was just wondering why when I ported it to tomcat, 
it didnt seem to work.  Im looking at mm.mysql driver.  I was 
wondering if the mm.mysql driver uses a different config when 
used with weblogic or tomcat.

Hope u can help.
TIA





Get your own 800 number
Voicemail, fax, email, and a lot more
http://www.ureach.com/reg/tag


 On Mon, 19 Aug 2002, suresh ([EMAIL PROTECTED]) 
wrote:

 Hi
 Actually I am not an expert with mysql. I myself is a newbie 
to mysql
 But as for I know there is no use of your commit and rollback 
since mysql 
 does not support both.
 But the usage in your servlet or jsp coding will not throw 
any run time or 
 compile time error if you include
 con.setAutoCommit(true) or rollback.
 I am not sure whether you are using innoDB where the case is 
different
 If you do not use InnoDB try to use Lock and Unlock with 
Tomcat. It will 
 work for you.
 first lock the tables where you are going to write or update 
with WRITE
 also lock the tables which you will be just referring as READ
 do your task
 then unlock. Unlock is automatic if you just close the 
connection to the dB
 Hope this helps you.
 
 Cheers
 
 
 
 
 
 
 
 
 
 
 
 At 03:15 Œß‘O 02/08/19 -0400, you wrote:
 Hi List!
 
 Hope you can help me with my problem...
 I am trying to incorporate commit and rollback in my sql
 statements... I have tried it in my web application which 
runs
 on weblogic and it work fine. However, when I migrated my web
 app to Tomcat, it failed to rollback when it encountered an
 error.  Ive been using the same mysql driver for both.
 Is there a special configuration I need that is dependent on
 the server Im running? Other sql statements without the 
commit
 and rollback functionality.. works perfectly fine in TOmcat.
 
 I wonder what's wrong.  I dunno where to address the 
problem...
 its it a mysql problem or server config.
 
 Thanks in advance.
 
 
 
 
 
 
 Get your own 800 number
 Voicemail, fax, email, and a lot more
 http://www.ureach.com/reg/tag
 
 -

 Before posting, please check:
 http://www.mysql.com/manual.php   (the manual)
 http://lists.mysql.com/   (the list archive)
 
 To request this thread, e-mail mysql-
[EMAIL PROTECTED]
 To unsubscribe, e-mail 
 mysql-unsubscribe-
[EMAIL PROTECTED]
 Trouble unsubscribing? Try: 
http://lists.mysql.com/php/unsubscribe.php
 


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




commit and rollback commands through php

2001-12-19 Thread sreedhar

How can i say commit or rollback using php. i didnot find any commands for
commit or rollback for mysql in php.

regards,
sreedhar


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Commit and Rollback.

2001-05-08 Thread Rajeev Ramanujan

Hi,

   Will MySQL support COMMIT and ROLLBACK.

Thank You
Rajeev Ramanujan




beggin, commit, and rollback

2001-04-04 Thread Kristopher Briscoe

Sorry if this is mundane for some, but I have searched the manual and I 
cannot find the answer to itTwo issues here
.

1)
Doesn't mysql support begin and rollback transactions?  If so what is the 
correct procedure to make it happen.  I logged in and ran my query..

select * from host_info;

saw what I expected.  Then I did a begin statement
begin;

then I entered a delete statment
delete from host_info where hostname='kris';

then did a select
select * from host_info where hostname='kris';

my row had disappeared.  Then I tried to implement a rollback.
rollback;

all returned a success, but when I ran my query again the data was still 
gone.  This is probably something simple that I am missing.  Any help is 
greatly appreaciated.


2) Where can I find refernce to setting up and using joins?

Thanks,
Kris-
_
Get your FREE download of MSN Explorer at http://explorer.msn.com


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: beggin, commit, and rollback

2001-04-04 Thread Jeremy Zawodny

On Wed, Apr 04, 2001 at 02:52:39PM -0700, Kristopher Briscoe wrote:
 
 Doesn't mysql support begin and rollback transactions?  If so what
 is the correct procedure to make it happen.  I logged in and ran my
 query..

Depends on the table type. Check the manual for details on the
different table types.
-- 
Jeremy D. Zawodny, [EMAIL PROTECTED]
Technical Yahoo - Yahoo Finance
Desk: (408) 328-7878Fax: (408) 530-5454
Cell: (408) 439-9951

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: beggin, commit, and rollback

2001-04-04 Thread Gary Huntress

The MySQL manual is one of the best I've seen

1)
http://www.mysql.com/documentation/mysql/bychapter/manual_Compatibility.html
#Commit-rollback

2)
http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html#JOI
N


Regards,

Gary "SuperID" Huntress
===
FreeSQL.org offering free database hosting to developers
Visit http://www.freesql.org



- Original Message -
From: "Kristopher Briscoe" [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, April 04, 2001 5:52 PM
Subject: beggin, commit, and rollback


 Sorry if this is mundane for some, but I have searched the manual and I
 cannot find the answer to itTwo issues here
 .

 1)
 Doesn't mysql support begin and rollback transactions?  If so what is the
 correct procedure to make it happen.  I logged in and ran my query..

 select * from host_info;

 saw what I expected.  Then I did a begin statement
 begin;

 then I entered a delete statment
 delete from host_info where hostname='kris';

 then did a select
 select * from host_info where hostname='kris';

 my row had disappeared.  Then I tried to implement a rollback.
 rollback;

 all returned a success, but when I ran my query again the data was still
 gone.  This is probably something simple that I am missing.  Any help is
 greatly appreaciated.


 2) Where can I find refernce to setting up and using joins?

 Thanks,
 Kris-
 _
 Get your FREE download of MSN Explorer at http://explorer.msn.com


 -
 Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)

 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail
[EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: beggin, commit, and rollback

2001-04-04 Thread Miguel Angel Solórzano

At 14:52 4/4/2001 -0700, Kristopher Briscoe wrote:
Hi,
See the sample below:

C:\mysql\binmysql test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 3.23.36

Type 'help;' or '\h' for help. Type '\c' to clear the buffer

mysql create table host_info (hostname char(50)) type=innobase;
Query OK, 0 rows affected (0.05 sec)

mysql insert into host_info values ("Kris");
Query OK, 1 row affected (0.05 sec)

mysql set autocommit=0;
Query OK, 0 rows affected (0.00 sec)

mysql select * from host_info;
+--+
| hostname |
+--+
| Kris |
+--+
1 row in set (0.00 sec)

mysql delete from host_info where hostname="Kris";
Query OK, 1 row affected (0.00 sec)

mysql select * from host_info;
Empty set (0.00 sec)

mysql rollback;
Query OK, 0 rows affected (0.03 sec)

mysql select * from host_info;
+--+
| hostname |
+--+
| Kris |
+--+
1 row in set (0.00 sec)

mysql

Regards,
Miguel

Sorry if this is mundane for some, but I have searched the manual and I 
cannot find the answer to itTwo issues here
.

1)
Doesn't mysql support begin and rollback transactions?  If so what is the 
correct procedure to make it happen.  I logged in and ran my query..

select * from host_info;

saw what I expected.  Then I did a begin statement
begin;

then I entered a delete statment
delete from host_info where hostname='kris';

then did a select
select * from host_info where hostname='kris';

my row had disappeared.  Then I tried to implement a rollback.
rollback;

all returned a success, but when I ran my query again the data was still 
gone.  This is probably something simple that I am missing.  Any help is 
greatly appreaciated.


2) Where can I find refernce to setting up and using joins?

Thanks,
Kris-
_
Get your FREE download of MSN Explorer at http://explorer.msn.com


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail 
[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


__  ___   __
   /  |/  /_ __/ __/ __ \/ /   http://www.mysql.com/
  / /|_/ / // /\ \/ /_/ / /__  Miguel Solrzano [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/  So Paulo, Brazil
___/  Development Team


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php