<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>MySQL Forums - Transactions</title>
        <description>Forum for MySQL Transactions</description>
        <link>http://forums.mysql.com/list.php?97</link>
        <lastBuildDate>Thu, 23 May 2013 17:50:28 +0000</lastBuildDate>
        <generator>Phorum 5.2.19</generator>
        <item>
            <guid>http://forums.mysql.com/read.php?97,587047,587047#msg-587047</guid>
            <title>How to get % status (no replies)</title>
            <link>http://forums.mysql.com/read.php?97,587047,587047#msg-587047</link>
            <description><![CDATA[ I have a table that contain a column like as-<br />
<br />
Course_Name    Status<br />
<br />
Math          Complete<br />
Math          Complete<br />
Math          Complete<br />
Science       Incomplete<br />
Science       Complete<br />
Science       Complete<br />
<br />
I need the sql query who give % complete of each course which output like as follows-<br />
<br />
Course_Name   % status_Complete<br />
Math                  100%<br />
Science               33.3%]]></description>
            <dc:creator>Ajeet Sri</dc:creator>
            <category>Transactions</category>
            <pubDate>Wed, 22 May 2013 09:25:09 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,583662,583662#msg-583662</guid>
            <title>Max no of select queries to a table in mysql? (1 reply)</title>
            <link>http://forums.mysql.com/read.php?97,583662,583662#msg-583662</link>
            <description><![CDATA[ Hi,<br />
Can anyone please let me know how many different select queries we can execute to a particular table in mysql at a time?<br />
<br />
<br />
Thanks in advance,<br />
Velmurugan.P]]></description>
            <dc:creator>Velmurugan Panneerselvam</dc:creator>
            <category>Transactions</category>
            <pubDate>Thu, 11 Apr 2013 16:30:23 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,582822,582822#msg-582822</guid>
            <title>Locking multiple rows in repeatable read mode (1 reply)</title>
            <link>http://forums.mysql.com/read.php?97,582822,582822#msg-582822</link>
            <description><![CDATA[ If I understand correctly how repeatable read works, on the first select in a trasaction the database creates a snapshot of its current state and with few exceptions like &quot;insert into ... select ...&quot; the transaction does not see any changes hapenning outside of it.<br />
<br />
In my situation I have to lock two or more arbitrary rows identified discretly by their primary key values. If I lock them independently like this:<br />
<br />
select * from t where pk=3 for update;<br />
select * from t where pk=8 for update;<br />
<br />
another transaction may squezee between these two statements and do something the first transaction would not be aware of. I cannot process the records independently with a commit between them because this has to be dealt with in &quot;all or nothing&quot; manner. Is the only solution to lock both records at the same time like this:<br />
<br />
select * from t where pk in (3,8) for update;<br />
<br />
I am not particularly fond of that idea because I do not like building the statements of arbitrary lentght like this one dynamically. Also, would it honour the order in which it locks them so I can avoid a deadlock by sorting them?<br />
<br />
Thank you for your response in advance.<br />
Marko]]></description>
            <dc:creator>Marko Vukovic</dc:creator>
            <category>Transactions</category>
            <pubDate>Tue, 02 Apr 2013 05:02:46 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,582094,582094#msg-582094</guid>
            <title>How do I know which transaction lock a table? (6 replies)</title>
            <link>http://forums.mysql.com/read.php?97,582094,582094#msg-582094</link>
            <description><![CDATA[ if I execute any alter statement(alter table online_payment add column mac varchar(200); or alter table online_payment engine=&quot;MyISAM&quot;; or alter online_payment AUTO_INCREMENT=15492;) to online_payment, this table will be stuck, but I can execute any insert statement, and there isn't any other process operate this table(i make sure this by show processlist statment), only one &quot;Waiting for table metadata lock alter table&quot;. The engine of this table is myiasm, so i believe that there is a transactions lock this table. In this case, is there any way to solve this problem without restart mysql? I have waited ten minutes before i stop the alter statement, so that transaction should be running at least ten minutes, and i execute the alter several times, so the transaction should be often executed. And now as long as I execute this alter statement, then I would not be able to execute select statement, the results of select will immediately come out if I interrupt the alter statement.]]></description>
            <dc:creator>john walker</dc:creator>
            <category>Transactions</category>
            <pubDate>Sun, 24 Mar 2013 00:52:37 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,581125,581125#msg-581125</guid>
            <title>solved: How can a user read his own privileges? (2 replies)</title>
            <link>http://forums.mysql.com/read.php?97,581125,581125#msg-581125</link>
            <description><![CDATA[ Hello everyone,<br />
<br />
I am writing a database application in OpenOffice and each person logging in has his own mySQL user.<br />
<br />
In order to customize forms I would like to read out, if user x has update privileges for table y or not, for example. Of course, user x has no access to the information_schema database. Can he get to know his rights without trying and throwing errors?<br />
<br />
Thank you!]]></description>
            <dc:creator>Wolfgang Jacques</dc:creator>
            <category>Transactions</category>
            <pubDate>Thu, 14 Mar 2013 01:06:22 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,580883,580883#msg-580883</guid>
            <title>Update column takes time!! (1 reply)</title>
            <link>http://forums.mysql.com/read.php?97,580883,580883#msg-580883</link>
            <description><![CDATA[ Dear all!!<br />
I have 450 number of tables. Every table has a column 'update_count'.<br />
At some time I have to update value of this column to zero. But due large volume of data(row) in every table and also indexing on many other column it takes too...too much time.<br />
Can be a different trick to update a column value, of every table??]]></description>
            <dc:creator>MOnalee Bhandge</dc:creator>
            <category>Transactions</category>
            <pubDate>Sun, 10 Mar 2013 18:08:21 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,579865,579865#msg-579865</guid>
            <title>changing isolation level (1 reply)</title>
            <link>http://forums.mysql.com/read.php?97,579865,579865#msg-579865</link>
            <description><![CDATA[ Hello<br />
<br />
Testing the last GA version, and  SET TRANSACTION ISOLATION doesn't seem to change internal variable. <br />
<br />
Server version: 5.6.10 MySQL Community Server (GPL)<br />
<br />
(soutou@localhost) [bdsoutou] mysql&gt; SELECT @@tx_isolation;<br />
+-----------------+<br />
| @@tx_isolation  |<br />
+-----------------+<br />
| REPEATABLE-READ |<br />
+-----------------+<br />
1 row in set (0.00 sec)<br />
<br />
(soutou@localhost) [bdsoutou] mysql&gt; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;<br />
Query OK, 0 rows affected (0.00 sec)<br />
<br />
(soutou@localhost) [bdsoutou] mysql&gt; SELECT @@tx_isolation;<br />
+-----------------+<br />
| @@tx_isolation  |<br />
+-----------------+<br />
| REPEATABLE-READ |<br />
+-----------------+<br />
<br />
It works with SET SESSION tx_isolation='READ-UNCOMMITTED' but why ?]]></description>
            <dc:creator>Christian Soutou</dc:creator>
            <category>Transactions</category>
            <pubDate>Sun, 24 Feb 2013 21:23:23 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,579025,579025#msg-579025</guid>
            <title>SELECT ... FOR UPDATE does not honor next-key locks (no replies)</title>
            <link>http://forums.mysql.com/read.php?97,579025,579025#msg-579025</link>
            <description><![CDATA[ I was wondering if this is expected behavior or a bug I am seeing in the InnoDB table engine.<br />
<br />
If a SELECT . . . FOR UPDATE statement is called, other selects will block on any rows locked by this statement.  However, if the SELECT . . . FOR UPDATE statement does not find any rows, but applies a lock on an index, a similar SELECT statement will not block on that lock.<br />
<br />
A simple use case:<br />
<br />
Create a table named `test` with a column named col1, with an index on col1:<br />
<br />
CREATE TABLE `test` (<br />
  `col1` int(11) NOT NULL,<br />
  KEY `col1` (`col1`)<br />
) ENGINE=InnoDB;<br />
<br />
On one session, start a transaction, and select for update where col1=1:<br />
<br />
BEGIN;<br />
SELECT * FROM `test` WHERE col1=1 FOR UPDATE;<br />
<br />
This will select an empty set, but should set an appropriate lock on an index.<br />
<br />
Before committing the first transaction, on a second session, start another transaction, and attempt to insert a row with col1 equalling 1.<br />
<br />
BEGIN;<br />
INSERT INTO `test` values (1);<br />
<br />
This will block as expected.  However, if while the first transaction is still open and a new transaction is repeated with the same select statement as the first:<br />
<br />
BEGIN;<br />
SELECT * FROM `test` WHERE col1=1 FOR UPDATE;<br />
<br />
It does not block and returns immediately.  It blocks only if there were rows found (with row blocking).<br />
<br />
According to the documentation on innodb-next-key-locking (http://dev.mysql.com/doc/refman/5.0/en/innodb-next-key-locking.html), this should block:<br />
<br />
&quot;You can use next-key locking to implement a uniqueness check in your application: If you read your data in share mode and do not see a duplicate for a row you are going to insert, then you can safely insert your row and know that the next-key lock set on the successor of your row during the read prevents anyone meanwhile inserting a duplicate for your row. Thus, the next-key locking enables you to “lock” the nonexistence of something in your table.&quot;<br />
<br />
Is this an error in the documentation or a bug in MySQL?  The use case in the documentation is exactly the issue I am seeing-- I select a row and insert only if it doesn't exist.  However, when this operation occurs simultaneously, both operations see no row existing, and both then insert the same row, resulting in duplicate rows.<br />
<br />
I've tried the test stated above with both &quot;LOCK IN SHARE MODE&quot; as well as &quot;FOR UPDATE&quot;, and found the same issue occurs for both.]]></description>
            <dc:creator>Brian Bernstein</dc:creator>
            <category>Transactions</category>
            <pubDate>Tue, 12 Feb 2013 18:10:33 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,578976,578976#msg-578976</guid>
            <title>Importing a database dump created with --single-transaction does not result in single-transaction import of the file (4 replies)</title>
            <link>http://forums.mysql.com/read.php?97,578976,578976#msg-578976</link>
            <description><![CDATA[ Hello,<br />
<br />
I'm not sure that this qualifies as a &quot;Newbie&quot; question, but this forum seems to lack a more appropriate category.<br />
<br />
I have a handful of tables, totaling 150 MB in size, that I need to dump and then import into another server on a regular basis.<br />
<br />
The destination server is a production server on which zero downtime while replacing the tables is a must.<br />
<br />
I thought that enclosing the dump in a single transaction would serve the intended purpose. However, in practice, each table appears to be emptied before the data is imported, which causes the table to contain incomplete data for as long as is required to import the data in its entirety. This occurs one table at a time. To summarize:<br />
<br />
1.) Table is dropped and recreated.<br />
2.) Data is inserted; this process requires several minutes, during which time the the number of rows in the table increases &quot;in real-time&quot;, as the data is imported.<br />
3.) The process is repeated for the next table.<br />
<br />
In essence, it seems that START TRANSACTION is being ignored.<br />
<br />
I see nothing on the relevant manual page ( <a href="http://dev.mysql.com/doc/refman/5.1/en/commit.html"  rel="nofollow">http://dev.mysql.com/doc/refman/5.1/en/commit.html</a> ) that explains this behavior when using AUTOCOMMIT=0, START TRANSACTION, and COMMIT.<br />
<br />
The structure of the dump file is as follows:<br />
<br />
-----------------------------------------------<br />
SET SQL_MODE=&quot;NO_AUTO_VALUE_ON_ZERO&quot;;<br />
SET AUTOCOMMIT=0;<br />
START TRANSACTION;<br />
SET time_zone = &quot;+00:00&quot;;<br />
<br />
DROP TABLE IF EXISTS `table`;<br />
CREATE TABLE IF NOT EXISTS `table` ([...]);<br />
INSERT INTO `table` ([...]) VALUES ([...]);<br />
<br />
COMMIT;<br />
-----------------------------------------------<br />
<br />
The dumps are created with the following command:<br />
<br />
mysqldump --add-drop-table --default-character-set=utf8 --extended-insert --host=localhost --quick --quote-names --routines --set-charset --single-transaction --triggers --tz-utc --verbose --user=root --password=password mydbname<br />
<br />
All tables are InnoDB.<br />
<br />
MySQL version is 5.1.66.<br />
<br />
Thanks for any help!]]></description>
            <dc:creator>Ben Johnson</dc:creator>
            <category>Transactions</category>
            <pubDate>Thu, 14 Feb 2013 04:23:16 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,577250,577250#msg-577250</guid>
            <title>deadlock for mixed row and table lock? (4 replies)</title>
            <link>http://forums.mysql.com/read.php?97,577250,577250#msg-577250</link>
            <description><![CDATA[ Hi,<br />
<br />
Using InnoDB.  2 Tables, call them A and B, which are used in conjunction to define my &quot;tree&quot; relationships.  I always make sure in all transactions to update A and THEN update B.<br />
<br />
However, in many:<br />
<br />
I do row updates on rows of A (sorted by id) (row lock) and then inserts on B (assume table lock) while in others I do inserts on A (assume table lock) and then updates on rows of B (sorted by id).<br />
<br />
Am I safe against deadlock?<br />
<br />
Andy]]></description>
            <dc:creator>Andrew Nuss</dc:creator>
            <category>Transactions</category>
            <pubDate>Sun, 24 Feb 2013 21:39:23 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,576653,576653#msg-576653</guid>
            <title>Transaction Not Fully Commited (1 reply)</title>
            <link>http://forums.mysql.com/read.php?97,576653,576653#msg-576653</link>
            <description><![CDATA[ I am having a problem with a transaction. <br />
<br />
Environment:<br />
- C# ASP.NET<br />
- MySQL 5.1.51<br />
<br />
Tables:<br />
- tbl_book<br />
- tbl_pages<br />
<br />
My code flow basically works like this:<br />
1) Start Transaction<br />
2) Call a stored procedure (book_new) to insert a new book record into tbl_book and return the inserted book id using LAST_INSERT_ID<br />
3) In my code, I can read the returned Book ID <br />
4) In my code, in a loop, generate a page and call another stored procedure (page_new) to insert the new page record into tbl_pages with the Book ID as foreign key<br />
5) After generating all the pages (around 15 ~ 100 records, usually takes about 45 ~ 90 seconds), the transaction is committed.<br />
<br />
The problem:<br />
tbl_pages has all the records with the Book ID, however, tbl_book has no record with Book ID. <br />
<br />
In another word, the transaction only commits half of the statements. <br />
<br />
Any idea why?]]></description>
            <dc:creator>Teddy Cooper</dc:creator>
            <category>Transactions</category>
            <pubDate>Mon, 31 Dec 2012 20:17:34 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,576567,576567#msg-576567</guid>
            <title>MySQL Stored Procedure coding question (1 reply)</title>
            <link>http://forums.mysql.com/read.php?97,576567,576567#msg-576567</link>
            <description><![CDATA[ I am using MySql with Workbench<br />
<br />
I have not been able to use the &lt;b&gt;MAX(C.LastContact)&lt;/b&gt; agregate in the WHERE clause which is needed to get the correct results. I am trying to filter based off a incoming parameter 'MonitorStatus'. I have tried using HAVING and CASE WHEN. Neither has worked. If I could bring in one more column into the select statement that could be used for filtering , it would work but if I do that it messes up the COUNT returning a SINGLE ROW / SINGLE NUMBER,  needed for a Digital gadget. I have not been able to get it to work. I am using Dynamic SQL. Below is a portion of the code:<br />
DOES ANYONE KNOW HOW THIS CAN BE DONE?<br />
<br />
<br />
DELIMITER $$<br />
<br />
DROP PROCEDURE IF EXISTS usp_cbi_TEST_LocationMonitorCounts$$<br />
CREATE PROCEDURE usp_cbi_TEST_LocationMonitorCounts(<br />
<br />
	QueryType varchar(30),<br />
	MonitorStatus varchar(50),<br />
	StatusTimeToFail int #In Minutes<br />
)<br />
BEGIN<br />
IF QueryType LIKE ('%Count%')<br />
THEN<br />
		SET SelectStmt = <br />
<br />
		&quot;SELECT COUNT(distinct(C.LocationID))AS 'Total Locations'<br />
				<br />
		FROM    Computers AS C<br />
#******************************************************************************<br />
IF ((StatusTimeToFail IS NULL) OR (StatusTimeToFail ='') OR (StatusTimeToFail =0))<br />
THEN<br />
	SET @TimeToFail = 15; #DEFAULT minutes<br />
ELSE	<br />
	SET @TimeToFail = StatusTimeToFail;<br />
END IF;<br />
#******************************************************************************<br />
IF (QueryType LIKE ('%Count%'))<br />
THEN<br />
	IF (MonitorStatus != 'all')<br />
	THEN<br />
		IF (MonitorStatus LIKE('%Fail%'))<br />
		THEN<br />
				SET WhereClause = CONCAT(' WHERE ');<br />
				SET WhereClause = CONCAT(WhereClause,<br />
 &quot; IFNULL(TIMESTAMPDIFF(minute, C.LastContact, NOW()),0) &quot;,   '&gt;=', @TimeToFail);<br />
<br />
<br />
		ELSEIF (MonitorStatus LIKE('%OK%'))<br />
		then<br />
				SET WhereClause = CONCAT(' WHERE ');				<br />
				SET WhereClause = CONCAT(WhereClause,<br />
 &quot; IFNULL(TIMESTAMPDIFF(minute, C.LastContact, NOW()),0) &quot;,  '&lt;', @TimeToFail);]]></description>
            <dc:creator>Ed English</dc:creator>
            <category>Transactions</category>
            <pubDate>Sat, 29 Dec 2012 22:56:19 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,573741,573741#msg-573741</guid>
            <title>Alternative for IN+Subselect in this case (1 reply)</title>
            <link>http://forums.mysql.com/read.php?97,573741,573741#msg-573741</link>
            <description><![CDATA[ Good morning everyone,<br />
<br />
iam having some problems with the following statement. The Subselect is moderately quick, but the whole statment takes about 70-75 seconds, which is unacceptable. Here are some facts you might need to know:<br />
The statement is partly hardcoded and cant be changed (until the first WHERE). So i cant use a join rather than the IN+Subselect.<br />
&quot;EXISTS&quot; only saves me a few seconds.<br />
table consists of 1 million lines<br />
idxmail consists of 2 million lines<br />
matching consists of 10 000 lines<br />
@var1 is set by the program<br />
 <br />
<br />
SELECT col1, col2<br />
FROM table b<br />
WHERE b.id IN (<br />
SELECT id<br />
FROM idxmail i<br />
JOIN matching m ON i.proxyaddress = m.proxyaddress<br />
WHERE m.mailnickname = '@var1')<br />
<br />
The profile of this query has about 2 million lines aswell. One for each line in idxmail.<br />
<br />
<br />
Explain (There is an index on id in table b):<br />
<br />
&quot;id&quot;	&quot;select_type&quot;	&quot;table&quot;	&quot;type&quot;	&quot;possible_keys&quot;	&quot;key&quot;	&quot;key_len&quot;	&quot;ref&quot;	&quot;rows&quot;	&quot;Extra&quot;<br />
&quot;1&quot;	&quot;PRIMARY&quot;	&quot;b&quot;	&quot;ALL&quot;	NULL	NULL	NULL	NULL	&quot;813796&quot;	&quot;Using where&quot;<br />
&quot;2&quot;	&quot;DEPENDENT SUBQUERY&quot;	&quot;i&quot;	&quot;ref&quot;	&quot;ID,Proxyadresse&quot;	&quot;ID&quot;	&quot;5&quot;	&quot;func&quot;	&quot;1&quot;	&quot;Using where&quot;<br />
&quot;2&quot;	&quot;DEPENDENT SUBQUERY&quot;	&quot;m&quot;	&quot;ref&quot;	&quot;Mailnickname,Proxyadresse&quot;	&quot;Proxyadresse&quot;	&quot;768&quot;	&quot;dwdata.i.Proxyadresse&quot;	&quot;1&quot;	&quot;Using where&quot;<br />
<br />
<br />
Thanks in advance.]]></description>
            <dc:creator>Christoph Noltensmeier</dc:creator>
            <category>Transactions</category>
            <pubDate>Sat, 17 Nov 2012 02:33:42 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,573613,573613#msg-573613</guid>
            <title>Optimisation problem with left join (1 reply)</title>
            <link>http://forums.mysql.com/read.php?97,573613,573613#msg-573613</link>
            <description><![CDATA[ Hi<br />
<br />
I wonder if anyone could offer any advice on the following query.  It runs okay, and very quickly, but due to the left join it is scanning all rows on the &quot;teams&quot; table despite having an index set on 'url_teamname', and I'm hoping this can be reduced somehow.<br />
<br />
A URL friendly team name can be passed in a URL, and I need to grab the ID and name for that team.  We have 3,161 teams in the &quot;teams&quot; table, but there may or may not be an entry in table &quot;prevteams&quot; depending on if the team was formerly known by another name for a range of seasons.<br />
<br />
The query is as follows:<br />
<br />
SELECT t.teamid AS useid, IF(pt.prevname IS NULL,t.teamname,pt.prevname) AS usename<br />
FROM teams t<br />
 LEFT JOIN prevteams pt ON t.teamno = pt.teamno AND pt.fromssn &lt;= '142' AND pt.tossn &gt;= '142'<br />
WHERE pt.url_prevname = 'arsenal' OR t.url_teamname = 'arsenal';<br />
<br />
The explain results are as follows:<br />
1, 'SIMPLE', 't', 'ALL', 'IX_URLT', '', '', '', 3161, ''<br />
1, 'SIMPLE', 'pt', 'ref', 'PRIMARY,IX_TmFromTo,IX_TmFrom,IX_TmTo,IX_From_To', 'IX_TmFromTo', '4', 'football.t.TeamNo', 1, 'Using where'<br />
<br />
Many thanks in advance<br />
Gary]]></description>
            <dc:creator>Gary Broughton</dc:creator>
            <category>Transactions</category>
            <pubDate>Sat, 17 Nov 2012 02:43:07 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,572405,572405#msg-572405</guid>
            <title>Query Is to Slow (4 replies)</title>
            <link>http://forums.mysql.com/read.php?97,572405,572405#msg-572405</link>
            <description><![CDATA[ The following two queres when ran separatly give me results inless then a second.<br />
<br />
set @start = '2012-01-01';<br />
set @stop = '2012-12-31';<br />
<br />
select<br />
distinct concat(users.first_name, &quot; &quot;, users.last_name) as Name<br />
from<br />
users<br />
left join tasks on users.id = tasks.created_by<br />
where<br />
(tasks.date_start between @start and @stop)<br />
order by concat(users.first_name, &quot; &quot;, users.last_name)<br />
;<br />
<br />
set @start = '2012-01-01';<br />
set @stop = '2012-12-31';<br />
<br />
select<br />
distinct concat(users.first_name, &quot; &quot;, users.last_name) as Name<br />
from<br />
users<br />
left join meetings on users.id = meetings.created_by<br />
where<br />
(meetings.date_start between @start and @stop)<br />
order by concat(users.first_name, &quot; &quot;, users.last_name)<br />
;<br />
<br />
However when I combine the queries in to the following it takes munites (I have never waited long enough for it to finish).<br />
<br />
set @start = '2012-01-01';<br />
set @stop = '2012-12-31';<br />
<br />
select<br />
distinct concat(users.first_name, &quot; &quot;, users.last_name) as Name<br />
from<br />
users<br />
left join tasks on users.id = tasks.created_by<br />
left join meetings on users.id = meetings.created_by<br />
where<br />
(tasks.date_start between @start and @stop)<br />
or (meetings.date_start between @start and @stop)<br />
order by concat(users.first_name, &quot; &quot;, users.last_name)<br />
;<br />
<br />
What am I doing wrong, or is this just a performance issue?<br />
<br />
Thank you,<br />
Scott]]></description>
            <dc:creator>Scott Hanebutt</dc:creator>
            <category>Transactions</category>
            <pubDate>Wed, 31 Oct 2012 14:13:24 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,571691,571691#msg-571691</guid>
            <title>SQL SELECT statement taking too long (1 reply)</title>
            <link>http://forums.mysql.com/read.php?97,571691,571691#msg-571691</link>
            <description><![CDATA[ Hello, <br />
<br />
I am currently running the following SQL statement: <br />
<br />
SELECT company<br />
FROM plotrows<br />
WHERE pid<br />
IN (<br />
<br />
SELECT pid<br />
FROM plotrows<br />
WHERE hybrid =  '1098'<br />
)<br />
GROUP BY company<br />
ORDER BY company<br />
<br />
The query is taking almost 5 minutes. This is causing a problem and I believe it is time out in my PHP script. When I try to run the PHP script in my browser I receive the following error: <br />
<br />
Query execution was interrupted<br />
<br />
The 'plotrows' database table has about 37,000 records... <br />
<br />
How can I go about getting this query to run faster? Any suggestions?]]></description>
            <dc:creator>Joshua Walusz</dc:creator>
            <category>Transactions</category>
            <pubDate>Sat, 27 Oct 2012 21:49:17 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,571002,571002#msg-571002</guid>
            <title>PLEASE HELP, SELECT FOR UPDATE NOT WORKING (no replies)</title>
            <link>http://forums.mysql.com/read.php?97,571002,571002#msg-571002</link>
            <description><![CDATA[ SELECT .... FOR UPDATE not working when fired from remote accounts. It works fine when i run it from the command line client directly on the server using root@localhost account. I have given all privileges to my remote accounts and it doesnt work. I am using DBFORGE studio as client. When i execute the following statement <br />
<br />
 SELECT * FROM SOMETABLE WHERE ID = 8 FOR UPDATE; <br />
<br />
it runs and finishes and everything looks fine. Then i log to my server, run command line and connect to my MySql db as root@localhost to test. Aggain i run <br />
<br />
 SELECT * FROM SOMETABLE WHERE ID = 8 FOR UPDATE;<br />
<br />
And it finishes. So row wasnt locked!?!?!?. I'm like WTF? So i go back to dbForge studio running on my computer and run<br />
<br />
 SELECT * FROM SOMETABLE WHERE ID = 8 FOR UPDATE;<br />
<br />
AND ROW IS LOCKED, TRANSACTION IS WAITING!!!<br />
<br />
I cannot figure out why SELECT .... FOR UPDATE doesnt lock the row when run by remote accounts from remote computer, and workse when run from the server.<br />
<br />
PLEASE HELP!!!!<br />
<br />
BTW. I HAVE TRIED EVERYTHING. GIVEN THE USERS GRANT ALL PRIVILEGES and everything!!!]]></description>
            <dc:creator>Alem Bišćan</dc:creator>
            <category>Transactions</category>
            <pubDate>Sun, 14 Oct 2012 18:22:21 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,570464,570464#msg-570464</guid>
            <title>Select statement display all ip-addresses of a subnet (1 reply)</title>
            <link>http://forums.mysql.com/read.php?97,570464,570464#msg-570464</link>
            <description><![CDATA[ Hi,<br />
<br />
I'm not new in Mysql, but my knowledge is just some basics of SQL. I hope somebody could help, because first I'm not sure if it is possible what I'm looking for and further, what do I need to look for :S<br />
<br />
Here my question:<br />
I have a table called network_addr which consist of the fields:<br />
- id_network, network_addr, mask<br />
<br />
As network_addr is stored in decimal format and mask in number of bits, I can calulate how ip-addresses this network could contain.<br />
<br />
Now the question is, is it possible by an sql statement to print a table with all possible ip-addresse?<br />
<br />
Hope somebody could help me.<br />
<br />
Thanks!]]></description>
            <dc:creator>Florian Schilling</dc:creator>
            <category>Transactions</category>
            <pubDate>Wed, 10 Oct 2012 05:37:41 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,569489,569489#msg-569489</guid>
            <title>include line number depending on field (no replies)</title>
            <link>http://forums.mysql.com/read.php?97,569489,569489#msg-569489</link>
            <description><![CDATA[ Hello,<br />
<br />
I've got a table in my database where I store the order lines. I am using a sh script to export that table to a csv.<br />
What I need is to show the line number in its order, so if it outputs the first order, lines would be:<br />
1,product1<br />
2,product2<br />
3,product3<br />
<br />
for the second order, lines would begin with 1, so I can see for every order, the numbered lines.<br />
<br />
Is there any way to achieve this, something like incrementing a variable and reseting it to 0 when a new order_id is found?<br />
<br />
I've achieved creating a variable and incrementing it on every iteration, but I don't know how to know the field.<br />
<br />
Thanks you!]]></description>
            <dc:creator>pascual bayo</dc:creator>
            <category>Transactions</category>
            <pubDate>Tue, 25 Sep 2012 13:48:29 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,569472,569472#msg-569472</guid>
            <title>How Count Distinct With IF (1 reply)</title>
            <link>http://forums.mysql.com/read.php?97,569472,569472#msg-569472</link>
            <description><![CDATA[ I need to do a query with count distinct and IF, but the results always are 0.<br />
What I need to do, is count the different users from a table in different months, using IF, and finally grouping by some value. My individual query, for one month is this: <br />
<br />
     SELECT <br />
     COUNT(DISTINCT(idUsers)) AS num_usuarios<br />
     FROM table01<br />
     WHERE date1='201207'<br />
     GROUPED BY cve_school<br />
<br />
But I need to get the results by different months in the same query. What I'm trying to do is this:<br />
<br />
    SELECT <br />
    IF(date1=(201207), count(distinct(idUsers)), 0) as user30,<br />
    IF(fecha1=(201206), count(distinct(idUsers)), 0) as user60,<br />
    IF(fecha1=(201205), count(distinct(idUsers)), 0) as user90,<br />
    IF(fecha1=(201204), count(distinct(idUsers)), 0) as user120,<br />
    IF(fecha1=(201203), count(distinct(idUsers)), 0) as user150<br />
    FROM table01<br />
    GROUPED BY cve_school<br />
<br />
<br />
But the all the results are always 0.]]></description>
            <dc:creator>Daniel Estrada</dc:creator>
            <category>Transactions</category>
            <pubDate>Fri, 28 Sep 2012 04:47:55 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,568364,568364#msg-568364</guid>
            <title>work with transaction in Query Browser! (no replies)</title>
            <link>http://forums.mysql.com/read.php?97,568364,568364#msg-568364</link>
            <description><![CDATA[ I have just upgraded Mysql for HP from 4.0.8 (Connector/J 3.0.11) to 4.1.11 (Copnnector/J 3.1.7) and realized that my old code did not work anymore. Be specific, the ResultSet that was obtained from executing a PreparedStatement was empty. In the process of figuring what went wrong, I replaced the PreparedStatement with non-prepared statement and it works: <br />
<a href="http://storify.com/hukejoli/watch-the-dark-knight-rises-online-free-on-megavid"  rel="nofollow">Watch The Dark Knight Rises Online</a><br />
String query = &quot;SELECT xxxxxxxxx&quot;; <br />
Statement stmt = conn.createStatement(); <br />
rs = stmt.executeQuery(query); <br />
<a href="http://storify.com/hukejoli/watch-the-expendables-2-online-free-on-movietail-2"  rel="nofollow">Watch The Expendables 2 Online</a><br />
<br />
Just wondering if anyone has experienced the same issue? The query string is pretty long and have couple of inner joins and outer joins and plus order by clause. I don't know if that also contribute to the problem. <br />
<a href="http://storify.com/michealfleem/watch-ted-movie-online-free-streaming-2012"  rel="nofollow">Watch Ted Online</a>]]></description>
            <dc:creator>huke joli</dc:creator>
            <category>Transactions</category>
            <pubDate>Thu, 13 Sep 2012 09:55:50 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,564749,564749#msg-564749</guid>
            <title>FiFo in mysql (1 reply)</title>
            <link>http://forums.mysql.com/read.php?97,564749,564749#msg-564749</link>
            <description><![CDATA[ Hi, <br />
I have a tricky transaction that I haven't been able to create. I have looked for an answer on the web, but I haven't found anything... <br />
<br />
Imagine I have created a database where I keep track of when and how many company shares (Stocks) I sell/buy and the shares prices. <br />
<br />
Let's say that I have bought the following shares: <br />
01/01/2007 100 Yahoo Shares at 10$ each. <br />
02/01/2007 100 Yahoo Shares at 20$ each. <br />
<br />
The average price in this case would be (we can use AVG()): <br />
200 Yahoo Shares at 15 $ each. <br />
<br />
The problem is that if I sell: <br />
03/01/2007 100 Yahoo shares at 30$ each. <br />
The average price would be: <br />
(100*10$ + 100*20$ - 100*30$)/100 = 0 $. <br />
<br />
That average price includes the profit within the average price. I want to consider a FIFO system, where the first shares that I bought are the ones that are sold first. That way I would get an average price of: <br />
100 Yahoo Shares at 20 $ each. <br />
<br />
Is it possible to do this FIFO thing using Mysql?. Since I am using PHP, would it be better to do all the FIFO calculations within PHP? <br />
<br />
I would really appreciate any help with this. <br />
<br />
Thanks in advance.]]></description>
            <dc:creator>Paresh Madani</dc:creator>
            <category>Transactions</category>
            <pubDate>Mon, 20 Aug 2012 03:21:08 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,563569,563569#msg-563569</guid>
            <title>Transaction in functions/stored procedure (1 reply)</title>
            <link>http://forums.mysql.com/read.php?97,563569,563569#msg-563569</link>
            <description><![CDATA[ If i have in a mysql function/stored procedure just 2 queries (2 deletes from different tables, or 1 insert and 1 delete for different tables), how shoul i use the transaction? I think i must use it because if the second query fails, my DB is wrong. What controls should i use to see if i must commit or rollback? I searched, but i found just some examples with query+commit or query+rollback.]]></description>
            <dc:creator>Sam Jonhson</dc:creator>
            <category>Transactions</category>
            <pubDate>Thu, 02 Aug 2012 14:34:23 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,561337,561337#msg-561337</guid>
            <title>how to get value of auto increased number (3 replies)</title>
            <link>http://forums.mysql.com/read.php?97,561337,561337#msg-561337</link>
            <description><![CDATA[ right  now, this is the best way I can think of to preserve the record identity using auto incresed number (pseudo-code):<br />
<br />
//begin of pseudo code<br />
<br />
trans.begin<br />
<br />
statement.execute(&quot;INSERT INTO TBL1 (name) VALUES ('one')&quot;); // inserting<br />
rs = statement.execute(&quot;SELECT MAX(recID) number FROM TBL1&quot;); //get recID<br />
<br />
long number = rs.get(&quot;number&quot;);<br />
<br />
trans.commit<br />
<br />
//end of pseudo code<br />
<br />
this is the only way I can think of to make the &quot;number&quot; available in the application code. Is there any better way? I need alternative that will work in concurrent multi-user environment, where multiple user may access the same row at the same time. thanks]]></description>
            <dc:creator>Global Solution</dc:creator>
            <category>Transactions</category>
            <pubDate>Mon, 16 Jul 2012 05:30:43 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,557450,557450#msg-557450</guid>
            <title>Table Rename (1 reply)</title>
            <link>http://forums.mysql.com/read.php?97,557450,557450#msg-557450</link>
            <description><![CDATA[ Is there someway to do a table rename within a transaction, or make it atomic so if an update fails it doesnt rename the table. <br />
<br />
Thanks]]></description>
            <dc:creator>Rob UK</dc:creator>
            <category>Transactions</category>
            <pubDate>Wed, 13 Jun 2012 16:36:27 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,527335,527335#msg-527335</guid>
            <title>Best isolation level for the transaction (4 replies)</title>
            <link>http://forums.mysql.com/read.php?97,527335,527335#msg-527335</link>
            <description><![CDATA[ Hello guys, are you ok? <br />
<br />
Well, i'm having a little doubt about a isolation level of a transaction. <br />
I have a group of query that will be executed and perform the follow actions: <br />
<br />
- 1º step: check if the user account have founds (SELECT); <br />
- 2º step: (here, some updates in another table and bla bla bla); <br />
- 3º step: disccount the ammount (if his account have founds) of the user account; <br />
<br />
The problem is: if two transaction were executed in the same time (on the truth, with miliseconds of diference, anyway, SIMULTANEOUS!), the 1º step and 3º step can be a big problem for the database. Let's call the transactions by T1 and T2. If T1 execute the 1º step, and T2 execute the 1º step BEFORE T1 execute the 3º step, T2 can receive the response that have founds in the account, even if the T1 in the 3º step, erase all this founds. <br />
<br />
So i need a isolation level for the transaction that make the T2 (or T3, T4, Tn) wait for a complete execution of T1 for continue. <br />
<br />
So well, what is the best choice for my problem friends? <br />
Best regards, <br />
Luiz Cláudio Pinheiro]]></description>
            <dc:creator>Luiz Cláudio Pinheiro</dc:creator>
            <category>Transactions</category>
            <pubDate>Fri, 27 Apr 2012 03:01:23 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,527148,527148#msg-527148</guid>
            <title>Multi-User Updates (1 reply)</title>
            <link>http://forums.mysql.com/read.php?97,527148,527148#msg-527148</link>
            <description><![CDATA[ I'm new to working with MySql and could use some help.<br />
<br />
I have a relationship between two tables - Budget_Master_File and Budget_Transactions.<br />
<br />
Each record in Budget_Master_File can have MANY Budget_Transaction Records.<br />
<br />
Tables are related by  Budget_Master_File.Bud_ID and Budget_Transactions.BudID<br />
<br />
I would like to Edit the amount of an existing Budget_Transaction (t.Amount) and update the Current Account Balance (b.balance) by backing out old transaction amount and adding in new transaction amount.  <br />
<br />
To get my data that needs to be edited  (Transaction ID 27) I use the following SQL.<br />
<br />
SELECT * <br />
FROM Budget_Transactions t<br />
LEFT JOIN Budget_Master_File b<br />
ON b.Bud_ID = t.BudID<br />
WHERE t.Trans_ID = 27;<br />
<br />
Now I display data and wait for operator to click a UPDATE Button<br />
<br />
It could be several minutes before UPDATE button is clicked.<br />
<br />
Once UPDATE is Clicked I need to:<br />
Lock both Tables<br />
Apply Updates to both Tables<br />
<br />
b.Balance = b.Balance - t.Amount + NewAmount<br />
t.Amount = NewAmount<br />
<br />
Finally - Unlock Tables<br />
<br />
I am assuming that I would need to do something like the following:<br />
<br />
-- Lock Tables ---<br />
LOCK TABLES <br />
    Budget_Master_File WRITE,<br />
    Budget_Transactions WRITE;<br />
<br />
-- ReFetch Data ---<br />
SELECT * <br />
FROM Budget_Transactions t<br />
LEFT JOIN Budget_Master_File b<br />
ON b.Bud_ID = t.BudID<br />
WHERE t.Trans_ID = 27;<br />
<br />
-- Update Tables Here ---<br />
<br />
UNLOCK TABLES; <br />
<br />
Can someone show me:<br />
1.  How do do Lock for Writing if my code is wrong.<br />
2.  Best way to get data immediately before updating<br />
3.  How to do the Update<br />
4.  Unlock Procedure if my code is wrong.<br />
<br />
<br />
Any assistance is appreciated.<br />
<br />
Thanks in advance...]]></description>
            <dc:creator>Lee Bornstein</dc:creator>
            <category>Transactions</category>
            <pubDate>Mon, 23 Apr 2012 21:36:32 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,522339,522339#msg-522339</guid>
            <title>Uncommitted rows are updated by a second transaction (2 replies)</title>
            <link>http://forums.mysql.com/read.php?97,522339,522339#msg-522339</link>
            <description><![CDATA[ Hello,<br />
<br />
Please help me understand the following scenario:<br />
Connection 1 and connection 2 starts a transaction with REPEATABLE-READ transaction isolation.<br />
<br />
A. Connection 1:<br />
  1. Inserts a row.<br />
  2. commit.<br />
<br />
B. Connection 2:<br />
  1. Selects all rows - gets no rows.<br />
  2. Updates all rows - the row of connection 1 is updated.<br />
  3. Selects all rows - the up-to-date row of connection 1 is returned.<br />
<br />
C. Connection 1:<br />
  1. Selects all rows - gets the inserted row - not up-to-date.<br />
<br />
I would expect that the UPDATE in B.2 will not update any rows.<br />
Is this the correct behaviour? Can you please explain?<br />
<br />
MySQL Server 5.1.42-community.<br />
<br />
Thanks.<br />
<br />
<br />
This is an output of a Java test:<br />
<br />
connection1 = Connection 73934, AutoCommit = false, JDBC TransactionIsolation = 4, DB TransactionIsolation REPEATABLE-READ<br />
connection2 = Connection 73935, AutoCommit = false, JDBC TransactionIsolation = 4, DB TransactionIsolation REPEATABLE-READ<br />
executeUpdate Connection 73934, AutoCommit = false, JDBC TransactionIsolation = 4, DB TransactionIsolation REPEATABLE-READ: 'INSERT INTO TEST_TABLE (PK_COL) VALUES (NULL)', updatedRowCount = 1<br />
AFTER ONE INSERT BEFORE COMMIT: Connection 73934, rows {1=null}<br />
AFTER ONE INSERT BEFORE COMMIT: Connection 73935, rows {}<br />
AFTER ONE INSERT AFTER COMMIT: Connection 73934, rows {1=null}<br />
AFTER ONE INSERT AFTER COMMIT: Connection 73935, rows {}<br />
executeUpdate Connection 73935, AutoCommit = false, JDBC TransactionIsolation = 4, DB TransactionIsolation REPEATABLE-READ: 'UPDATE TEST_TABLE SET COL2 = CURRENT_TIMESTAMP', updatedRowCount = 1<br />
AFTER UPDATE ALL: Connection 73934, rows {1=null}<br />
AFTER UPDATE ALL: Connection 73935, rows {1=2012-03-29 11:57:44.0}<br />
executeUpdate Connection 73935, AutoCommit = false, JDBC TransactionIsolation = 4, DB TransactionIsolation REPEATABLE-READ: 'INSERT INTO TEST_TABLE (PK_COL) VALUES (NULL)', updatedRowCount = 1<br />
executeUpdate Connection 73935, AutoCommit = false, JDBC TransactionIsolation = 4, DB TransactionIsolation REPEATABLE-READ: 'INSERT INTO TEST_TABLE (PK_COL) VALUES (NULL)', updatedRowCount = 1<br />
executeUpdate Connection 73935, AutoCommit = false, JDBC TransactionIsolation = 4, DB TransactionIsolation REPEATABLE-READ: 'INSERT INTO TEST_TABLE (PK_COL) VALUES (NULL)', updatedRowCount = 1<br />
AFTER THREE INSERT: Connection 73934, rows {1=null}<br />
AFTER THREE INSERT: Connection 73935, rows {1=2012-03-29 11:57:44.0, 2=null, 3=null, 4=null}<br />
AFTER COMMIT: Connection 73934, rows {1=2012-03-29 11:57:44.0, 2=null, 3=null, 4=null}<br />
AFTER COMMIT: Connection 73935, rows {1=2012-03-29 11:57:44.0, 2=null, 3=null, 4=null}<br />
<br />
<br />
<br />
This is the Java class:<br />
<br />
import java.sql.*;<br />
import java.util.HashMap;<br />
import java.util.Map;<br />
<br />
public class TestTransaction {<br />
    public static void main(String[] args) throws SQLException {<br />
<br />
        Connection connection1 = null;<br />
        Connection connection2 = null;<br />
        try {<br />
<br />
            prepareEnv();<br />
<br />
            connection1 = createConnection();<br />
            connection1.setAutoCommit(false);<br />
            System.out.println(&quot;connection1 = &quot; + toString(connection1));<br />
<br />
            connection2 = createConnection();<br />
            connection2.setAutoCommit(false);<br />
            System.out.println(&quot;connection2 = &quot; + toString(connection2));<br />
<br />
            printRows(&quot;START&quot;, connection1);<br />
            printRows(&quot;START&quot;, connection2);<br />
<br />
            executeUpdate(connection1, &quot;INSERT INTO TEST_TABLE (PK_COL) VALUES (NULL)&quot;);<br />
<br />
            printRows(&quot;AFTER ONE INSERT BEFORE COMMIT&quot;, connection1);<br />
            printRows(&quot;AFTER ONE INSERT BEFORE COMMIT&quot;, connection2);<br />
            connection1.commit();<br />
            printRows(&quot;AFTER ONE INSERT AFTER COMMIT&quot;, connection1);<br />
            printRows(&quot;AFTER ONE INSERT AFTER COMMIT&quot;, connection2);<br />
<br />
            executeUpdate(connection2, &quot;UPDATE TEST_TABLE SET COL2 = CURRENT_TIMESTAMP&quot;);<br />
            printRows(&quot;AFTER UPDATE ALL&quot;, connection1);<br />
            printRows(&quot;AFTER UPDATE ALL&quot;, connection2);<br />
<br />
            executeUpdate(connection2, &quot;INSERT INTO TEST_TABLE (PK_COL) VALUES (NULL)&quot;);<br />
            executeUpdate(connection2, &quot;INSERT INTO TEST_TABLE (PK_COL) VALUES (NULL)&quot;);<br />
            executeUpdate(connection2, &quot;INSERT INTO TEST_TABLE (PK_COL) VALUES (NULL)&quot;);<br />
            printRows(&quot;AFTER THREE INSERT&quot;, connection1);<br />
            printRows(&quot;AFTER THREE INSERT&quot;, connection2);<br />
<br />
            connection1.commit();<br />
            connection2.commit();<br />
<br />
            printRows(&quot;AFTER COMMIT&quot;, connection1);<br />
            printRows(&quot;AFTER COMMIT&quot;, connection2);<br />
<br />
        } finally {<br />
            closeConnection(connection1);<br />
            closeConnection(connection2);<br />
        }<br />
    }<br />
<br />
    private static void prepareEnv() throws SQLException {<br />
        Connection connection = null;<br />
        try {<br />
            connection = createConnection();<br />
            Statement statement = connection.createStatement();<br />
            statement.execute(&quot;DROP TABLE `TEST_TABLE`&quot;);<br />
            statement.execute(<br />
                    &quot;CREATE TABLE `TEST_TABLE` (&quot; +<br />
                    &quot;  `PK_COL` int(11) NOT NULL AUTO_INCREMENT,\n&quot; +<br />
                    &quot;  `COL2` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,\n&quot; +<br />
                    &quot;  PRIMARY KEY (`PK_COL`)\n&quot; +<br />
                    &quot;) ENGINE=InnoDB DEFAULT CHARSET=utf8&quot;);<br />
        } finally {<br />
            closeConnection(connection);<br />
        }<br />
    }<br />
<br />
    private static void executeUpdate(Connection connection, String sql) throws SQLException {<br />
        Statement statement = connection.createStatement();<br />
        int rowCount = statement.executeUpdate(sql);<br />
        System.out.println(&quot;executeUpdate &quot; + toString(connection) + &quot;: '&quot; + sql + &quot;', updatedRowCount = &quot; + rowCount);<br />
    }<br />
<br />
    private static Connection createConnection() throws SQLException {<br />
        return DriverManager.getConnection(&quot;jdbc:mysql://localhost/test&quot;, &quot;test&quot;, &quot;test&quot;);<br />
    }<br />
<br />
    private static String toString(Connection connection) throws SQLException {<br />
        int connectionId = fetchConnectionId(connection);<br />
        String transactionIsolation;<br />
        Statement statement = null;<br />
        ResultSet resultSet = null;<br />
        try {<br />
            statement = connection.createStatement();<br />
            resultSet = statement.executeQuery(&quot;SELECT @@tx_isolation&quot;);<br />
            resultSet.next();<br />
            transactionIsolation = resultSet.getString(1);<br />
        } finally {<br />
            closeResources(statement, resultSet);<br />
        }<br />
        return &quot;Connection &quot; + connectionId + &quot;, AutoCommit = &quot; + connection.getAutoCommit() + &quot;, JDBC TransactionIsolation = &quot; + connection.getTransactionIsolation() + &quot;, DB TransactionIsolation &quot; + transactionIsolation;<br />
    }<br />
<br />
    private static int fetchConnectionId(Connection connection) throws SQLException {<br />
        int connectionId;<br />
        Statement statement = null;<br />
        ResultSet resultSet = null;<br />
        try {<br />
            statement = connection.createStatement();<br />
            resultSet = statement.executeQuery(&quot;SELECT CONNECTION_ID()&quot;);<br />
            resultSet.next();<br />
            connectionId = resultSet.getInt(1);<br />
        } finally {<br />
            closeResources(statement, resultSet);<br />
        }<br />
        return connectionId;<br />
    }<br />
<br />
    private static void printRows(String prefix, Connection connection) throws SQLException {<br />
        Map&lt;Integer, Timestamp&gt; rows = new HashMap&lt;Integer, Timestamp&gt;();<br />
        Statement statement = null;<br />
        ResultSet resultSet = null;<br />
        try {<br />
            statement = connection.createStatement();<br />
            resultSet = statement.executeQuery(&quot;SELECT PK_COL, COL2 FROM TEST_TABLE&quot;);<br />
            while (resultSet.next()) {<br />
                rows.put(resultSet.getInt(&quot;PK_COL&quot;), resultSet.getTimestamp(&quot;COL2&quot;));<br />
            }<br />
            System.out.println(prefix + &quot;: Connection &quot; + fetchConnectionId(connection) + &quot;, rows &quot; + rows);<br />
        } finally {<br />
            closeResources(statement, resultSet);<br />
        }<br />
    }<br />
<br />
    private static void closeResources(Statement statement, ResultSet resultSet) {<br />
        if (resultSet != null) {<br />
            try {<br />
                resultSet.close();<br />
            } catch (SQLException e) {<br />
                System.out.println(&quot;WARN: Closing resultSet &quot; + e);<br />
            }<br />
        }<br />
        if (statement != null) {<br />
            try {<br />
                statement.close();<br />
            } catch (SQLException e) {<br />
                System.out.println(&quot;WARN: Closing statement &quot; + e);<br />
            }<br />
        }<br />
    }<br />
<br />
    public static void closeConnection(Connection connection) {<br />
        try {<br />
            if (connection != null) {<br />
                connection.close();<br />
            }<br />
        } catch (SQLException e) {<br />
            System.out.println(&quot;WARN: Closing connection &quot; + e);<br />
        }<br />
    }<br />
}<br />
:]]></description>
            <dc:creator>Moshe Elisha</dc:creator>
            <category>Transactions</category>
            <pubDate>Thu, 29 Mar 2012 21:52:33 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,522323,522323#msg-522323</guid>
            <title>Convert string to date (1 reply)</title>
            <link>http://forums.mysql.com/read.php?97,522323,522323#msg-522323</link>
            <description><![CDATA[ I have a table with dates as strings in the format 11-Jun-2011. I want to change this to a proper date in the format 2011/06/11.<br />
<br />
In some of the tables, the dates are in the format: 11-Jun-11. I also want to change this to the format 2011/06/11.<br />
<br />
Kind regards<br />
<br />
Jolinda]]></description>
            <dc:creator>Jolinda Bartlett</dc:creator>
            <category>Transactions</category>
            <pubDate>Thu, 29 Mar 2012 19:12:40 +0000</pubDate>
        </item>
        <item>
            <guid>http://forums.mysql.com/read.php?97,519462,519462#msg-519462</guid>
            <title>q about concurrency for money transfer (1 reply)</title>
            <link>http://forums.mysql.com/read.php?97,519462,519462#msg-519462</link>
            <description><![CDATA[ Hi all,<br />
I would like to make a money transfer procedure in a single transaction, but whether to perform or not perform the transaction depends on some value in some view (not table). something like this:<br />
<br />
select units from view1 where product = 1;<br />
<br />
if units &gt; 0 then<br />
<br />
    update account set money = money - 10 where account_id = 1;<br />
<br />
    update account set money = money + 10 where account_id = 2;<br />
<br />
endif<br />
<br />
<br />
how can i make this transactional? I was thinking about &quot;select for udpate&quot; but I don't think it works on views, or at least, I'm not sure which records I should lock... I am concerned about the fact that 'units' may change between the &quot;if&quot; statement and the actual update statement...<br />
<br />
I'd appreciate any help...<br />
thanks]]></description>
            <dc:creator>sagi mann</dc:creator>
            <category>Transactions</category>
            <pubDate>Sat, 10 Mar 2012 19:30:02 +0000</pubDate>
        </item>
    </channel>
</rss>
