[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



Scroll down until you find it (stupid site doesn't have anchors) --
<a  rel="nofollow" href="http://dev.mysql.com/doc/mysql/en/information-functions.html";>http://dev.mysql.com/doc/mysql/en/information-functions.html</a>

On 6/9/05, Chris Fowler &lt;cfowler at outpostsentinel.com&gt; wrote:
&gt; I'm going to control deletion.  Once a row is inserted it can not be
&gt; changed.
&gt; 
&gt; There is a problem if the user does do the following in an empty DB.
&gt; 
&gt; insert into sensor_533 values (533, now());
&gt; 
&gt; Now max will retrieve the 533 as the max with only one row in the DB.
&gt; 
&gt; &gt; Checking the new Row ID after an insert is the only real way to go
&gt; about it.
&gt; 
&gt; This might be the best way but how do I do this?  &quot;select serial_no from
&gt; table_533 where .....&quot;
&gt; 
&gt; The table is very simple for now.
&gt; 
&gt;  CREATE TABLE sensor_533 (
&gt;   serial_no INTEGER(9) NOT NULL AUTO_INCREMENT,
&gt;   issued DATETIME NOT NULL,
&gt;   PRIMARY KEY(serial_no),
&gt; );
&gt; 
&gt; CREATE TABLE device (
&gt;   device_id INTEGER(11) NOT NULL AUTO_INCREMENT,
&gt;   name VARCHAR(20) NULL,
&gt;   table_name VARCHAR(20) NULL,
&gt;   PRIMARY KEY(device_id),
&gt; );
&gt; 
&gt; insert into device values (0, &quot;533&quot;, &quot;sensor_533&quot;);
&gt; 
&gt; Evan that method has the same problem as select max(...)  In the MySQL
&gt; documents it stated that the auto_increment value was stored in memory
&gt; at startup and the program simply does a select max(...) to get the
&gt; correct value.
&gt; 
&gt; 
&gt; 
&gt; On Thu, 2005-06-09 at 09:05 -0400, Michael B. Trausch wrote:
&gt; &gt; -----BEGIN PGP SIGNED MESSAGE-----
&gt; &gt; Hash: RIPEMD160
&gt; &gt;
&gt; &gt; Chris Fowler wrote:
&gt; &gt; &gt;
&gt; &gt; &gt; I've attached a perl program where I hacked out a way to get the next
&gt; &gt; &gt; logical entry.  This program does not do the insert yet.
&gt; &gt; &gt;
&gt; &gt;
&gt; &gt; Just note that if entries are added and deleted and so forth, that this
&gt; &gt; will not be accurate.  The program is selecting the highest current
&gt; &gt; serial number, when in fact, I could add 500 rows, and then delete them
&gt; &gt; all.  The max serial would then be (next_incremented_serial-501), and
&gt; &gt; then you'd be out of sync with the DB.  In addition, when you next
&gt; &gt; INSERT using a non-explicit ID count, you'll be out of sync.
&gt; &gt;
&gt; &gt;       - Mike
&gt; &gt;
&gt; &gt; - --
&gt; &gt; Michael B. Trausch                                     fd0man at gmail.com
&gt; &gt; Web: <a  rel="nofollow" href="http://fd0man.theunixplace.com/";>http://fd0man.theunixplace.com/</a>        Jabber: mtrausch at jabber.com
&gt; &gt; Phone: +1-(678)-522-7934                  FAX (US Only): 1-866-806-4647
&gt; &gt; =======================================================================
&gt; &gt;   Do you have PGP or GPG?  Key at pgp.mit.edu, Please Encrypt E-Mail!
&gt; &gt;
&gt; &gt; -----BEGIN PGP SIGNATURE-----
&gt; &gt; Version: GnuPG v1.4.1 (GNU/Linux)
&gt; &gt; Comment: Using GnuPG with Thunderbird - <a  rel="nofollow" href="http://enigmail.mozdev.org";>http://enigmail.mozdev.org</a>
&gt; &gt;
&gt; &gt; iD8DBQFCqD59PXInbkqM7nwRA6caAJ0Qs0pX9X9raz660ftuYrg7GulNGACfX8MH
&gt; &gt; LkBCry3rMa+g/697ijbmr4Q=
&gt; &gt; =KkgU
&gt; &gt; -----END PGP SIGNATURE-----
&gt; &gt; _______________________________________________
&gt; &gt; Ale mailing list
&gt; &gt; Ale at ale.org
&gt; &gt; <a  rel="nofollow" href="http://www.ale.org/mailman/listinfo/ale";>http://www.ale.org/mailman/listinfo/ale</a>
&gt; 
&gt; _______________________________________________
&gt; Ale mailing list
&gt; Ale at ale.org
&gt; <a  rel="nofollow" href="http://www.ale.org/mailman/listinfo/ale";>http://www.ale.org/mailman/listinfo/ale</a>
&gt; 


-- 
James Sumners
<a  rel="nofollow" href="http://james.roomfullofmirrors.com/";>http://james.roomfullofmirrors.com/</a>

&quot;All governments suffer a recurring problem: Power attracts
pathological personalities. It is not that power corrupts but that it
is magnetic to the corruptible. Such people have a tendency to become
drunk on violence, a condition to which they are quickly addicted.&quot;

Missionaria Protectiva, Text QIV (decto)
CH:D 59


</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00401" href="msg00401.html">[ale] Getting the next index of a table in mysql</a></strong>
<ul><li><em>From:</em> cfowler at outpostsentinel.com (Chris Fowler)</li></ul></li>
<li><strong><a name="00402" href="msg00402.html">[ale] Getting the next index of a table in mysql</a></strong>
<ul><li><em>From:</em> james.sumners at gmail.com (James Sumners)</li></ul></li>
<li><strong><a name="00403" href="msg00403.html">[ale] Getting the next index of a table in mysql</a></strong>
<ul><li><em>From:</em> fd0man at gmail.com (Michael B. Trausch)</li></ul></li>
<li><strong><a name="00405" href="msg00405.html">[ale] Getting the next index of a table in mysql</a></strong>
<ul><li><em>From:</em> cfowler at outpostsentinel.com (Chris Fowler)</li></ul></li>
<li><strong><a name="00406" href="msg00406.html">[ale] Getting the next index of a table in mysql</a></strong>
<ul><li><em>From:</em> fd0man at gmail.com (Michael B. Trausch)</li></ul></li>
<li><strong><a name="00407" href="msg00407.html">[ale] Getting the next index of a table in mysql</a></strong>
<ul><li><em>From:</em> cfowler at outpostsentinel.com (Chris Fowler)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00407.html">[ale] Getting the next index of a table in mysql</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00409.html">[ale] Getting the next index of a table in mysql</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00407.html">[ale] Getting the next index of a table in mysql</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00409.html">[ale] Getting the next index of a table in mysql</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00408"><strong>Date</strong></a></li>
<li><a href="threads.html#00408"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>