﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>BBS.PROGENIC.COM / Chat / Coding  / @@Identity in MySql / Latest Posts</title><generator>InstantForum.NET v4.1.2</generator><description>BBS.PROGENIC.COM</description><link>http://bbs.progenic.com/</link><webMaster>noreply@progenic.com</webMaster><lastBuildDate>Wed, 08 Feb 2012 09:20:28 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: @@Identity in MySql</title><link>http://bbs.progenic.com/Topic11667-9-1.aspx</link><description>orly?</description><pubDate>Mon, 25 Jan 2010 04:22:50 GMT</pubDate><dc:creator>proge</dc:creator></item><item><title>RE: @@Identity in MySql</title><link>http://bbs.progenic.com/Topic11667-9-1.aspx</link><description>he obviously is using it for mysql injection teqniques the identify string is the hard part of the injection</description><pubDate>Sun, 24 Jan 2010 23:00:15 GMT</pubDate><dc:creator>scriptjunkie</dc:creator></item><item><title>RE: @@Identity in MySql</title><link>http://bbs.progenic.com/Topic11667-9-1.aspx</link><description>Sounds about right, not sure how ado.net's connection pooling comes into play here though, it keeps connections alive so theoretically that could mess things up. But you'd have to read up / test that really.&lt;/P&gt;&lt;P&gt;That being said though, any sort of trigger will definitely live inside your connection's scope, so if one of those does an insert somewhere on an identity field because of something you did, you're in trouble. Moral of the story - use scope_identity(), there's no reason not to &lt;img align="absmiddle" src="http://bbs.progenic.com/Skins/Common/EmotIcons/Smile.gif" border="0" title="Smile"&gt;&lt;BR&gt;</description><pubDate>Wed, 05 Sep 2007 13:02:44 GMT</pubDate><dc:creator>wax</dc:creator></item><item><title>RE: @@Identity in MySql</title><link>http://bbs.progenic.com/Topic11667-9-1.aspx</link><description>&lt;div class="Quote"&gt;&lt;b&gt;wax (9/5/2007)&lt;/b&gt;&lt;hr noshade size="1" class="hr"&gt;I hope it's not actually the same as @@identity, but rather scope_identity()..&lt;P&gt;scope_identity() is the last inserted id for your scope (query, stored proc, trigger)&lt;/P&gt;&lt;P&gt;@@identity is last inserted id for the database for your connection&lt;/P&gt;&lt;P&gt;Or in other words - on busy systems with heavy inserting going on, @@identity can return the wrong id&lt;/div&gt;&lt;P&gt;hmm from what I read it is for the current connection which i assume means between con.open and con.close.&lt;P&gt;Sound right to you?</description><pubDate>Wed, 05 Sep 2007 12:19:06 GMT</pubDate><dc:creator>proge</dc:creator></item><item><title>RE: @@Identity in MySql</title><link>http://bbs.progenic.com/Topic11667-9-1.aspx</link><description>mhm....all i can agree with is that databasez are bitches&lt;br&gt;hed trouble with swl at absolutel every site i worked on&lt;br&gt;absolutely no exceptions</description><pubDate>Wed, 05 Sep 2007 11:29:37 GMT</pubDate><dc:creator>_Infernal_</dc:creator></item><item><title>RE: @@Identity in MySql</title><link>http://bbs.progenic.com/Topic11667-9-1.aspx</link><description>I hope it's not actually the same as @@identity, but rather scope_identity()..&lt;/P&gt;&lt;P&gt;scope_identity() is the last inserted id for your scope (query, stored proc, trigger)&lt;/P&gt;&lt;P&gt;@@identity is last inserted id for the database for your connection&lt;/P&gt;&lt;P&gt;Or in other words - on busy systems with heavy inserting going on, @@identity can return the wrong id</description><pubDate>Wed, 05 Sep 2007 11:28:28 GMT</pubDate><dc:creator>wax</dc:creator></item><item><title>RE: @@Identity in MySql</title><link>http://bbs.progenic.com/Topic11667-9-1.aspx</link><description>It's for an antispam system i'm working on. It's been quite interesting learning how mysql differs from mssql.&lt;P&gt;Two other differences that stumped me for a while were that mysql doesn't have GetDate() as an sql function so i had to swap that to Now(), and the one I got stuck on the longest was when you use parameterized queries, mssql variables are named like @Variable but in mysql it's ?Variable. It gave me no error messages when i used @Variable it just didn't work, took me f**king forever to work that out &lt;img align="absmiddle" src="http://bbs.progenic.com/Skins/Common/EmotIcons/Smile.gif" border="0" title="Smile"&gt;.</description><pubDate>Wed, 05 Sep 2007 10:52:16 GMT</pubDate><dc:creator>proge</dc:creator></item><item><title>RE: @@Identity in MySql</title><link>http://bbs.progenic.com/Topic11667-9-1.aspx</link><description>just out of curiosity&lt;br&gt;where are u using this&lt;br&gt;&lt;br&gt;just if ya want to say &lt;img align="absmiddle" src="http://bbs.progenic.com/Skins/Common/EmotIcons/Tongue.gif" border="0" title="Tongue"&gt;</description><pubDate>Wed, 05 Sep 2007 10:12:06 GMT</pubDate><dc:creator>_Infernal_</dc:creator></item><item><title>RE: @@Identity in MySql</title><link>http://bbs.progenic.com/Topic11667-9-1.aspx</link><description>sorted &lt;img align="absmiddle" src="http://bbs.progenic.com/Skins/Common/EmotIcons/Smile.gif" border="0" title="Smile"&gt; it's SELECT LAST_INSERT_ID() and it can be used in c# like so:&lt;/P&gt;&lt;P&gt;&lt;pre&gt; public int InsertContactList(objContactList list)&lt;BR&gt;        {&lt;/P&gt;&lt;P&gt;            MySqlCommand cmd;&lt;/P&gt;&lt;P&gt;            conn.Open();&lt;BR&gt;            cmd = new MySqlCommand("insert into contact_lists (ListName,UserID) values (?ListName,?UserID);Select LAST_INSERT_ID();", conn);&lt;BR&gt;            &lt;BR&gt;            cmd.Parameters.AddWithValue("?ListName", list.ListName);&lt;BR&gt;            cmd.Parameters.AddWithValue("?UserID", list.UserID);&lt;/P&gt;&lt;P&gt;            int i = (int)(long)cmd.ExecuteScalar();&lt;BR&gt;            conn.Close();&lt;BR&gt;            return i;&lt;/P&gt;&lt;P&gt;        }&lt;/pre&gt;</description><pubDate>Wed, 05 Sep 2007 08:27:29 GMT</pubDate><dc:creator>proge</dc:creator></item><item><title>@@Identity in MySql</title><link>http://bbs.progenic.com/Topic11667-9-1.aspx</link><description>I'm trying to get the row id for the record i just entered, i could select the max id for the primary key but this is going to be a huge multithreaded system and can't risk returning the wrong ID.&lt;P&gt;In mssql you have @@Identiy which can return the id of the row you added, anybody know if there is an equivalant in mysql?</description><pubDate>Wed, 05 Sep 2007 07:55:38 GMT</pubDate><dc:creator>proge</dc:creator></item></channel></rss>
